Documentation
¶
Overview ¶
Package event is the chok v2 business event bus: typed pub/sub with per-subscriber bounded queues. It is layer two of the lifecycle split (SPEC §3.5): asynchronous, no error propagation, no veto — anything that must be able to abort a phase belongs to component Init or the reload callback, never here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus routes published values to subscribers registered for the value's concrete type. The zero value is not usable; construct with NewBus.
func (*Bus) Close ¶
Close stops the bus: subsequent Publish calls become silent no-ops, every async subscriber drains its backlog within the ctx budget (mini-SPEC §2: default 5s from the kernel), then the goroutines stop. Called by the kernel after the last component Close so subscribers observe the complete lifecycle stream.
type BusOpt ¶
type BusOpt func(*Bus)
BusOpt configures NewBus.
func WithLogger ¶
WithLogger routes overflow warnings and subscriber panics to l. Without it the bus stays silent (events are still counted).
type Logger ¶
type Logger interface {
Warn(msg string, keysAndValues ...any)
Error(msg string, keysAndValues ...any)
}
Logger is the bus's consumer-side logging contract (overflow warns, subscriber panics). The chok log.Logger satisfies it structurally — defined here so this package stays a leaf under the kernel.
type SubOpt ¶
type SubOpt func(*subscription)
SubOpt configures a subscription.
func WithBlock ¶
func WithBlock() SubOpt
WithBlock makes Publish wait for queue space instead of dropping the oldest event. The wait is bounded by the publish context — on ctx.Done the event is dropped (counted), never deadlocked.
func WithDropOldest ¶
func WithDropOldest() SubOpt
WithDropOldest is the explicit spelling of the default policy.
func WithQueueSize ¶
WithQueueSize overrides the bounded queue capacity (min 1).