names

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package names centralises every NATS resource name packtrail uses — streams, KV buckets, object stores, subjects and durable consumer names — derived from a single namespace prefix, plus the validation rules for every identifier that ends up as a NATS subject token or KV key segment.

Index

Constants

View Source
const Default = "packtrail"

Default is the namespace prefix used when none is supplied.

Variables

This section is empty.

Functions

func CheckToken added in v1.0.0

func CheckToken(what, s string) error

CheckToken returns a descriptive error when s is not a valid token. what names the identifier in the message ("execution id", "flow name", …).

func Partition added in v1.0.0

func Partition(execID string, n int) int

Partition maps an execution id to its partition in [0, n). It is FNV-1a (32 bit) modulo n, chosen because it is trivial to reproduce in any language SDK: every command for an execution must land in the same partition.

func TriggerMsgExecID added in v1.0.0

func TriggerMsgExecID(flow, msgID string) string

TriggerMsgExecID is the execution a trigger of flow starts for a message with Nats-Msg-Id msgID. Flows triggered by the same message get different ids, and a redelivered or republished message the same one.

func TriggerSeqExecID added in v1.0.0

func TriggerSeqExecID(flow, stream string, seq uint64) string

TriggerSeqExecID is the execution a stream trigger of flow starts for a message without Nats-Msg-Id: the message's stream and sequence identify it.

func ValidPrefix added in v1.0.0

func ValidPrefix(p string) bool

ValidPrefix reports whether p is a valid namespace prefix.

func ValidToken added in v1.0.0

func ValidToken(s string) bool

ValidToken reports whether s can be used as a single NATS subject token and KV key segment.

Types

type Names

type Names struct {
	Prefix string

	// Streams.
	StreamEvents string // source of truth: <p>.ev.<partition>.<exec>
	StreamCmd    string // command inbox + durable timers + cron schedules
	StreamWork   string // worker jobs: <p>.work.<kind>
	StreamDLQ    string // dead letters: <p>.dlq.<kind>.<key>

	// KV buckets.
	BucketSnapshots string
	BucketFlows     string
	BucketIndex     string
	BucketCache     string
	BucketSem       string
	BucketStore     string

	// Object stores.
	ObjectBlobs   string
	ObjectArchive string
}

Names holds every concrete resource name for one namespace.

func New

func New(prefix string) Names

New builds the resource names for prefix. An empty prefix falls back to Default. New panics on an invalid prefix: it is an unrecoverable configuration error that would corrupt every derived name, and callers are expected to validate user input with ValidPrefix first.

func (Names) CmdPartitionFilter added in v1.0.0

func (n Names) CmdPartitionFilter(partition int) string

CmdPartitionFilter matches every command of one partition.

func (Names) CmdStreamSubjects added in v1.0.0

func (n Names) CmdStreamSubjects() []string

CmdStreamSubjects lists the subjects of the command stream.

func (Names) CmdSubject added in v1.0.0

func (n Names) CmdSubject(partition int, execID string) string

CmdSubject is the command inbox subject of one execution.

func (Names) CronFilter added in v1.0.0

func (n Names) CronFilter() string

CronFilter matches every fired cron message.

func (Names) CronSubject added in v1.0.0

func (n Names) CronSubject(name string) string

CronSubject receives the messages fired by the cron schedule named name.

func (Names) CtlSubject added in v1.0.0

func (n Names) CtlSubject(kind string) string

CtlSubject carries core-NATS control broadcasts between engine processes (not persisted).

func (Names) DLQSubject added in v1.0.0

func (n Names) DLQSubject(kind, key string) string

DLQSubject is the dead-letter subject for one kind of dead letter.

func (Names) DLQSubjects added in v1.0.0

func (n Names) DLQSubjects() string

DLQSubjects is the subject filter of the dead-letter stream.

func (Names) DurCron added in v1.0.0

func (n Names) DurCron() string

DurCron is the durable consumer of fired cron messages.

func (Names) DurDispatch added in v1.0.0

func (n Names) DurDispatch(partition int) string

DurDispatch is the durable consumer that feeds one dispatcher partition.

func (Names) DurEngine

func (n Names) DurEngine(partition int) string

DurEngine is the durable consumer that feeds one engine partition.

func (Names) DurIndexer

func (n Names) DurIndexer() string

DurIndexer is the durable consumer that maintains the visibility index.

func (Names) DurWorker added in v1.0.0

func (n Names) DurWorker(kind string) string

DurWorker is the durable consumer shared by every worker of one kind.

func (Names) EventPartitionFilter added in v1.0.0

func (n Names) EventPartitionFilter(partition int) string

EventPartitionFilter matches every execution of one partition.

func (Names) EventSubject added in v1.0.0

func (n Names) EventSubject(partition int, execID string) string

EventSubject is the subject holding every event of one execution.

func (Names) EventsSubjects added in v1.0.0

func (n Names) EventsSubjects() string

EventsSubjects is the subject filter of the events stream.

func (Names) ProgressFilter added in v1.0.0

func (n Names) ProgressFilter(execID string) string

ProgressFilter matches every progress message of execID.

func (Names) ProgressSubject added in v1.0.0

func (n Names) ProgressSubject(execID, node string) string

ProgressSubject carries the core-NATS progress messages a worker publishes while running node of execID: never stored (G5-04).

func (Names) ScheduleSubject added in v1.0.0

func (n Names) ScheduleSubject(name string) string

ScheduleSubject holds the cron schedule message named name.

func (Names) StopSubject added in v1.0.0

func (n Names) StopSubject(execID string) string

StopSubject carries the core-NATS stop notices for jobs of execID: the work they do is no longer wanted (G5-02).

func (Names) StopSubjects added in v1.0.0

func (n Names) StopSubjects() string

StopSubjects matches every stop notice (one subscription per worker process).

func (Names) TimerExecFilter added in v1.0.0

func (n Names) TimerExecFilter(execID string) string

TimerExecFilter matches every pending timer of one execution.

func (Names) TimerSubject added in v1.0.0

func (n Names) TimerSubject(execID, timerID string) string

TimerSubject holds the schedule message of one durable timer.

func (Names) WorkDelaySubject added in v1.0.0

func (n Names) WorkDelaySubject(kind, id string) string

WorkDelaySubject holds the schedule that hands a busy job back to its kind's queue later.

func (Names) WorkDelaySubjects added in v1.0.0

func (n Names) WorkDelaySubjects() string

WorkDelaySubjects is the subject filter of hand-back schedules.

func (Names) WorkSubject added in v1.0.0

func (n Names) WorkSubject(kind string) string

WorkSubject is the job queue of one worker kind.

func (Names) WorkSubjects added in v1.0.0

func (n Names) WorkSubjects() string

WorkSubjects is the subject filter of the work stream.

Jump to

Keyboard shortcuts

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