Skip to main content

Module lifecycle

Module lifecycle 

Source
Expand description

Fire-and-forget lifecycle and telemetry taps.

Two Service shapes live here, both fire-and-forget:

§Service<LifecycleEvent>

Replaces the legacy dispatch_hook callback registry. Plugins that want to observe lifecycle events (user_created, oauth_signup, magic_link_requested, user_verified, etc.) register a tower::Service<LifecycleEvent, Response = ()>.

§TelemetryService (Service<TelemetryEvent>)

Replaces the legacy EventSubscriber trait whose run(self, rx: Receiver<Value>) shape forced the subscriber to own the event stream. Per ADR-006 the host now owns the receive loop and calls each registered Service per event. Composition wins: tower::trace::TraceLayer, tower::timeout::TimeoutLayer, tower::limit::ConcurrencyLimitLayer all stack onto the Service before registration.

Both Services log + drop on error — neither lifecycle nor telemetry dispatch should ever fail the originating call site.

Structs§

LifecycleEvent
A single lifecycle event. kind is a stable string the host uses to route events; plugins filter on kind themselves and no-op for events they don’t care about.

Type Aliases§

TelemetryEvent
A single telemetry event — opaque JSON shaped by tracing’s event emitter (level, target, fields, span context). Plugins inspect fields they care about; everything else is ignored.
TelemetryService
Tower-shaped telemetry-subscriber type.