streamruntime

package
v0.66.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package streamruntime is the one link-time seam for the native streams lane.

messaging/streams registers an implementation at init. app starts the manager through that registration. inbox implements the hold port without importing messaging/streams, so a core-only consumer never pulls the vendor client (ADR-091).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotLinked = errors.New(
	`messaging.streams.uri is set but the streams lane is not linked; import _ "github.com/gaborage/go-bricks/messaging/streams"`)

ErrNotLinked is returned at startup when messaging.streams.uri is set but messaging/streams was never imported into the build.

Functions

func Register

func Register(r Runtime)

Register installs the streams lane implementation. messaging/streams calls it from init. A second registration panics: two factories would silently drop one lane.

Types

type DeclStats

type DeclStats struct {
	Streams    int
	Consumers  int
	Publishers int
}

DeclStats is the operator-facing count the unconfigured-URI error names.

type Declarations

type Declarations interface {
	IsEmpty() bool
	Stats() DeclStats
}

Declarations is the collected, validated declaration set. The concrete type is produced by the registered runtime so app never names streams types.

type Handle

type Handle interface {
	Start(ctx context.Context, decls Declarations) error
	Close() error
	StopConsumers()
	SetTenantStamps(enabled bool)
	Ready() bool
	Stats() map[string]any
}

Handle is the started (or about-to-start) stream manager as the framework sees it.

type HeldMessage

type HeldMessage struct {
	Consumer   string
	Stream     string
	Offset     int64
	TenantID   string
	Data       []byte
	Properties map[string]any
	HeldAt     time.Time
}

HeldMessage is one parked stream delivery as the hold ledger sees it.

type HoldLedger

type HoldLedger interface {
	Park(ctx context.Context, msg *HeldMessage) error
	HeldTenants(ctx context.Context, consumer string) ([]string, error)
}

HoldLedger is the port stream consumers park through.

Park is idempotent on (Consumer, Stream, Offset) and marks the tenant held in the same write: a row whose tenant is not held would be replayed by nothing.

type HoldReplayer

type HoldReplayer interface {
	HoldConsumers() []string
	Replay(ctx context.Context, consumer string, msg *HeldMessage) error
	// ReloadHeld refreshes one consumer's held set from the ledger. It takes no
	// listing: the generation that guards the set has to be read BEFORE the ledger
	// is, and only the streams package holds it, so the read belongs on that side
	// of the port.
	ReloadHeld(ctx context.Context, consumer string) error
}

HoldReplayer is what the hold drain drives to put a held message back through the lane, and how it tells a runner which tenants the ledger still holds.

type ManagerOptions

type ManagerOptions struct {
	URI                 string
	AddressResolverHost string
	AddressResolverPort int
	OffsetStoreCount    int
	OffsetStoreInterval time.Duration
	Logger              logger.Logger
	Hold                HoldLedger
}

ManagerOptions is the subset of manager construction the framework owns.

type ModuleNamer added in v0.63.0

type ModuleNamer interface {
	Name() string
}

ModuleNamer is the subset of app.Module the runtime needs to walk declarers.

type Runtime

type Runtime interface {
	CollectDeclarations(modules []ModuleNamer, log logger.Logger) (Declarations, error)
	NewManager(opts *ManagerOptions) Handle
	CanDrainHold() bool
}

Runtime is the registered streams implementation.

func Registered

func Registered() Runtime

Registered returns the installed runtime, or nil when the lane is not linked.

func SwapRegistered

func SwapRegistered(r Runtime) Runtime

SwapRegistered replaces the installed runtime and returns the previous one. Tests use it to exercise the unlinked path in a package that also imports messaging/streams.

Jump to

Keyboard shortcuts

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