Class SubscriberClient (0.5.0)

SubscriberClient(
    executor: Optional[concurrent.futures.thread.ThreadPoolExecutor] = None,
    nack_handler: Optional[
        google.cloud.pubsublite.cloudpubsub.nack_handler.NackHandler
    ] = None,
    message_transformer: Optional[
        google.cloud.pubsublite.cloudpubsub.message_transformer.MessageTransformer
    ] = None,
    credentials: Optional[google.auth.credentials.Credentials] = None,
    transport: str = "grpc_asyncio",
    client_options: Optional[google.api_core.client_options.ClientOptions] = None,
)

A SubscriberClient reads messages similar to Google Pub/Sub. Any subscribe failures are unlikely to succeed if retried.

Must be used in a with block or have enter() called before use.

Methods

SubscriberClient

SubscriberClient(
    executor: Optional[concurrent.futures.thread.ThreadPoolExecutor] = None,
    nack_handler: Optional[
        google.cloud.pubsublite.cloudpubsub.nack_handler.NackHandler
    ] = None,
    message_transformer: Optional[
        google.cloud.pubsublite.cloudpubsub.message_transformer.MessageTransformer
    ] = None,
    credentials: Optional[google.auth.credentials.Credentials] = None,
    transport: str = "grpc_asyncio",
    client_options: Optional[google.api_core.client_options.ClientOptions] = None,
)

Create a new SubscriberClient.

__enter__

__enter__()

Return self upon entering the runtime context.

__exit__

__exit__(exc_type, exc_value, traceback)

Raise any exception triggered within the runtime context.

subscribe

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

This method starts a background thread to begin pulling messages from a Pub/Sub Lite subscription and scheduling them to be processed using the provided callback.

Exceptions
TypeDescription
GoogleApiCallErrorOn a permanent failure.