Class AsyncPublisherClient (1.10.0)

AsyncPublisherClient(
    *,
    per_partition_batching_settings: typing.Optional[
        google.cloud.pubsub_v1.types.BatchSettings
    ] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
    transport: str = "grpc_asyncio",
    client_options: typing.Optional[
        google.api_core.client_options.ClientOptions
    ] = None,
    enable_idempotence: bool = False
)

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

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

Methods

AsyncPublisherClient

AsyncPublisherClient(
    *,
    per_partition_batching_settings: typing.Optional[
        google.cloud.pubsub_v1.types.BatchSettings
    ] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
    transport: str = "grpc_asyncio",
    client_options: typing.Optional[
        google.api_core.client_options.ClientOptions
    ] = None,
    enable_idempotence: bool = False
)

Create a new AsyncPublisherClient.

__aenter__

__aenter__()

Return self upon entering the runtime context.

__aexit__

__aexit__(exc_type, exc_value, traceback)

Raise any exception triggered within the runtime context.

publish

publish(
    topic: typing.Union[google.cloud.pubsublite.types.paths.TopicPath, str],
    data: bytes,
    ordering_key: str = "",
    **attrs: typing.Mapping[str, str]
) -> str

Publish a message.

Parameters
Name Description
topic typing.Union[google.cloud.pubsublite.types.paths.TopicPath, str]

The topic to publish to. Publishes to new topics may have nontrivial startup latency.

data bytes

The bytestring payload of the message

ordering_key str

The key to enforce ordering on, or "" for no ordering.

Exceptions
Type Description
GoogleApiCallError On a permanent failure.