Skip to content

Quick start

This runs a single gateway with Docker, keeps its data on local disk, and connects a client to it without credentials. It takes a few minutes. Use it to try the API, not for production: a production cluster runs in two zones on GKE with Cloud SQL and Cloud Storage (Install).

  • Docker.
  • The lowtide container image. During the preview, you receive the image name with your invitation. The examples write it as IMAGE_REPOSITORY:VERSION.
  • A Pub/Sub client: a client library, gcloud or curl.
Terminal window
docker run --rm --name lowtide -p 8085:8085 -p 9090:9090 \
IMAGE_REPOSITORY:VERSION \
--blob-url file:///var/lib/lowtide/segments

The gateway serves the Pub/Sub API, gRPC and REST, on port 8085. Port 9090 serves /metrics, /healthz and /readyz. Without --meta-url, metadata is kept in memory, so it is lost when the container stops.

Check that it is ready:

Terminal window
curl localhost:9090/readyz

The client libraries connect to an emulator when PUBSUB_EMULATOR_HOST is set. lowtide answers on the same protocol, so no code change is needed:

Terminal window
PUBSUB_EMULATOR_HOST=localhost:8085 python my_service.py

In this mode the libraries send no credentials. That is fine here because authentication is off. On a real cluster, clients use the TLS endpoint instead (Client libraries).

The REST API is on the same port. Create a topic and a subscription, publish, and pull:

Terminal window
curl -X PUT localhost:8085/v1/projects/my-project/topics/orders \
-H 'content-type: application/json' -d '{}'
curl -X PUT localhost:8085/v1/projects/my-project/subscriptions/orders-worker \
-H 'content-type: application/json' \
-d '{"topic": "projects/my-project/topics/orders"}'
curl -X POST localhost:8085/v1/projects/my-project/topics/orders:publish \
-H 'content-type: application/json' \
-d '{"messages": [{"data": "aGVsbG8=", "attributes": {"kind": "test"}}]}'
curl -X POST localhost:8085/v1/projects/my-project/subscriptions/orders-worker:pull \
-H 'content-type: application/json' -d '{"maxMessages": 10}'

Project names are not checked against GCP while authentication is off, so any project ID works.

Terminal window
gcloud config set api_endpoint_overrides/pubsub http://localhost:8085/
gcloud config set auth/disable_credentials true
gcloud pubsub topics create payments --project=my-project

Undo both settings when you are done, or gcloud keeps sending Pub/Sub commands to your laptop:

Terminal window
gcloud config unset api_endpoint_overrides/pubsub
gcloud config unset auth/disable_credentials