Skip to main content

Overview

Publish processed pipeline data to Google Cloud Pub/Sub topics for fan-out to downstream consumers, event-driven architectures, and decoupled integrations. Each row emitted by the upstream transform is serialized as a JSON object and delivered as the body of a single Pub/Sub message.
The Pub/Sub sink is only available on Turbo pipelines.

Configuration

Parameters

string
required
Must be pubsub.
string
required
The transform or source to read data from.
string
required
The Pub/Sub topic to publish to. The topic must already exist in the GCP project referenced by the secret β€” the sink does not create topics. Specify the short topic id (for example my-topic), not the fully-qualified projects/.../topics/... name.
string
required
Name of the Goldsky secret (type pubsub) containing the GCP project id and service-account credentials. See Secret format below.
number
Maximum number of messages to batch before publishing.
string
Maximum time to wait before flushing a batch. Accepts humantime durations such as 100ms, 1s, or 500ms.
string
Optional human-readable description for the sink.

Secret format

Create a Pub/Sub secret with the Goldsky CLI. You will be prompted for the GCP project id and the contents of a service-account JSON key file:
The resulting secret has the following structure:
  • projectId: the GCP project that owns the destination topic (for example goldsky-prod).
  • credentialsJson: the raw contents of a GCP service-account JSON key file, on a single line. The CLI validates that the value parses as JSON and that type is service_account.

IAM permissions

The service account referenced by credentialsJson must have the following IAM roles in the destination project:
  • roles/pubsub.publisher β€” required to publish messages to the topic.
  • roles/pubsub.viewer β€” required for the sink’s topic-existence pre-check that runs during pipeline initialization.
You can also grant equivalent custom roles that include pubsub.topics.publish and pubsub.topics.get.

Message format

Each row emitted by the upstream transform becomes the data payload of a single Pub/Sub message, serialized as a JSON object. For example, a row with columns id, from, and value is delivered as:

Example

Stream high-value ERC-20 transfers to a Pub/Sub topic for downstream fan-out:

Best practices

The sink performs a topic-existence check during initialization and will fail to start if the topic does not exist. Create the topic in advance with gcloud pubsub topics create my-topic or via Terraform.
Grant the service account roles/pubsub.publisher and roles/pubsub.viewer only on the specific topic (or the project that contains it) β€” not on the whole organization. Rotate the JSON key periodically.
Pub/Sub rejects messages larger than 10 MB. Use an upstream SQL transform to drop or truncate large columns if your row payloads approach this limit.
Pub/Sub fans out to subscriptions, not directly to subscribers. Create one subscription per downstream consumer so they receive independent copies of the stream.