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).
Before you start
Section titled “Before you start”- 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.
1. Start a gateway
Section titled “1. Start a gateway”docker run --rm --name lowtide -p 8085:8085 -p 9090:9090 \ IMAGE_REPOSITORY:VERSION \ --blob-url file:///var/lib/lowtide/segmentsThe 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:
curl localhost:9090/readyz2. Point a client at it
Section titled “2. Point a client at it”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:
PUBSUB_EMULATOR_HOST=localhost:8085 python my_service.pyIn 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).
3. Or use curl
Section titled “3. Or use curl”The REST API is on the same port. Create a topic and a subscription, publish, and pull:
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.
4. Or use gcloud
Section titled “4. Or use gcloud”gcloud config set api_endpoint_overrides/pubsub http://localhost:8085/gcloud config set auth/disable_credentials truegcloud pubsub topics create payments --project=my-projectUndo both settings when you are done, or gcloud keeps sending Pub/Sub commands to your laptop:
gcloud config unset api_endpoint_overrides/pubsubgcloud config unset auth/disable_credentialsNext steps
Section titled “Next steps”- Learn the terms these docs use: Concepts.
- Install a cluster in your project: Choose how to install.
- See every gateway setting: Gateway flags.