async-grpc 0.6.0 → 0.7.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/lib/async/grpc/client.rb +6 -3
- data/lib/async/grpc/remote_error.rb +1 -1
- data/lib/async/grpc/stub.rb +5 -4
- data/lib/async/grpc/version.rb +1 -1
- data/readme.md +16 -0
- data.tar.gz.sig +0 -0
- metadata +8 -8
- 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: 13df5d80dfc403580a0b3efa15de081d71f285901a5f082bacb7cb840b23f66f
|
|
4
|
+
data.tar.gz: 59f811ca32b0beac56192f587be2e3184279c5d9160891b9b931b20229473033
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d85ab093902e64a2ea3877f788eeac19bd6ae005bf47d3ddfa52831d0fa8193255f6ae0158b7bbb6897f4f5cdd39935cf03d7b14b9139da8257ffef07e1258e
|
|
7
|
+
data.tar.gz: ee29fe46cf81d22298c94c5cb63b17a4783e4159f6110f70efc91444d507f47aec2bf14346d7e6187b9b40bee3f18a1e38c511afc0250c3f2fadbf88790495b7
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/async/grpc/client.rb
CHANGED
|
@@ -113,11 +113,12 @@ module Async
|
|
|
113
113
|
# @parameter metadata [Hash] Custom metadata headers
|
|
114
114
|
# @parameter timeout [Numeric | Nil] Optional timeout in seconds
|
|
115
115
|
# @parameter encoding [String | Nil] Optional compression encoding
|
|
116
|
+
# @parameter initial [Object | Array | Nil] Optional initial message(s) for bidirectional streaming
|
|
116
117
|
# @yields {|input, output| ...} Block for streaming calls
|
|
117
118
|
# @returns [Object | Protocol::GRPC::Body::ReadableBody] Response message or readable body for streaming
|
|
118
119
|
# @raises [ArgumentError] If method is unknown or streaming type is invalid
|
|
119
120
|
# @raises [Protocol::GRPC::Error] If the gRPC call fails
|
|
120
|
-
def invoke(service, method, request = nil, metadata: {}, timeout: nil, encoding: nil, &block)
|
|
121
|
+
def invoke(service, method, request = nil, metadata: {}, timeout: nil, encoding: nil, initial: nil, &block)
|
|
121
122
|
rpc = service.class.lookup_rpc(method)
|
|
122
123
|
raise ArgumentError, "Unknown method: #{method}" unless rpc
|
|
123
124
|
|
|
@@ -141,7 +142,7 @@ module Async
|
|
|
141
142
|
when :client_streaming
|
|
142
143
|
client_streaming_call(path, headers, request_class, response_class, encoding, &block)
|
|
143
144
|
when :bidirectional
|
|
144
|
-
bidirectional_call(path, headers, request_class, response_class, encoding, &block)
|
|
145
|
+
bidirectional_call(path, headers, request_class, response_class, encoding, initial: initial, &block)
|
|
145
146
|
else
|
|
146
147
|
raise ArgumentError, "Unknown streaming type: #{streaming}"
|
|
147
148
|
end
|
|
@@ -273,14 +274,16 @@ module Async
|
|
|
273
274
|
# @parameter request_class [Class] Request message class
|
|
274
275
|
# @parameter response_class [Class] Response message class
|
|
275
276
|
# @parameter encoding [String | Nil] Compression encoding
|
|
277
|
+
# @parameter initial [Object | Array | Nil] Optional initial message(s) to write before waiting for the response
|
|
276
278
|
# @yields {|input, output| ...} Block to handle bidirectional streaming
|
|
277
279
|
# @returns [Protocol::GRPC::Body::ReadableBody] Readable body for streaming messages
|
|
278
280
|
# @raises [Protocol::GRPC::Error] If the gRPC call fails
|
|
279
|
-
def bidirectional_call(path, headers, request_class, response_class, encoding, &block)
|
|
281
|
+
def bidirectional_call(path, headers, request_class, response_class, encoding, initial: nil, &block)
|
|
280
282
|
body = Protocol::GRPC::Body::WritableBody.new(
|
|
281
283
|
encoding: encoding,
|
|
282
284
|
message_class: request_class
|
|
283
285
|
)
|
|
286
|
+
Array(initial).each{|message| body.write(message)}
|
|
284
287
|
|
|
285
288
|
http_request = Protocol::HTTP::Request["POST", path, headers, body]
|
|
286
289
|
response = call(http_request)
|
data/lib/async/grpc/stub.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
|
-
# Copyright, 2025, by Samuel Williams.
|
|
4
|
+
# Copyright, 2025-2026, by Samuel Williams.
|
|
5
5
|
|
|
6
6
|
require "protocol/grpc/interface"
|
|
7
7
|
|
|
@@ -36,7 +36,7 @@ module Async
|
|
|
36
36
|
# Uses snake_case method names (Ruby convention).
|
|
37
37
|
# @parameter method_name [Symbol] The method name to call (snake_case)
|
|
38
38
|
# @parameter args [Array] Positional arguments (first is the request message)
|
|
39
|
-
# @parameter options [Hash] Keyword arguments (metadata, timeout, encoding)
|
|
39
|
+
# @parameter options [Hash] Keyword arguments (metadata, timeout, encoding, initial)
|
|
40
40
|
# @yields {|input, output| ...} Block for streaming calls
|
|
41
41
|
# @returns [Object | Protocol::GRPC::Body::ReadableBody] Response message or readable body
|
|
42
42
|
# @raises [NoMethodError] If the method is not found
|
|
@@ -47,13 +47,14 @@ module Async
|
|
|
47
47
|
# Extract request from args (first positional argument):
|
|
48
48
|
request = args.first
|
|
49
49
|
|
|
50
|
-
# Extract metadata, timeout, encoding from options:
|
|
50
|
+
# Extract metadata, timeout, encoding and initial messages from options:
|
|
51
51
|
metadata = options.delete(:metadata) || {}
|
|
52
52
|
timeout = options.delete(:timeout)
|
|
53
53
|
encoding = options.delete(:encoding)
|
|
54
|
+
initial = options.delete(:initial)
|
|
54
55
|
|
|
55
56
|
# Delegate to client.invoke with PascalCase method name (for interface lookup):
|
|
56
|
-
@client.invoke(@interface, interface_method_name, request, metadata: metadata, timeout: timeout, encoding: encoding, &block)
|
|
57
|
+
@client.invoke(@interface, interface_method_name, request, metadata: metadata, timeout: timeout, encoding: encoding, initial: initial, &block)
|
|
57
58
|
else
|
|
58
59
|
super
|
|
59
60
|
end
|
data/lib/async/grpc/version.rb
CHANGED
data/readme.md
CHANGED
|
@@ -72,6 +72,22 @@ We welcome contributions to this project.
|
|
|
72
72
|
4. Push to the branch (`git push origin my-new-feature`).
|
|
73
73
|
5. Create new Pull Request.
|
|
74
74
|
|
|
75
|
+
### Running Tests
|
|
76
|
+
|
|
77
|
+
To run the test suite:
|
|
78
|
+
|
|
79
|
+
``` shell
|
|
80
|
+
bundle exec sus
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Making Releases
|
|
84
|
+
|
|
85
|
+
To make a new release:
|
|
86
|
+
|
|
87
|
+
``` shell
|
|
88
|
+
bundle exec bake gem:release:patch # or minor or major
|
|
89
|
+
```
|
|
90
|
+
|
|
75
91
|
### Developer Certificate of Origin
|
|
76
92
|
|
|
77
93
|
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: async-grpc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -53,33 +53,33 @@ dependencies:
|
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: protocol-
|
|
56
|
+
name: protocol-grpc
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: 0.11.0
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
68
|
+
version: 0.11.0
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: protocol-
|
|
70
|
+
name: protocol-http
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.
|
|
75
|
+
version: '0.60'
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.
|
|
82
|
+
version: '0.60'
|
|
83
83
|
executables: []
|
|
84
84
|
extensions: []
|
|
85
85
|
extra_rdoc_files: []
|
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
118
118
|
- !ruby/object:Gem::Version
|
|
119
119
|
version: '0'
|
|
120
120
|
requirements: []
|
|
121
|
-
rubygems_version: 4.0.
|
|
121
|
+
rubygems_version: 4.0.10
|
|
122
122
|
specification_version: 4
|
|
123
123
|
summary: Client and server implementation for gRPC using Async.
|
|
124
124
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|