Map | Filter | FlatMap | KeyBy | Process | Join | MultiJoin | Delay | CaseOperator functions
Operator contracts invoked by generated C++ userver streams. Implement only the contract selected by the stream type in the designer.
When to use
Use this page while implementing a generated business function or endpoint handler.
Behavior
- Every invocation receives the current stream and input value; runtimes with explicit message contexts also pass the context separately.
- Emission is explicit. Returning from Map, FlatMap, KeyBy, or Process without using an output intentionally produces no downstream value.
- Process has separate normal and error outputs. Throwing or returning a runtime error is not a substitute for intentionally emitting the graph error type.
- Join inputs are already grouped by key and retained by the configured join storage before the user callback runs.
Streams without a user callback
Input, Sink, Merge, Split, FlatMap Iterable, Cycle Link, Error, and individual When branches are primarily graph/runtime nodes. Their behavior is generated from topology and configuration; they do not all require a custom operator implementation.
Output and error semantics
Normal output follows persisted graph links. A Process error output follows the dedicated Error link. A callback can emit more than once unless the selected stream contract or downstream protocol imposes a stricter rule.
Operator contracts
User-facing methods selected by generated stream wiring.
operator()(MessageContext, StreamBase&, const T&, Output&&)Map / FlatMap / KeyByThe generated StreamFunction checks the callable shape and supplies an output adapter whose out method emits values.
operator()(MessageContext, StreamBase&, const T&) -> boolFilterReturns whether the current value should continue to downstream streams.
operator()(MessageContext, StreamBase&, const T&, Output&&, ErrorOutput&&)ProcessRuns general business logic with independent normal and error outputs.
operator()(MessageContext, StreamBase&, K, left, right, Output&&) -> boolJoinReceives the current key and the buffered values from the left and right inputs, emits results, and returns the framework completion decision for that key.
operator()(MessageContext, StreamBase&, K, values, Output&&) -> boolMultiJoinReceives the current key and one buffered value collection per input, emits results, and returns the framework completion decision for that key.
duration(...) / delayError(...)Delay callableCalculates how long the value should wait; the paired error method decides what to emit when scheduling the delay fails.
buildSwitch(StreamBase&, whenItems)Case routingBuilds the runtime selector used by a Case stream to choose one of its typed When branches.
Generated extension pattern
void operator()(servicelib::MessageContext context,
servicelib::StreamBase& stream, const Order& value,
auto&& out, auto&& errors) const {
out.out(std::move(context), value);
}