natsubj

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package natsubj builds and parses the ppz subject grammar

<org_id>.<handle>.<pipe>

where {pipe} ∈ {broadcast, inbox, stdin, stdout}. The optional workspace slot between org and handle is reserved by the long-term grammar but unused.

Index

Constants

This section is empty.

Variables

View Source
var AutoProvisionedPipes = map[string]bool{
	"broadcast": true,
	"inbox":     true,
	"stdin":     true,
	"stdout":    true,
	"stdctrl":   true,
}

AutoProvisionedPipes covers pipes the server creates automatically for sources. Some are also allowed via user pipe creation (`stdin`, `stdout`, `stdctrl` for terminal sharing); `inbox` remains reserved from manual creation even though it is provisioned automatically. The set is here for documentation + the daemon's ls dedupe.

View Source
var HandleRegex = regexp.MustCompile(`^[a-z0-9]([a-z0-9-]{0,30}[a-z0-9])?$`)

HandleRegex per WIRE.md §1: lowercase alnum + hyphens, max 32, no leading or trailing hyphen.

View Source
var Reserved = map[string]bool{
	"broadcast": true,
	"inbox":     true,
	"stdin":     true,
	"stdout":    true,
	"stdctrl":   true,
	"system":    true,
	"db":        true,
}

Reserved handles that cannot be used as pipe names. They overlap with the channel names so a bare-token target stays unambiguous.

View Source
var ReservedPipeNames = map[string]bool{
	"system": true,
	"db":     true,
	"inbox":  true,
}

ReservedPipeNames are names blocked from user pipe creation. Reserved for future system use (e.g. an inbox routing scheme, db-backed pipes).

View Source
var ValidChannels = ValidPipes

ValidChannels is a deprecated alias kept during the Phase A rename for any caller still phrasing the check as "channel". Will be removed in Phase B.

View Source
var ValidPipes = map[string]bool{
	"broadcast": true,
	"inbox":     true,
	"stdin":     true,
	"stdout":    true,
	"stdctrl":   true,
}

ValidPipes are the pipe names recognised on the wire — both auto- provisioned (broadcast / stdin / stdout / stdctrl) and any future user- creatable names. The user-creatable paths add additional validation on top (regex, reserved-name check).

stdctrl carries control signals that don't fit on stdin/out — initially just JSON resize events, later potentially exit codes, title changes, focus events, etc. The web terminal viewer consumes it to keep its xterm.js viewport sized to match the source pty.

Functions

func Broadcast

func Broadcast(orgID uuid.UUID, handle string) string

Broadcast is the canonical helper for the broadcast channel — preserved for callers that don't think in terms of channels yet.

func OrgSubscription

func OrgSubscription(orgID uuid.UUID) string

OrgSubscription is the wildcard subscription used by the server-side subscriber and by the daemon's NATS user JWT permission set.

func StreamName

func StreamName(orgID uuid.UUID, handle, pipe string) string

StreamName produces the JetStream stream name per WIRE.md §2:

source_<orgshort>_<handle>_<pipe>

where orgshort is the first 8 hex chars of the org UUID, hyphens stripped.

func Subject

func Subject(orgID uuid.UUID, handle, pipe string) string

Subject builds <org>.<handle>.<pipe>.

func ValidateChannel

func ValidateChannel(c string) error

ValidateChannel is the Phase A backward-compat alias for ValidatePipe. Removed in Phase B.

func ValidateHandle

func ValidateHandle(h string) error

func ValidatePipe

func ValidatePipe(name string) error

ValidatePipe checks a pipe name's *syntax* — regex only, no auto/reserved restrictions. Used by `read` / `send` / `broadcast` targets, where any existing pipe is a legitimate destination (auto-provisioned or user- created). The "does this stream actually exist" check is deferred to the publish/read path against JetStream.

User pipe creation goes through ValidateUserPipeName, which adds the auto/reserved restrictions on top of the regex.

func ValidateUserPipeName

func ValidateUserPipeName(name string) error

ValidateUserPipeName validates a name passed to `ppz pipe create`. Same handle regex (lowercase alnum + hyphens, max 32, no leading/trailing hyphen). Reserved names are rejected. Auto-provisioned names (broadcast, stdin, stdout) ARE allowed: any source can have arbitrary pipes added to it, and the pipe-create path is idempotent against an already-existing stream.

Types

This section is empty.

Jump to

Keyboard shortcuts

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