It's a simple pubsub implementation in Go for interacting with the GCP PubSub Emulator.
The standard gcloud pubsub
command doesn't support using the emulator.
The simplest and only way to install at the moment is to use go install
... other ways will be added shortly.
go install github.com/owenrumney/pubsub/cmd/pubsub@latest
To get the top level help, use
pubsub --help
pubsub help
Usage:
pubsub [command]
Available Commands:
help Help about any command
subscriptions List create and delete subscriptions
topics List create and delete topics
Flags:
-d, --debug Enable debug logging
-h, --help help for pubsub
-p, --project string GCP project ID (default "test-project")
-t, --topic-name string Topic name
Use "pubsub [command] --help" for more information about a command.
All commands require a project ID to be set using -p
or --project
. If this isn't done, the default test-project
is used. Optionally, you can set the PROJECT_ID
environment variable to save you the keystrokes.
To get help on topics, use
pubsub topics --help
List create and delete topics
Usage:
pubsub topics [command]
Available Commands:
create Create a topic
delete Delete a topic
list List topics
tail Tail a topic
Flags:
-h, --help help for topics
Global Flags:
-d, --debug Enable debug logging
-p, --project string GCP project ID (default "test-project")
-t, --topic-name string Topic name
Use "pubsub topics [command] --help" for more information about a command.
pubsub topics -p my-test-project list
pubsub topics create -p my-test-project -t my-topic
pubsub topics delete -p my-test-project -t my-topic
Default tail is for 10 minutes, this can be changed with the --tail-duration
flag; use the format 10s
for 10 seconds, 5m
for 5 minutes, 1h
for 1 hour, etc.
pubsub topics tail -p my-test-project -t my-topic --tail-duration 5m
To get help on subscriptions, use
pubsub subscriptions --help
List create and delete subscriptions
Usage:
pubsub subscriptions [command]
Available Commands:
create Create a subscription
delete Delete a subscription
list List subscriptions
Flags:
-h, --help help for subscriptions
Global Flags:
-d, --debug Enable debug logging
-p, --project string GCP project ID (default "test-project")
-t, --topic-name string Topic name
Use "pubsub subscriptions [command] --help" for more information about a command.
pubsub subscriptions -p my-test-project list
pubsub subscriptions create -p my-test-project -t my-topic -s my-subscription
When creating a subscription, you can optionally create push endpoint using the -e
or --push-endpoint
flag.
pubsub subscriptions delete -p my-test-project -s my-subscription