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 ¶
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 ¶
Types ¶
type Declarations ¶
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 Module ¶
type Module interface {
Name() string
}
Module is the subset of app.Module the runtime needs to walk declarers.
type Runtime ¶
type Runtime interface {
CollectDeclarations(modules []Module, 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 ¶
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.