Class AsyncSubscriberClient (1.11.0)

AsyncSubscriberClient(
    *,
    nack_handler: typing.Optional[
        google.cloud.pubsublite.cloudpubsub.nack_handler.NackHandler
    ] = None,
    reassignment_handler: typing.Optional[
        google.cloud.pubsublite.cloudpubsub.reassignment_handler.ReassignmentHandler
    ] = None,
    message_transformer: typing.Optional[
        google.cloud.pubsublite.cloudpubsub.message_transformer.MessageTransformer
    ] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
    transport: str = "grpc_asyncio",
    client_options: typing.Optional[google.api_core.client_options.ClientOptions] = None
)

An AsyncSubscriberClient reads messages similar to Google Pub/Sub, but must be used in an async context. Any subscribe failures are unlikely to succeed if retried.

Must be used in an async with block or have aenter() awaited before use.

Methods

AsyncSubscriberClient

AsyncSubscriberClient(
    *,
    nack_handler: typing.Optional[
        google.cloud.pubsublite.cloudpubsub.nack_handler.NackHandler
    ] = None,
    reassignment_handler: typing.Optional[
        google.cloud.pubsublite.cloudpubsub.reassignment_handler.ReassignmentHandler
    ] = None,
    message_transformer: typing.Optional[
        google.cloud.pubsublite.cloudpubsub.message_transformer.MessageTransformer
    ] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
    transport: str = "grpc_asyncio",
    client_options: typing.Optional[google.api_core.client_options.ClientOptions] = None
)

Create a new AsyncSubscriberClient.

__aenter__

__aenter__()

Return self upon entering the runtime context.

__aexit__

__aexit__(exc_type, exc_value, traceback)

Raise any exception triggered within the runtime context.

subscribe

subscribe(
    subscription: typing.Union[
        google.cloud.pubsublite.types.paths.SubscriptionPath, str
    ],
    per_partition_flow_control_settings: google.cloud.pubsublite.types.flow_control_settings.FlowControlSettings,
    fixed_partitions: typing.Optional[
        typing.Set[google.cloud.pubsublite.types.partition.Partition]
    ] = None,
) -> typing.AsyncIterator[google.cloud.pubsub_v1.subscriber.message.Message]

Read messages from a subscription.

Parameters
Name Description
subscription typing.Union[google.cloud.pubsublite.types.paths.SubscriptionPath, str]

The subscription to subscribe to.

per_partition_flow_control_settings FlowControlSettings

The flow control settings for each partition subscribed to. Note that these settings apply to each partition individually, not in aggregate.

fixed_partitions typing.Optional[typing.Set[google.cloud.pubsublite.types.partition.Partition]]

A fixed set of partitions to subscribe to. If not present, will instead use auto-assignment.

Exceptions
Type Description
GoogleApiCallError On a permanent failure.