Skip to content

Repository files navigation

Async::GRPC::Compatible

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.

Usage

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
end

That configuration API is illustrative and will require a corresponding NuevoProtobuf change.

Current Compatibility

The initial implementation supports:

  • The grpc-ruby GRPC::ClientStub.new parameter shape.
  • Unary request_response calls.
  • Custom marshal and unmarshal callables.
  • Request metadata and deadlines.
  • Insecure and standard TLS endpoints.
  • Translation of gRPC failures into GRPC::BadStatus subclasses.

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.

Development

Run the test suite:

$ bundle exec sus

The integration suite includes a unary client fixture generated by NuevoProtobuf 2.5.4 and exercises it against an in-process Async HTTP/2 server.

Releases

Please see the project releases for all releases.

License

Released under the MIT License.

About

grpc-ruby compatible client interfaces using Async::GRPC.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages