launchflow.gcp.pubsub
PubsubTopic
1class PubsubTopic(GCPResource[PubsubTopicConnectionInfo])
A GCP Cloud Pub/Sub Topic.
Example usage:
1import launchflow as lf
2
3# Automatically configures / deploys a PubSub Topic in your GCP project
4topic = lf.gcp.PubsubTopic("my-pubsub-topic")
5
6topic.publish(b"Hello, world!")
publish
1def publish(data: bytes, ordering_key: str = "")
Publish a message to the topic.
Args:
data
: The bytes to publish in the messageordering_key
: An optional ordering key for the message
Example usage:
1import launchflow as lf
2
3topic = lf.gcp.PubsubTopic("my-pubsub-topic")
4
5topic.publish(b"Hello, world!")
publish_async
1async def publish_async(data: bytes, ordering_key: str = "")
Asynchronously publish a message to the topic.
Args:
data
: The bytes to publish in the messageordering_key
: An optional ordering key for the message
Example usage:
1import launchflow as lf
2
3topic = lf.gcp.PubsubTopic("my-pubsub-topic")
4
5await topic.publish_async(b"Hello, world!")
PubsubSubscription
1class PubsubSubscription(GCPResource[PubsubSubscriptionConnectionInfo])
A GCP Cloud Pub/Sub Topic.
Example usage:
1import launchflow as lf
2
3topic = lf.gcp.PubsubTopic("my-pubsub-topic")
4subscription = lf.gcp.PubsubSubscription("my-pubsub-sub", topic=topic)
5
6topic.publish(b"Hello, world!")