Google's Pub/Sub emulator, wired in.
Topics, subscriptions, publish, pull, StreamingPull and push, on Google's own emulator.
Backed by: Google's Pub/Sub emulator Google's emulator
Get startedWhat it covers
Pub/Sub runs on Google’s own emulator, integrated rather than reimplemented. PUBSUB_EMULATOR_HOST from cloudburrow env is all the official clients need. Its state is lost when the pod restarts, whatever --mode says.
- Topics and subscriptions
- Publish and pull
- StreamingPull
- Push delivery
- Schemas, snapshots and seek, with tested lifecycle calls
- Subscription expiration and exactly-once delivery, applied by CloudBurrow's front (#873, #880, #891)
- Schemas, topics, subscriptions and snapshots in
state saveandstate load; messages are not kept (#880) - IAM policies on topics, subscriptions, snapshots and schemas, stored without enforcement (#1367)
- Verified
gcloud pubsubtopics and subscriptions commands
In the console
Tested snippet
From docs/examples/ at main 0ea2594. CI runs these blocks against CloudBurrow.
import os, uuid
from google.cloud import pubsub_v1
project = os.environ["GOOGLE_CLOUD_PROJECT"]
publisher, subscriber = pubsub_v1.PublisherClient(), pubsub_v1.SubscriberClient()
topic = publisher.topic_path(project, f"example-{uuid.uuid4().hex[:12]}")
sub = subscriber.subscription_path(project, f"example-{uuid.uuid4().hex[:12]}")
publisher.create_topic(name=topic)
subscriber.create_subscription(name=sub, topic=topic)
publisher.publish(topic, b"hello").result(timeout=30)
messages = subscriber.pull(subscription=sub, max_messages=1, timeout=30).received_messages
assert messages[0].message.data == b"hello"
subscriber.acknowledge(subscription=sub, ack_ids=[messages[0].ack_id])
subscriber.delete_subscription(subscription=sub)
publisher.delete_topic(topic=topic)
This block is run by CloudBurrow's Python suite in CI. If it stops working, CI fails. docs/examples/python.md
import assert from 'node:assert/strict';
import { randomUUID } from 'node:crypto';
import { once } from 'node:events';
import { PubSub } from '@google-cloud/pubsub';
const pubsub = new PubSub({ projectId: process.env.GOOGLE_CLOUD_PROJECT });
const [topic] = await pubsub.createTopic(`example-${randomUUID()}`);
const [subscription] = await topic.createSubscription(`example-${randomUUID()}`);
await topic.publishMessage({ data: Buffer.from('hello') });
const [message] = await once(subscription, 'message', { signal: AbortSignal.timeout(30_000) });
assert.equal(message.data.toString(), 'hello');
message.ack();
await subscription.close();
await subscription.delete();
await topic.delete();
await pubsub.close();
This block is run by CloudBurrow's Node.js suite in CI. If it stops working, CI fails. docs/examples/node.md
What's verified
Follow the operation matrix to see what the backend serves and the tests linked to Verified calls.
Not supported
- 01 / Local boundary
State does not survive a restart of the pod or the instance, a limitation of Google's emulator, measured
- 02 / Local boundary
When the emulator's container crashes, CloudBurrow's front recreates topics, subscriptions, schemas and snapshots, but every message not yet acknowledged is lost. #1608
Source: docs/compatibility.md at main 0ea2594.
Questions
Does Pub/Sub keep its topics across a restart?
--data-dir, measured, not assumed. If only the emulator's container restarts, CloudBurrow's front creates the topics, subscriptions, schemas and snapshots again; unacknowledged messages are lost.Build against Google Cloud APIs, locally
Free and open source under Apache-2.0. No account, no sign-up, no Google Cloud bill.