protocol-grpc 0.13.0 → 0.14.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 +4 -3
- data/design.md +0 -12
- data/lib/protocol/grpc/call.rb +6 -10
- data/lib/protocol/grpc/version.rb +1 -1
- data/lib/protocol/grpc.rb +0 -1
- data/readme.md +9 -0
- data/releases.md +9 -0
- data.tar.gz.sig +0 -0
- metadata +1 -2
- metadata.gz.sig +0 -0
- data/lib/protocol/grpc/methods.rb +0 -81
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c7aa96e69acd0574147e4c3e8c16fba62e8278d01e094267d3cb3427221d8fa0
|
|
4
|
+
data.tar.gz: 303976d191a6b5ff5e20db644ef2f29a71c5b7c346558eac2a3e5122c1197bff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1bc1343e7e2e8e21206139992f9483a1c970b21456f90bfb124d4fdd8728eedb51b921a7d93999ece219fd4b079cb9c9e0b2433750e6ee249c234124a1dfaba3
|
|
7
|
+
data.tar.gz: cea3a080a0cea063968a40939451b2c2f044f1e4b9068b64f231272e7f2c2d953f6f7ceabef437762700cf2d36b04a90ffb94dfd43ef76f2e5b4ed55d6e4ba29
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/context/getting-started.md
CHANGED
|
@@ -18,7 +18,7 @@ $ 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
|
|
21
|
+
- A {ruby Protocol::GRPC::Call} class which represents the request, response, metadata, and deadline for a single gRPC RPC call.
|
|
22
22
|
- A {ruby Protocol::GRPC::Status} module with gRPC status code constants.
|
|
23
23
|
- A {ruby Protocol::GRPC::Error} hierarchy for gRPC-specific error handling.
|
|
24
24
|
|
|
@@ -132,13 +132,14 @@ end
|
|
|
132
132
|
``` ruby
|
|
133
133
|
require "protocol/grpc/call"
|
|
134
134
|
|
|
135
|
-
call = Protocol::GRPC::Call.new(request, deadline: deadline)
|
|
135
|
+
call = Protocol::GRPC::Call.new(request, response, deadline: deadline)
|
|
136
136
|
|
|
137
137
|
# Access request
|
|
138
138
|
call.request # => Protocol::HTTP::Request
|
|
139
139
|
|
|
140
|
-
# Check deadline
|
|
140
|
+
# Check deadline and status
|
|
141
141
|
call.deadline.exceeded? # => false
|
|
142
|
+
call.status # => Protocol::GRPC::Status::OK
|
|
142
143
|
|
|
143
144
|
# Access peer information
|
|
144
145
|
call.peer # => Protocol::HTTP::Address
|
data/design.md
CHANGED
|
@@ -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
|
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.rb
CHANGED
|
@@ -10,7 +10,6 @@ require_relative "grpc/error"
|
|
|
10
10
|
require_relative "grpc/route"
|
|
11
11
|
require_relative "grpc/header"
|
|
12
12
|
require_relative "grpc/metadata"
|
|
13
|
-
require_relative "grpc/methods"
|
|
14
13
|
require_relative "grpc/call"
|
|
15
14
|
require_relative "grpc/body/readable"
|
|
16
15
|
require_relative "grpc/body/writable"
|
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.14.0
|
|
32
|
+
|
|
33
|
+
- **Breaking**: Removed the unused `Protocol::GRPC::Call#cancel!` and `Protocol::GRPC::Call#cancelled?` methods.
|
|
34
|
+
- Added `Protocol::GRPC::Call#status` to report the status assigned to the response.
|
|
35
|
+
|
|
36
|
+
### v0.13.1
|
|
37
|
+
|
|
38
|
+
- **Breaking**: Removed the deprecated `Protocol::GRPC::Methods` module. Use `Protocol::GRPC::Route`, `Protocol::GRPC::Metadata`, and `Protocol::GRPC::Header::Timeout` instead.
|
|
39
|
+
|
|
31
40
|
### v0.13.0
|
|
32
41
|
|
|
33
42
|
- Added `Protocol::GRPC::Route` for building and parsing gRPC request paths.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.14.0
|
|
4
|
+
|
|
5
|
+
- **Breaking**: Removed the unused `Protocol::GRPC::Call#cancel!` and `Protocol::GRPC::Call#cancelled?` methods.
|
|
6
|
+
- Added `Protocol::GRPC::Call#status` to report the status assigned to the response.
|
|
7
|
+
|
|
8
|
+
## v0.13.1
|
|
9
|
+
|
|
10
|
+
- **Breaking**: Removed the deprecated `Protocol::GRPC::Methods` module. Use `Protocol::GRPC::Route`, `Protocol::GRPC::Metadata`, and `Protocol::GRPC::Header::Timeout` instead.
|
|
11
|
+
|
|
3
12
|
## v0.13.0
|
|
4
13
|
|
|
5
14
|
- Added `Protocol::GRPC::Route` for building and parsing gRPC request paths.
|
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.
|
|
4
|
+
version: 0.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -116,7 +116,6 @@ files:
|
|
|
116
116
|
- lib/protocol/grpc/health_check.rb
|
|
117
117
|
- lib/protocol/grpc/interface.rb
|
|
118
118
|
- lib/protocol/grpc/metadata.rb
|
|
119
|
-
- lib/protocol/grpc/methods.rb
|
|
120
119
|
- lib/protocol/grpc/middleware.rb
|
|
121
120
|
- lib/protocol/grpc/route.rb
|
|
122
121
|
- lib/protocol/grpc/status.rb
|
metadata.gz.sig
CHANGED
|
Binary file
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Released under the MIT License.
|
|
4
|
-
# Copyright, 2025-2026, by Samuel Williams.
|
|
5
|
-
|
|
6
|
-
require_relative "metadata"
|
|
7
|
-
require_relative "route"
|
|
8
|
-
|
|
9
|
-
module Protocol
|
|
10
|
-
module GRPC
|
|
11
|
-
# Provides utility methods for building and parsing gRPC-compatible HTTP requests.
|
|
12
|
-
module Methods
|
|
13
|
-
# Build gRPC path from service and method.
|
|
14
|
-
# @parameter service [String] e.g., "my_service.Greeter"
|
|
15
|
-
# @parameter method [String] e.g., "SayHello"
|
|
16
|
-
# @returns [String] e.g., "/my_service.Greeter/SayHello"
|
|
17
|
-
# @deprecated Use {Route.build} instead.
|
|
18
|
-
def self.build_path(service, method)
|
|
19
|
-
Kernel.warn("`Protocol::GRPC::Methods.build_path` is deprecated; use `Protocol::GRPC::Route.build` instead.", uplevel: 1, category: :deprecated) if $VERBOSE
|
|
20
|
-
|
|
21
|
-
Route.build(service, method)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Parse service and method from gRPC path.
|
|
25
|
-
# @parameter path [String] e.g., "/my_service.Greeter/SayHello"
|
|
26
|
-
# @returns [Array(String | String)] [service, method]
|
|
27
|
-
# @deprecated Use {Route.parse} instead.
|
|
28
|
-
def self.parse_path(path)
|
|
29
|
-
Kernel.warn("`Protocol::GRPC::Methods.parse_path` is deprecated; use `Protocol::GRPC::Route.parse` instead.", uplevel: 1, category: :deprecated) if $VERBOSE
|
|
30
|
-
|
|
31
|
-
Route.parse(path)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Build gRPC request headers.
|
|
35
|
-
# @parameter metadata [Hash] Custom metadata key-value pairs
|
|
36
|
-
# @parameter timeout [Numeric | Nil] Optional timeout in seconds
|
|
37
|
-
# @parameter content_type [String] Content type (default: "application/grpc+proto")
|
|
38
|
-
# @returns [Protocol::HTTP::Headers]
|
|
39
|
-
# @deprecated Use {Metadata.build} instead.
|
|
40
|
-
def self.build_headers(metadata: {}, timeout: nil, content_type: "application/grpc+proto")
|
|
41
|
-
Kernel.warn("`Protocol::GRPC::Methods.build_headers` is deprecated; use `Protocol::GRPC::Metadata.build` instead.", uplevel: 1, category: :deprecated) if $VERBOSE
|
|
42
|
-
|
|
43
|
-
Metadata.build(metadata: metadata, timeout: timeout, content_type: content_type)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Extract metadata from gRPC headers.
|
|
47
|
-
# @parameter headers [Protocol::HTTP::Headers]
|
|
48
|
-
# @returns [Hash] Metadata key-value pairs
|
|
49
|
-
# @deprecated Use {Metadata.extract} instead.
|
|
50
|
-
def self.extract_metadata(headers)
|
|
51
|
-
Kernel.warn("`Protocol::GRPC::Methods.extract_metadata` is deprecated; use `Protocol::GRPC::Metadata.extract` instead.", uplevel: 1, category: :deprecated) if $VERBOSE
|
|
52
|
-
|
|
53
|
-
Metadata.extract(headers)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Format timeout for grpc-timeout header.
|
|
57
|
-
# @parameter timeout [Numeric] Timeout in seconds
|
|
58
|
-
# @returns [String] e.g., "1000m" for 1 second
|
|
59
|
-
# @deprecated Use {Protocol::GRPC::Header::Timeout.format} instead.
|
|
60
|
-
def self.format_timeout(timeout)
|
|
61
|
-
Kernel.warn("`Protocol::GRPC::Methods.format_timeout` is deprecated; use `Protocol::GRPC::Header::Timeout.format` instead.", uplevel: 1, category: :deprecated) if $VERBOSE
|
|
62
|
-
|
|
63
|
-
Header::Timeout.format(timeout)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# Parse grpc-timeout header value.
|
|
67
|
-
# @parameter value [String] e.g., "1000m"
|
|
68
|
-
# @returns [Numeric | Nil] Timeout in seconds, or `Nil` if value is invalid
|
|
69
|
-
# @deprecated Use {Protocol::GRPC::Header::Timeout#to_seconds} instead.
|
|
70
|
-
def self.parse_timeout(value)
|
|
71
|
-
Kernel.warn("`Protocol::GRPC::Methods.parse_timeout` is deprecated; use `Protocol::GRPC::Header::Timeout#to_seconds` instead.", uplevel: 1, category: :deprecated) if $VERBOSE
|
|
72
|
-
|
|
73
|
-
return nil unless value
|
|
74
|
-
|
|
75
|
-
Header::Timeout.parse(value).to_seconds
|
|
76
|
-
rescue ArgumentError
|
|
77
|
-
return nil
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|