Documentation
¶
Overview ¶
Package events provides the generic, typed @events route directive.
Index ¶
- Constants
- Variables
- func Bundle(_ map[string]string) compiler.Bundle
- func InstallPublisher(ctx context.Context, meta map[string]any) context.Context
- func IsRouteInvocation(ctx context.Context) bool
- func MaterializeRoutes(req compiler.MaterializeReq) error
- func PublishFromBundle[T any](ctx context.Context, bundleID, subject string, payload *T) error
- func WithRouteInvocation(ctx context.Context) context.Context
- type NonRetainingEventSink
- type NonRetainingEventSinkAction
- type Route
Constants ¶
const ID = "events"
Variables ¶
var Directive = compiler.Directive{ Name: "events", Example: "@events {\n observe thttp.events.listener_ready -> thttp.listener_ready_sink\n}", Handler: handleDirective, OpaqueBlock: true, }
Directive parses newline-separated routes to direct typed event sinks.
Functions ¶
func InstallPublisher ¶
InstallPublisher composes the source's explicit routes with any publisher supplied by the host. The host publisher receives the original payload and context; it may retain the caller-owned payload. No pooled or shared payload state is used by the route table.
func IsRouteInvocation ¶
IsRouteInvocation reports whether ctx is executing a legacy route invocation.
func MaterializeRoutes ¶
func MaterializeRoutes(req compiler.MaterializeReq) error
MaterializeRoutes resolves explicit event sources and direct typed sinks from the mounted Catalog resolver. Routed sinks must implement the non-retaining contract; arbitrary expressions and dynamically coerced actions are rejected.
func PublishFromBundle ¶
PublishFromBundle publishes a caller-owned typed event through the publisher injected with Kernel's xctx.EventPublisher seam. Payload must point to an immutable event value that the caller will not mutate or reuse; host delegates may retain it. The local route sink is synchronous and must not retain it.
Types ¶
type NonRetainingEventSink ¶
type NonRetainingEventSink interface {
EventPayloadType() reflect.Type
HandleEvent(context.Context, any) error
}
NonRetainingEventSink is the synchronous route contract for typed event sinks. Implementations must not retain or mutate the payload or context after the call returns. PayloadType must be the exact pointer type accepted by HandleEvent. Event sinks are invoked directly, outside action execution and journal steps.
type NonRetainingEventSinkAction ¶
type NonRetainingEventSinkAction interface {
action.AnyAction
NonRetainingEventSink
}
NonRetainingEventSinkAction is both a Catalog-mountable action and a typed synchronous event sink.
func NewNonRetainingEventSink ¶
func NewNonRetainingEventSink[T any](name string, handler func(context.Context, *T) error) NonRetainingEventSinkAction
NewNonRetainingEventSink creates a Catalog-resolvable typed sink action. Its route path calls handler directly with the original caller-owned *T payload; it does not project fields, coerce the payload, or run the action's journal lifecycle. The handler must complete synchronously and must not retain or mutate the payload or context.