nats

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: AGPL-3.0 Imports: 16 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 nats is the NATS JetStream engine of `komando queue`, through github.com/nats-io/nats.go. It registers itself with queuex for nats:// and tls:// conns. A queue here is a JetStream stream: ls lists streams, describe shows one with its consumers, peek reads messages by their sequence number (no consumer, nothing acknowledged, nothing removed), send publishes to a subject a stream keeps. 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, password string, dial queuex.DialFunc, timeout time.Duration, clientID string) (queuex.Queue, error)

Open logs in to the conn's servers through dial (direct, --via an SSH server, or a VPN). nats.go adds TLS on top for tls:// (or when the server requires it), checked against the server's name.

Types

type Nats

type Nats struct {
	// contains filtered or unexported fields
}

Nats is a queuex.Queue on a NATS account with JetStream.

func (*Nats) Close

func (n *Nats) Close()

Close ends the connection.

func (*Nats) Create

func (n *Nats) Create(ctx context.Context, s queuex.TopicSpec, dryRun bool) (*queuex.Created, error)

Create makes a stream. The server cannot check a stream without making it, so a dry run checks the name is free and komando's reading of the settings, and makes nothing.

func (*Nats) Delete

func (n *Nats) Delete(ctx context.Context, streams []string, dryRun bool) ([]queuex.Deleted, error)

Delete deletes streams with their messages and consumers. Every name must exist; with dry run it only says what each holds.

func (*Nats) Describe

func (n *Nats) Describe(ctx context.Context, name string) (*queuex.TopicDetail, error)

Describe reads a stream's settings, state, copies and consumers.

func (*Nats) Groups

func (n *Nats) Groups(ctx context.Context) ([]queuex.Group, error)

Groups lists the consumers of every stream. Lag is what each has not been given yet (pending).

func (*Nats) Info

func (n *Nats) Info(ctx context.Context) (*queuex.Info, error)

Info is the server komando talks to and its account's JetStream use. A server or account without JetStream still answers, with jetstream false.

func (*Nats) Lag

func (n *Nats) Lag(ctx context.Context, group string) (*queuex.GroupLag, error)

Lag is one consumer, named STREAM/CONSUMER or by its name alone when only one stream has a consumer of that name.

func (*Nats) Peek

Peek reads messages straight from the stream by their sequence number, the way `nats stream get` does: no consumer is made, nothing is acknowledged and nothing is removed, also on a work-queue stream. By default the newest o.Limit, with o.Oldest the first ones still kept.

func (*Nats) Purge

func (n *Nats) Purge(ctx context.Context, stream string, dryRun bool) (*queuex.Purged, error)

Purge deletes every message of a stream; the stream and its consumers stay.

func (*Nats) Send

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

Send publishes one message to a subject and waits for the stream's acknowledgement. A stream must keep that subject: komando looks it up first, so a message never goes to a subject no stream keeps (core NATS would drop it without a word).

func (*Nats) Topics

func (n *Nats) Topics(ctx context.Context, pattern string, internal bool, limit int) ([]queuex.Topic, error)

Topics lists the streams whose name matches pattern. Key-value buckets (KV_NAME) and object stores (OBJ_NAME) are streams too, and are listed.

Jump to

Keyboard shortcuts

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