Tool to better test Google Pub/Sub calls and messages while using the gcloud emulator locally
- Start the emulator (google's docs)
gcloud beta emulators pubsub start --project=YOUR_PUBSUB_PROJECTID
- Set the environment variable with the Pub/Sub emulator address
export PUBSUB_EMULATOR_HOST=localhost:8085
- Run the toolkit
go run main.go YOUR_PUBSUB_PROJECTID
newtopic <topic-id>
creates a new topic with name 'topic-id'publish <topic-id> <data> <attributes>
publishes ontopic-id
the messagedata
with attributesattributes
. This is mostly hardcoded, but you can change the message easily in the code itselfshowtopics
lists all the topics in the active projectshowsubs
lists all the subscriptions in the active projectexit
gracefully exits the program, even if CTRL + C has no side effects.