Framework lifecycle
business function: context + environment -> shared instanceDependency Injection with Generated Maker Functions
The generated dependency-injection boundary for functions, endpoints, clients, servers, serializers, and infrastructure.
When to use
Use this page when implementing maker hooks, owning resources, or diagnosing startup and shutdown.
Behavior
- Generated defaults map graph elements to concrete framework constructors.
- The custom maker hook runs before invocation and may replace selected defaults.
- Independent makers run concurrently with shared cancellation after the first failure.
- Each business-function result is stored once per service and shared by all referencing streams for the service lifetime. Infrastructure makers retain their typed configuration. Endpoint-handler makers receive context and environment only.
Maker and instance lifetime
GeneratedInstall defaultsAssign every required factory.
User hookOverride makersReplace only selected factories.
StartupInvoke in parallelCreate one long-lived instance.
RunningReuse instanceMany messages call the stored object.
ShutdownRelease after drainOwnership ends after dependent work.
Maker responsibilities
- Create dependency clients and immutable collaborators.
- Business-function makers receive context and environment, not a stream or stream configuration. Endpoint-handler makers also receive no endpoint configuration. Infrastructure makers validate their own typed configuration.
- Return a function object whose hooks create per-request state.
- Leave activation and shutdown to runtime lifecycle methods.
Hooks and boundaries properties
Generated extension points and runtime-owned lifecycle boundaries.
PropertyTypeDescription
contextcancellation/deadlineCancels sibling initialization after a failure.
environmentServiceEnvironmentLogging, metrics, serde, callers, and runtime configuration.
configtyped graph configOnly infrastructure makers receive typed configuration. Business-function and endpoint-handler makers receive context and environment only.
resultowned instanceLong-lived function or infrastructure object.
Lifecycle outline
customMakersInit(ctx) {
makers.<function_name> = async (ctx, env) => new CustomFunction(...);
}