Context + Stream + Collector + EnvironmentRuntime values and outputs
Core C++ userver values passed into makers, operators, and endpoint handlers. These are the stable application-facing handles to the generated runtime.
When to use
Use this page while implementing a generated business function or endpoint handler.
Behavior
- Contexts carry cancellation and correlation across graph boundaries.
- Collectors and stream contexts are the supported way to emit values; calling downstream functions directly bypasses graph semantics and observability.
- The service environment is supplied during construction so business implementations can create scoped metrics, obtain loggers, and resolve configured dependencies.
Core runtime types
Types normally visible in preserved implementation signatures.
servicelib::MessageContextPer-message contextCarries stream ID and runtime propagation state. Pass or move it into every output so downstream work remains correlated.
servicelib::ContextLifecycle contextUsed by maker and service lifecycle code; it is distinct from the per-message MessageContext.
servicelib::StreamBaseStream metadataReference to the generated stream currently invoking the callable.
Output / ErrorOutputCallable outputsFramework-supplied adapters. out(context, value) or .out(context, value) emits normal or error values according to the generated callable signature.
servicelib::Payload<T>Shared payloadOwns or shares a typed value across asynchronous graph calls without forcing unnecessary copies.
servicelib::SourceStreamContext<T, R, E>Source endpoint contextcollect and collectError emit decoded values and typed failures.
servicelib::SinkStreamContext<T, R, E>Sink endpoint contextcollect emits transport results and collectError emits typed failures.
servicelib::BeginResult<State>Endpoint begin resultReturns the message context and request-local handler state together.
servicelib::IServiceEnvironmentMaker dependencyExposes runtime configuration, logger, metrics, tracing, and registered service dependencies.
Generated extension pattern
stream.collect(std::move(context), std::move(value));
stream.collectError(std::move(context), error);