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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/context/getting-started.md +8 -4
- data/design.md +19 -31
- data/lib/protocol/grpc/call.rb +6 -10
- data/lib/protocol/grpc/error.rb +1 -1
- data/lib/protocol/grpc/status.rb +19 -19
- data/lib/protocol/grpc/version.rb +1 -1
- data/readme.md +9 -4
- data/releases.md +9 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2195318192e11fc3cafc54e82ccb65b4111e1e5ab9d1772ec8e4e002e6251136
|
|
4
|
+
data.tar.gz: 9916efb3e3966c9242cbefca5534d233f82d079d363a4ecec86c4808dd707bcf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8236e53f25377fc556da30e47e36e8828a20fb7b2064d7a2b8046309f23ab26e98f3a8338842fb429f47fb510e58361ebcc1e06f24d097f4d37507159eb050b6
|
|
7
|
+
data.tar.gz: 2941d6b8edb774e16c6530b20cc76d330fccc05021564a32bb5bf8b4e5448c4e664001d3a59bd71cf584d4c276688b84749c6096582ff2661be6e761ca729650
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/context/getting-started.md
CHANGED
|
@@ -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
|
|
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
|
|
500
|
-
|
|
499
|
+
# Status code names
|
|
500
|
+
NAMES = {
|
|
501
501
|
OK => "OK",
|
|
502
|
-
CANCELLED => "
|
|
503
|
-
UNKNOWN => "
|
|
504
|
-
INVALID_ARGUMENT => "
|
|
505
|
-
DEADLINE_EXCEEDED => "
|
|
506
|
-
NOT_FOUND => "
|
|
507
|
-
ALREADY_EXISTS => "
|
|
508
|
-
PERMISSION_DENIED => "
|
|
509
|
-
RESOURCE_EXHAUSTED => "
|
|
510
|
-
FAILED_PRECONDITION => "
|
|
511
|
-
ABORTED => "
|
|
512
|
-
OUT_OF_RANGE => "
|
|
513
|
-
UNIMPLEMENTED => "
|
|
514
|
-
INTERNAL => "
|
|
515
|
-
UNAVAILABLE => "
|
|
516
|
-
DATA_LOSS => "
|
|
517
|
-
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::
|
|
588
|
+
super(message || Status::NAMES[status_code])
|
|
601
589
|
end
|
|
602
590
|
end
|
|
603
591
|
|
data/lib/protocol/grpc/call.rb
CHANGED
|
@@ -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
|
-
#
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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).
|
data/lib/protocol/grpc/error.rb
CHANGED
data/lib/protocol/grpc/status.rb
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
module Protocol
|
|
7
7
|
module GRPC
|
|
8
|
-
# Provides gRPC status codes and their
|
|
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
|
|
29
|
-
|
|
28
|
+
# Status code names, as defined by the gRPC specification.
|
|
29
|
+
NAMES = {
|
|
30
30
|
OK => "OK",
|
|
31
|
-
CANCELLED => "
|
|
32
|
-
UNKNOWN => "
|
|
33
|
-
INVALID_ARGUMENT => "
|
|
34
|
-
DEADLINE_EXCEEDED => "
|
|
35
|
-
NOT_FOUND => "
|
|
36
|
-
ALREADY_EXISTS => "
|
|
37
|
-
PERMISSION_DENIED => "
|
|
38
|
-
RESOURCE_EXHAUSTED => "
|
|
39
|
-
FAILED_PRECONDITION => "
|
|
40
|
-
ABORTED => "
|
|
41
|
-
OUT_OF_RANGE => "
|
|
42
|
-
UNIMPLEMENTED => "
|
|
43
|
-
INTERNAL => "
|
|
44
|
-
UNAVAILABLE => "
|
|
45
|
-
DATA_LOSS => "
|
|
46
|
-
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
|
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
metadata.gz.sig
CHANGED
|
Binary file
|