PubSubClient class¶
fastpubsub.clients.pubsub.PubSubClient
¶
A client for interacting with Google Cloud Pub/Sub.
Initializes the PubSubClient.
| PARAMETER | DESCRIPTION |
|---|---|
project_id
|
The Google Cloud project ID.
TYPE:
|
Source code in fastpubsub/clients/pubsub.py
is_emulator
instance-attribute
¶
is_emulator = (
True if getenv("PUBSUB_EMULATOR_HOST") else False
)
create_subscription
async
¶
create_subscription(
topic_name,
subscription_name,
retry_policy,
delivery_policy,
dead_letter_policy=None,
)
Creates a subscription.
| PARAMETER | DESCRIPTION |
|---|---|
topic_name
|
The name of the topic.
TYPE:
|
subscription_name
|
The name of the subscription.
TYPE:
|
retry_policy
|
The retry policy for the subscription.
TYPE:
|
delivery_policy
|
The delivery policy for the subscription.
TYPE:
|
dead_letter_policy
|
The dead-letter policy for the subscription.
TYPE:
|
Source code in fastpubsub/clients/pubsub.py
update_subscription
async
¶
update_subscription(
topic_name,
subscription_name,
retry_policy,
delivery_policy,
dead_letter_policy=None,
)
Updates a subscription.
| PARAMETER | DESCRIPTION |
|---|---|
topic_name
|
The name of the topic.
TYPE:
|
subscription_name
|
The name of the subscription.
TYPE:
|
retry_policy
|
The retry policy for the subscription.
TYPE:
|
delivery_policy
|
The delivery policy for the subscription.
TYPE:
|
dead_letter_policy
|
The dead-letter policy for the subscription.
TYPE:
|
Source code in fastpubsub/clients/pubsub.py
create_topic
async
¶
Creates a topic.
| PARAMETER | DESCRIPTION |
|---|---|
topic_name
|
The name of the topic.
TYPE:
|
create_default_subscription
|
Whether to create a default subscription for the topic.
TYPE:
|
Source code in fastpubsub/clients/pubsub.py
publish
async
¶
Publishes a message.
| PARAMETER | DESCRIPTION |
|---|---|
topic_name
|
The name of the topic.
TYPE:
|
data
|
The message data.
TYPE:
|
ordering_key
|
The ordering key for the message.
TYPE:
|
attributes
|
A dictionary of message attributes. |
Source code in fastpubsub/clients/pubsub.py
subscribe
async
¶
Starts the subscription listening on background.
| PARAMETER | DESCRIPTION |
|---|---|
callback
|
The function called when a message is received. |
subscription_name
|
The name of the subscription.
TYPE:
|
max_messages
|
The maximum number of messages to pull.
TYPE:
|
scheduler
|
The object that allocates messages to callbacks.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
StreamingPullFuture
|
A future that can be used to check the progress and get the result. |