protocol-grpc 0.13.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 034feb2e3b17d2cdf00697215d48a3d62d328c37df11f437b410ac6a0878b16f
4
- data.tar.gz: 3a94f6c1431029e2449383ef0f51196cc4aa7dd5e60f33d938270ffa05e877a8
3
+ metadata.gz: 2195318192e11fc3cafc54e82ccb65b4111e1e5ab9d1772ec8e4e002e6251136
4
+ data.tar.gz: 9916efb3e3966c9242cbefca5534d233f82d079d363a4ecec86c4808dd707bcf
5
5
  SHA512:
6
- metadata.gz: 141ad27dd57585879827d433964c3e8de3895cd41347b49b909bc5d33bc92bc87f5825bfd46bc167b01c99d3d7a37cd83741b2f3e473391af2148b25d427993c
7
- data.tar.gz: 8997edac6e081b1681cc8bbee2b5d4ea49de5f6af12dacd55946353a301f32d9446ab9487bf6ec27df15209303b264afa231ef5f7fbc67e7fb2bf2f03d440761
6
+ metadata.gz: 8236e53f25377fc556da30e47e36e8828a20fb7b2064d7a2b8046309f23ab26e98f3a8338842fb429f47fb510e58361ebcc1e06f24d097f4d37507159eb050b6
7
+ data.tar.gz: 2941d6b8edb774e16c6530b20cc76d330fccc05021564a32bb5bf8b4e5448c4e664001d3a59bd71cf584d4c276688b84749c6096582ff2661be6e761ca729650
checksums.yaml.gz.sig CHANGED
Binary file
@@ -18,8 +18,8 @@ $ bundle add protocol-grpc
18
18
  - A {ruby Protocol::GRPC::Body::Readable} class which handles reading gRPC messages from HTTP request/response bodies with automatic framing and decoding.
19
19
  - A {ruby Protocol::GRPC::Body::Writable} class which handles writing gRPC messages to HTTP request/response bodies with automatic framing and encoding.
20
20
  - A {ruby Protocol::GRPC::Middleware} abstract base class for building gRPC server applications.
21
- - A {ruby Protocol::GRPC::Call} class which represents the context of a single gRPC RPC call, including deadline tracking.
22
- - A {ruby Protocol::GRPC::Status} module with gRPC status code constants.
21
+ - A {ruby Protocol::GRPC::Call} class which represents the request, response, metadata, and deadline for a single gRPC RPC call.
22
+ - A {ruby Protocol::GRPC::Status} module with gRPC status code constants and names.
23
23
  - A {ruby Protocol::GRPC::Error} hierarchy for gRPC-specific error handling.
24
24
 
25
25
  ## Integration
@@ -103,6 +103,9 @@ if status != Protocol::GRPC::Status::OK
103
103
  message = Protocol::GRPC::Metadata.extract_message(response.headers)
104
104
  raise Protocol::GRPC::Error.for(status, message)
105
105
  end
106
+
107
+ # Use canonical gRPC status names for logging, metrics, or serialization:
108
+ Protocol::GRPC::Status::NAMES[status] # => "OK"
106
109
  ```
107
110
 
108
111
  ### Server Middleware
@@ -132,13 +135,14 @@ end
132
135
  ``` ruby
133
136
  require "protocol/grpc/call"
134
137
 
135
- call = Protocol::GRPC::Call.new(request, deadline: deadline)
138
+ call = Protocol::GRPC::Call.new(request, response, deadline: deadline)
136
139
 
137
140
  # Access request
138
141
  call.request # => Protocol::HTTP::Request
139
142
 
140
- # Check deadline
143
+ # Check deadline and status
141
144
  call.deadline.exceeded? # => false
145
+ call.status # => Protocol::GRPC::Status::OK
142
146
 
143
147
  # Access peer information
144
148
  call.peer # => Protocol::HTTP::Address
data/design.md CHANGED
@@ -496,25 +496,25 @@ module Protocol
496
496
  DATA_LOSS = 15
497
497
  UNAUTHENTICATED = 16
498
498
 
499
- # Status code descriptions
500
- DESCRIPTIONS = {
499
+ # Status code names
500
+ NAMES = {
501
501
  OK => "OK",
502
- CANCELLED => "Cancelled",
503
- UNKNOWN => "Unknown",
504
- INVALID_ARGUMENT => "Invalid Argument",
505
- DEADLINE_EXCEEDED => "Deadline Exceeded",
506
- NOT_FOUND => "Not Found",
507
- ALREADY_EXISTS => "Already Exists",
508
- PERMISSION_DENIED => "Permission Denied",
509
- RESOURCE_EXHAUSTED => "Resource Exhausted",
510
- FAILED_PRECONDITION => "Failed Precondition",
511
- ABORTED => "Aborted",
512
- OUT_OF_RANGE => "Out of Range",
513
- UNIMPLEMENTED => "Unimplemented",
514
- INTERNAL => "Internal",
515
- UNAVAILABLE => "Unavailable",
516
- DATA_LOSS => "Data Loss",
517
- UNAUTHENTICATED => "Unauthenticated"
502
+ CANCELLED => "CANCELLED",
503
+ UNKNOWN => "UNKNOWN",
504
+ INVALID_ARGUMENT => "INVALID_ARGUMENT",
505
+ DEADLINE_EXCEEDED => "DEADLINE_EXCEEDED",
506
+ NOT_FOUND => "NOT_FOUND",
507
+ ALREADY_EXISTS => "ALREADY_EXISTS",
508
+ PERMISSION_DENIED => "PERMISSION_DENIED",
509
+ RESOURCE_EXHAUSTED => "RESOURCE_EXHAUSTED",
510
+ FAILED_PRECONDITION => "FAILED_PRECONDITION",
511
+ ABORTED => "ABORTED",
512
+ OUT_OF_RANGE => "OUT_OF_RANGE",
513
+ UNIMPLEMENTED => "UNIMPLEMENTED",
514
+ INTERNAL => "INTERNAL",
515
+ UNAVAILABLE => "UNAVAILABLE",
516
+ DATA_LOSS => "DATA_LOSS",
517
+ UNAUTHENTICATED => "UNAUTHENTICATED"
518
518
  }.freeze
519
519
  end
520
520
  end
@@ -535,7 +535,6 @@ module Protocol
535
535
  def initialize(request, deadline: nil)
536
536
  @request = request
537
537
  @deadline = deadline
538
- @cancelled = false
539
538
  end
540
539
 
541
540
  # @attribute [Protocol::HTTP::Request] The underlying HTTP request
@@ -562,17 +561,6 @@ module Protocol
562
561
  @deadline ? [@deadline - Time.now, 0].max : nil
563
562
  end
564
563
 
565
- # Mark this call as cancelled
566
- def cancel!
567
- @cancelled = true
568
- end
569
-
570
- # Check if call was cancelled
571
- # @returns [Boolean]
572
- def cancelled?
573
- @cancelled
574
- end
575
-
576
564
  # Get peer information (client address)
577
565
  # @returns [String | Nil]
578
566
  def peer
@@ -597,7 +585,7 @@ module Protocol
597
585
  @status_code = status_code
598
586
  @details = details
599
587
  @metadata = metadata
600
- super(message || Status::DESCRIPTIONS[status_code])
588
+ super(message || Status::NAMES[status_code])
601
589
  end
602
590
  end
603
591
 
@@ -31,7 +31,6 @@ module Protocol
31
31
  @request = request
32
32
  @response = response
33
33
  @deadline = deadline
34
- @cancelled = false
35
34
  end
36
35
 
37
36
  # @attribute [Protocol::HTTP::Request] The underlying HTTP request.
@@ -67,15 +66,12 @@ module Protocol
67
66
  @deadline&.remaining
68
67
  end
69
68
 
70
- # Mark this call as cancelled.
71
- def cancel!
72
- @cancelled = true
73
- end
74
-
75
- # Check if the call was cancelled.
76
- # @returns [Boolean] `true` if the call was cancelled, `false` otherwise
77
- def cancelled?
78
- @cancelled
69
+ # Get the current gRPC status of the call.
70
+ # @returns [Integer | Nil] The current gRPC status code, if available.
71
+ def status
72
+ if headers = @response&.headers
73
+ headers["grpc-status"]&.to_i
74
+ end
79
75
  end
80
76
 
81
77
  # Get peer information (client address).
@@ -17,7 +17,7 @@ module Protocol
17
17
  @status_code = status_code
18
18
  @details = details
19
19
  @metadata = metadata
20
- super(message || Status::DESCRIPTIONS[status_code])
20
+ super(message || Status::NAMES[status_code])
21
21
  end
22
22
 
23
23
  # Map status code to error class
@@ -5,7 +5,7 @@
5
5
 
6
6
  module Protocol
7
7
  module GRPC
8
- # Provides gRPC status codes and their descriptions.
8
+ # Provides gRPC status codes and their names.
9
9
  module Status
10
10
  OK = 0
11
11
  CANCELLED = 1
@@ -25,25 +25,25 @@ module Protocol
25
25
  DATA_LOSS = 15
26
26
  UNAUTHENTICATED = 16
27
27
 
28
- # Status code descriptions
29
- DESCRIPTIONS = {
28
+ # Status code names, as defined by the gRPC specification.
29
+ NAMES = {
30
30
  OK => "OK",
31
- CANCELLED => "Cancelled",
32
- UNKNOWN => "Unknown",
33
- INVALID_ARGUMENT => "Invalid Argument",
34
- DEADLINE_EXCEEDED => "Deadline Exceeded",
35
- NOT_FOUND => "Not Found",
36
- ALREADY_EXISTS => "Already Exists",
37
- PERMISSION_DENIED => "Permission Denied",
38
- RESOURCE_EXHAUSTED => "Resource Exhausted",
39
- FAILED_PRECONDITION => "Failed Precondition",
40
- ABORTED => "Aborted",
41
- OUT_OF_RANGE => "Out of Range",
42
- UNIMPLEMENTED => "Unimplemented",
43
- INTERNAL => "Internal",
44
- UNAVAILABLE => "Unavailable",
45
- DATA_LOSS => "Data Loss",
46
- UNAUTHENTICATED => "Unauthenticated"
31
+ CANCELLED => "CANCELLED",
32
+ UNKNOWN => "UNKNOWN",
33
+ INVALID_ARGUMENT => "INVALID_ARGUMENT",
34
+ DEADLINE_EXCEEDED => "DEADLINE_EXCEEDED",
35
+ NOT_FOUND => "NOT_FOUND",
36
+ ALREADY_EXISTS => "ALREADY_EXISTS",
37
+ PERMISSION_DENIED => "PERMISSION_DENIED",
38
+ RESOURCE_EXHAUSTED => "RESOURCE_EXHAUSTED",
39
+ FAILED_PRECONDITION => "FAILED_PRECONDITION",
40
+ ABORTED => "ABORTED",
41
+ OUT_OF_RANGE => "OUT_OF_RANGE",
42
+ UNIMPLEMENTED => "UNIMPLEMENTED",
43
+ INTERNAL => "INTERNAL",
44
+ UNAVAILABLE => "UNAVAILABLE",
45
+ DATA_LOSS => "DATA_LOSS",
46
+ UNAUTHENTICATED => "UNAUTHENTICATED"
47
47
  }.freeze
48
48
  end
49
49
  end
@@ -7,7 +7,7 @@
7
7
  module Protocol
8
8
  # @namespace
9
9
  module GRPC
10
- VERSION = "0.13.1"
10
+ VERSION = "0.15.0"
11
11
  end
12
12
  end
13
13
 
data/readme.md CHANGED
@@ -28,6 +28,15 @@ Please see the [project documentation](https://socketry.github.io/protocol-grpc/
28
28
 
29
29
  Please see the [project releases](https://socketry.github.io/protocol-grpc/releases/index) for all releases.
30
30
 
31
+ ### v0.15.0
32
+
33
+ - **Breaking**: Removed `Protocol::GRPC::Status::DESCRIPTIONS`. Use `Protocol::GRPC::Status::NAMES` for canonical gRPC status names.
34
+
35
+ ### v0.14.0
36
+
37
+ - **Breaking**: Removed the unused `Protocol::GRPC::Call#cancel!` and `Protocol::GRPC::Call#cancelled?` methods.
38
+ - Added `Protocol::GRPC::Call#status` to report the status assigned to the response.
39
+
31
40
  ### v0.13.1
32
41
 
33
42
  - **Breaking**: Removed the deprecated `Protocol::GRPC::Methods` module. Use `Protocol::GRPC::Route`, `Protocol::GRPC::Metadata`, and `Protocol::GRPC::Header::Timeout` instead.
@@ -66,10 +75,6 @@ Please see the [project releases](https://socketry.github.io/protocol-grpc/relea
66
75
 
67
76
  - `RPC#method` is always defined (snake case).
68
77
 
69
- ### v0.1.0
70
-
71
- - Initial design.
72
-
73
78
  ## See Also
74
79
 
75
80
  - [async-grpc](https://github.com/socketry/async-grpc) — Asynchronous gRPC client and server implementation using this interface.
data/releases.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Releases
2
2
 
3
+ ## v0.15.0
4
+
5
+ - **Breaking**: Removed `Protocol::GRPC::Status::DESCRIPTIONS`. Use `Protocol::GRPC::Status::NAMES` for canonical gRPC status names.
6
+
7
+ ## v0.14.0
8
+
9
+ - **Breaking**: Removed the unused `Protocol::GRPC::Call#cancel!` and `Protocol::GRPC::Call#cancelled?` methods.
10
+ - Added `Protocol::GRPC::Call#status` to report the status assigned to the response.
11
+
3
12
  ## v0.13.1
4
13
 
5
14
  - **Breaking**: Removed the deprecated `Protocol::GRPC::Methods` module. Use `Protocol::GRPC::Route`, `Protocol::GRPC::Metadata`, and `Protocol::GRPC::Header::Timeout` instead.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-grpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file