PubsubGrpc.Client (PubsubGrpc v0.4.2)
View SourceClient module for interacting with Google Cloud Pub/Sub using gRPC connections.
This module provides a wrapper around GrpcConnectionPool that automatically
uses the default connection pool configured for Pub/Sub.
For most use cases, use the main PubsubGrpc module instead, as it provides
a higher-level API for common operations.
Examples
operation = fn channel ->
request = %Google.Pubsub.V1.GetTopicRequest{topic: "projects/my-project/topics/my-topic"}
Google.Pubsub.V1.Publisher.Stub.get_topic(channel, request, [])
end
{:ok, {:ok, topic}} = PubsubGrpc.Client.execute(operation)
Summary
Functions
Execute a gRPC operation using a connection from the pool.
Gets the status of the connection pool.
Execute a function with a connection from the pool.
Functions
@spec execute( (GRPC.Channel.t() -> term()), keyword() ) :: {:ok, term()} | {:error, term()}
Execute a gRPC operation using a connection from the pool.
Parameters
operation_fn: A 1-arity function that receives a gRPC channel and returns a resultopts: Optional parameters:pool- Pool name to use (default:PubsubGrpc.ConnectionPool)
Returns
{:ok, result}- Result from the operation function{:error, reason}- Error during connection checkout
Examples
operation = fn channel ->
request = %Google.Pubsub.V1.Topic{name: "projects/my-project/topics/test"}
Google.Pubsub.V1.Publisher.Stub.create_topic(channel, request, [])
end
{:ok, {:ok, topic}} = PubsubGrpc.Client.execute(operation)
Gets the status of the connection pool.
Parameters
opts: Optional parameters:pool- Pool name to check (default:PubsubGrpc.ConnectionPool)
Returns
- Pool status map with worker counts and statistics
@spec with_connection( (GRPC.Channel.t() -> term()), keyword() ) :: {:ok, term()} | {:error, term()}
Execute a function with a connection from the pool.
Alias for execute/2.