pubsub

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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) Close

func (p *Pubsub) Close()

Close ends the idle connections.

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

func (p *Pubsub) Delete(ctx context.Context, names []string, dryRun bool) ([]queuex.Deleted, error)

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

func (p *Pubsub) Describe(ctx context.Context, name string) (*queuex.TopicDetail, error)

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

func (p *Pubsub) Groups(ctx context.Context) ([]queuex.Group, error)

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

func (p *Pubsub) Info(ctx context.Context) (*queuex.Info, error)

Info is the project at a glance: where komando talks to, and how many topics and subscriptions it has.

func (*Pubsub) Lag

Lag: Pub/Sub's API does not count a subscription's backlog.

func (*Pubsub) Peek

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

func (p *Pubsub) Purge(ctx context.Context, name string, dryRun bool) (*queuex.Purged, error)

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

func (p *Pubsub) Send(ctx context.Context, m queuex.Message, dryRun bool) (*queuex.Sent, error)

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.

Jump to

Keyboard shortcuts

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