scanner

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package scanner walks JetStream streams and consumers and classifies them.

A consumer is classified as:

ACTIVE — push-bound, has pull waiters, or its last delivery is within
         Options.MinIdle.
STALE  — exists but is past Options.MinIdle and exceeds Options.MinPending.
OK     — exists and is healthy but does not meet the reporting thresholds.
ABSENT — only used in PeerStatus; consumer does not exist on the peer.
ERR    — could not be queried.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Stream     string
	MinPending int64
	MinIdle    time.Duration
}

type Row

type Row struct {
	Cluster    string        `json:"cluster"`
	Stream     string        `json:"stream"`
	Consumer   string        `json:"consumer"`
	Status     Status        `json:"status"`
	NumPending int64         `json:"num_pending"`
	NumWaiting int           `json:"num_waiting"`
	PushBound  bool          `json:"push_bound"`
	LastAck    time.Time     `json:"last_ack,omitzero"`
	Idle       time.Duration `json:"idle"`
	PeerStatus Status        `json:"peer_status,omitempty"`
}

func Scan

func Scan(ctx context.Context, nc, peer *natsctx.Conn, opts Options) ([]Row, error)

Scan enumerates streams and consumers on nc, classifies them per opts, and (if peer is non-nil) annotates each row with the peer-cluster status of the same (stream, consumer) pair.

type Status

type Status string
const (
	StatusActive Status = "ACTIVE"
	StatusStale  Status = "STALE"
	StatusOK     Status = "OK"
	StatusAbsent Status = "ABSENT"
	StatusError  Status = "ERR"
)

Jump to

Keyboard shortcuts

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