cleanup

package
v0.3.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: 7 Imported by: 0

Documentation

Overview

Package cleanup applies a manifest against live NATS clusters.

Apply is the operationally important function. It is shared by the `natsie consumer apply` CLI and the bot's signed-approval HTTP handler, so both code paths run the same re-verification and deletion logic.

Two safety properties are baked in:

  1. Re-verification: each entry's current state is re-queried before deletion. Anything that has become active (push-bound, has pull waiters, or has acked since the manifest's GeneratedAt) is preserved untouched.

  2. Per-entry deletes via the raw `$JS.API.CONSUMER.DELETE` subject, so consumer names starting with `-` (which the nats CLI rejects as flags) are handled the same way as any other name.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action is the verdict for one manifest entry.

const (
	ActionDeleted  Action = "DELETED"
	ActionWould    Action = "WOULD"
	ActionGone     Action = "GONE"
	ActionSkip     Action = "SKIP"
	ActionActive   Action = "ACTIVE"
	ActionFailed   Action = "FAIL"
	ActionConnFail Action = "CONN"
)

type Connector

type Connector func(cluster string) (conn *nats.Conn, release func(), err error)

Connector returns a NATS connection for the named cluster, along with a function the caller invokes to release it. The CLI passes natsctx.Connect-backed connectors; tests can pass an in-memory fake.

type Event

type Event struct {
	Cluster  string
	Stream   string
	Consumer string
	Action   Action
	Detail   string
}

Event records what happened to a single entry.

type Result

type Result struct {
	Deleted   int
	Skipped   int
	Preserved int
	Gone      int
	Failed    int
	Events    []Event
}

Result is the outcome of an Apply call.

func Apply

func Apply(ctx context.Context, m *manifest.Manifest, dryRun bool, connect Connector) (*Result, error)

Apply groups the manifest entries by cluster, dials each cluster once via the Connector, and runs the re-verification + deletion loop. DryRun reports actions without sending delete requests.

func (*Result) Summary

func (r *Result) Summary() string

Summary returns a one-line, log-friendly tally.

Jump to

Keyboard shortcuts

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