cmd

package
v0.0.0-...-e560ebb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdPublish = &subcommands.Command{
	UsageLine: "publish -project [PROJECT] -topic [TOPIC] [OPTIONS]",
	ShortDesc: "publish a message to a topic",
	CommandRun: func() subcommands.CommandRun {
		c := &publishRun{}
		c.registerCommonFlags(&c.Flags)
		c.Flags.StringVar(&c.messageFile, "file", "", "path to file to send as message")
		c.Flags.Var(flag.JSONMap(&c.attributes), "attributes", "map of attributes to add to the message")
		return c
	},
}

CmdPublish describes the subcommand flags for publishing messages

View Source
var CmdSetup = &subcommands.Command{
	UsageLine: "setup -project [PROJECT] -topic [TOPIC] -name [NAME]",
	ShortDesc: "set up a subscription",
	CommandRun: func() subcommands.CommandRun {
		c := &setupRun{}
		c.registerCommonFlags(&c.Flags)
		c.Flags.StringVar(&c.name, "name", "", "name of subscription: must be 3-255 characters, start with a letter, and composed of alphanumerics and -_.~+% only")
		return c
	},
}

CmdSetup describes the subcommand flags for setting up a subscription

View Source
var CmdSubscribe = &subcommands.Command{
	UsageLine: "subscribe -project [PROJECT] -topic [TOPIC] -output [PATH/TO/OUTPUT/DIR] [OPTIONS]",
	ShortDesc: "subscribe to a filtered topic",
	CommandRun: func() subcommands.CommandRun {
		c := &subscribeRun{}
		c.registerCommonFlags(&c.Flags)
		c.Flags.Var(flag.JSONMap(&c.attributes), "attributes", "map of attributes to filter for")
		c.Flags.IntVar(&c.messageCount, "count", 1, "number of messages to read before returning")
		c.Flags.StringVar(&c.outputDir, "output", "", "path to directory to store output")
		c.Flags.StringVar(&c.subName, "sub-name", "", "name of subscription: must be 3-255 characters, start with a letter, and composed of alphanumerics and -_.~+% only")
		c.Flags.DurationVar(&c.timeout, "timeout", time.Hour, "timeout to stop waiting, ex. 10s, 5m, 1h30m")
		return c
	},
}

CmdSubscribe describes the subcommand flags for subscribing to messages.

Functions

func Publish

func Publish(ctx context.Context, topic *pubsub.Topic, msg []byte, attrs map[string]string) error

Publish publishes a bytestream message to a topic with specified attributes

func ReadMessages

func ReadMessages(ctx context.Context, subscription *pubsub.Subscription, msgCount int, filter map[string]string) ([][]byte, error)

ReadMessages pulls messages from a Cloud Pub/Sub subscription.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL