grpc-ruby compatible client interfaces backed by async-grpc and async-http.
The gem is intended for generated clients which currently construct a GRPC::ClientStub, but need to make non-blocking calls inside an Async event loop. Connection reuse and HTTP/2 multiplexing remain the responsibility of async-http; this gem does not add a second connection pool.
The initial release still depends on grpc for its public credential and error types, but it does not use the native gRPC channel for requests.
Select the compatible stub when constructing a generated client:
require "async/grpc/compatible"
stub_class = Async::GRPC::Compatible::ClientStub
stub = stub_class.new("grpc.example.com:443", GRPC::Core::ChannelCredentials.new)
response = stub.request_response(
"/example.Service/Get",
request,
->(message){message.to_proto},
Example::Response.method(:decode),
metadata: {"authorization" => "Bearer token"}
)Applications such as NuevoProtobuf should accept the stub class explicitly rather than replacing the process-wide GRPC::ClientStub constant:
NuevoProtobuf::RPC.configure do |config|
config.client_stub_class = Async::GRPC::Compatible::ClientStub
endThat configuration API is illustrative and will require a corresponding NuevoProtobuf change.
The initial implementation supports:
- The grpc-ruby
GRPC::ClientStub.newparameter shape. - Unary
request_responsecalls. - Custom marshal and unmarshal callables.
- Request metadata and deadlines.
- Insecure and standard TLS endpoints.
- Translation of gRPC failures into
GRPC::BadStatussubclasses.
The following are not yet supported:
return_op: true.- Client, server, or bidirectional streaming.
- grpc-ruby interceptors.
- Parent call propagation and per-call credentials.
- Custom TLS root certificates, client certificates, and native channel overrides.
- grpc-ruby channel arguments beyond accepting the compatible constructor parameter.
- Non-DNS resolvers such as Unix sockets and xDS.
Run the test suite:
$ bundle exec susThe integration suite includes a unary client fixture generated by NuevoProtobuf 2.5.4 and exercises it against an in-process Async HTTP/2 server.
Please see the project releases for all releases.
Released under the MIT License.