Skip to content

GCP Pub/Sub Triggers

Once available, Orvanta will be able to connect to Google Cloud Pub/Sub and trigger a script or flow in response to messages published on a topic, either by pulling from a subscription or by receiving pushed messages on an auto-generated endpoint — the same shape as the other queue-backed triggers (Kafka, NATS, MQTT, SQS).

For reference, a GCP-triggered preprocessor would receive an event shaped like this:

export async function preprocessor(
event: {
kind: 'gcp',
payload: string, // base64 encoded payload
message_id: string,
subscription: string,
ordering_key?: string,
attributes?: Record<string, string>,
delivery_type: "push" | "pull",
headers?: Record<string, string>,
publish_time?: string,
}
) {
if (event.kind !== 'gcp') {
throw new Error(`Expected a GCP trigger kind, got: ${event.kind}`);
}
const decodedString = atob(event.payload);
return {
messageAsDecodedString: decodedString,
attributes: event.attributes ?? {},
};
}
  • payload: The Pub/Sub message, base64-encoded.
  • message_id: Unique message ID assigned by Pub/Sub.
  • subscription: The subscription ID that delivered the message.
  • delivery_type: "push" or "pull".
  • attributes: User-defined key-value metadata attached to the message.

See Preprocessors for how a preprocessor’s return value maps onto a script’s main() parameters.