Skip to content

Simple pubsub tool to work with GCP PubSub emulator

Notifications You must be signed in to change notification settings

owenrumney/pubsub

Repository files navigation

pubsub

What is it?

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.

How do I use it?

Install

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

Operation?

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.

Topics

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.
Listing Topics
pubsub topics -p my-test-project list
Creating Topics
pubsub topics create -p my-test-project -t my-topic
Deleting Topics
pubsub topics delete -p my-test-project -t my-topic
Tailing Topics

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

Subscriptions

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.
Listing Subscriptions
pubsub subscriptions -p my-test-project list
Creating Subscriptions
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.

Deleting Subscriptions
pubsub subscriptions delete -p my-test-project -s my-subscription

About

Simple pubsub tool to work with GCP PubSub emulator

Topics

Resources

Stars

Watchers

Forks

Languages