launchflow.gcp.pubsub

PubsubTopic

1
class PubsubTopic(GCPResource[PubsubTopicConnectionInfo])

A GCP Cloud Pub/Sub Topic.

Example usage:

1
import launchflow as lf
2
3
# Automatically configures / deploys a PubSub Topic in your GCP project
4
topic = lf.gcp.PubsubTopic("my-pubsub-topic")
5
6
topic.publish(b"Hello, world!")

publish

1
def publish(data: bytes, ordering_key: str = "")

Publish a message to the topic.

Args:

  • data: The bytes to publish in the message
  • ordering_key: An optional ordering key for the message

Example usage:

1
import launchflow as lf
2
3
topic = lf.gcp.PubsubTopic("my-pubsub-topic")
4
5
topic.publish(b"Hello, world!")

publish_async

1
async def publish_async(data: bytes, ordering_key: str = "")

Asynchronously publish a message to the topic.

Args:

  • data: The bytes to publish in the message
  • ordering_key: An optional ordering key for the message

Example usage:

1
import launchflow as lf
2
3
topic = lf.gcp.PubsubTopic("my-pubsub-topic")
4
5
await topic.publish_async(b"Hello, world!")

PubsubSubscription

1
class PubsubSubscription(GCPResource[PubsubSubscriptionConnectionInfo])

A GCP Cloud Pub/Sub Topic.

Example usage:

1
import launchflow as lf
2
3
topic = lf.gcp.PubsubTopic("my-pubsub-topic")
4
subscription = lf.gcp.PubsubSubscription("my-pubsub-sub", topic=topic)
5
6
topic.publish(b"Hello, world!")