Documentation
¶
Overview ¶
Package pubsub is the Google Cloud Pub/Sub engine of `komando queue`. It speaks the Pub/Sub REST API (v1) itself over komando's own HTTP dial, so --via and VPNs work and no Google SDK is needed. The login is the one komando uses for gs:// storage: a service account key from the conn's password reference, or else gcloud's application default credentials; the emulator needs none. It registers itself with queuex for pubsub:// conns. Pub/Sub keeps messages in subscriptions: peek pulls from one and gives every message back unacknowledged. See docs/features/queues.md.
Index ¶
- func Open(ctx context.Context, t driver.Target, key string, dial queuex.DialFunc, ...) (queuex.Queue, error)
- type Pubsub
- func (p *Pubsub) Close()
- func (p *Pubsub) Create(ctx context.Context, sp queuex.TopicSpec, dryRun bool) (*queuex.Created, error)
- func (p *Pubsub) Delete(ctx context.Context, names []string, dryRun bool) ([]queuex.Deleted, error)
- func (p *Pubsub) Describe(ctx context.Context, name string) (*queuex.TopicDetail, error)
- func (p *Pubsub) Groups(ctx context.Context) ([]queuex.Group, error)
- func (p *Pubsub) Info(ctx context.Context) (*queuex.Info, error)
- func (p *Pubsub) Lag(context.Context, string) (*queuex.GroupLag, error)
- func (p *Pubsub) Peek(ctx context.Context, o queuex.PeekOptions) (*queuex.PeekResult, error)
- func (p *Pubsub) Purge(ctx context.Context, name string, dryRun bool) (*queuex.Purged, error)
- func (p *Pubsub) Send(ctx context.Context, m queuex.Message, dryRun bool) (*queuex.Sent, error)
- func (p *Pubsub) Topics(ctx context.Context, pattern string, internal bool, limit int) ([]queuex.Topic, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
func Open(ctx context.Context, t driver.Target, key string, dial queuex.DialFunc, timeout time.Duration, clientID string) (queuex.Queue, error)
Open connects through dial (direct, --via an SSH server, or a VPN) and checks that Pub/Sub answers and takes the login. key is a service account key (JSON) from the conn's password reference, or "".
Types ¶
type Pubsub ¶
type Pubsub struct {
// contains filtered or unexported fields
}
Pubsub is a queuex.Queue on one Google Cloud project.
func (*Pubsub) Create ¶
func (p *Pubsub) Create(ctx context.Context, sp queuex.TopicSpec, dryRun bool) (*queuex.Created, error)
Create makes a topic, or a subscription when the name is subscriptions/NAME or --config names its topic (topic=NAME). Pub/Sub cannot check a resource without making it, so a dry run checks the names and settings and makes nothing.
func (*Pubsub) Delete ¶
Delete deletes topics, or subscriptions written subscriptions/NAME. Every name must exist; with dry run it only says what each is. Deleting a topic leaves its subscriptions and their messages: they are cut off (their topic becomes _deleted-topic_). Deleting a subscription deletes the messages it held. Pub/Sub does not count them, so messages is -1.
func (*Pubsub) Describe ¶
Describe shows a topic (its settings and its subscriptions) or a subscription. A bare name is a topic first; when there is no topic of that name, a subscription.
func (*Pubsub) Groups ¶
Groups lists the subscriptions: in Pub/Sub, each subscription gets every message of its topic, and the programs that pull from it share them, like a Kafka consumer group. Pub/Sub does not say who pulls or how far behind they are, so members is 0 and lag -1.
func (*Pubsub) Info ¶
Info is the project at a glance: where komando talks to, and how many topics and subscriptions it has.
func (*Pubsub) Peek ¶
func (p *Pubsub) Peek(ctx context.Context, o queuex.PeekOptions) (*queuex.PeekResult, error)
Peek pulls up to o.Limit messages from a subscription and gives every one back unacknowledged (its ack deadline set to 0), so Pub/Sub keeps them all and delivers them again at once. While peek runs (a few seconds) the messages it holds are not given to other subscribers; if komando stops before giving them back, Pub/Sub gives them out again after the subscription's ack deadline. Pulls return at once and never wait for new messages, so nothing is taken after peek is done.
With a dead-letter topic every delivery counts, and after maxDeliveryAttempts Pub/Sub moves the message there, so peek stops with DELIVERY_LIMIT_NEAR once a message it showed has fewer than keepDeliveries left.
func (*Pubsub) Purge ¶
Purge empties a subscription and keeps it: a seek to now, which marks every message published before now as acknowledged, also those a subscriber pulled and has not acknowledged yet. Other subscriptions of the topic keep theirs. Pub/Sub does not count them, so messages is -1.
func (*Pubsub) Send ¶
Send publishes one message to a topic. Headers become the message's attributes; --key is its ordering key (a subscription with ordering gives messages of one key in order).
func (*Pubsub) Topics ¶
func (p *Pubsub) Topics(ctx context.Context, pattern string, internal bool, limit int) ([]queuex.Topic, error)
Topics lists the topics whose name matches pattern (shell style: orders-*), with how many subscriptions each has. Pub/Sub does not count messages, so messages is -1.