SAService Architect Back to designer
SAService ArchitectDocumentation
Framework reference Begin -> consume -> correlate/respond -> end

Endpoint handlers

Source and sink endpoint contracts for Rust. The exact generated signature follows connector type, endpoint direction, protocol mode, input type, result type, and error type.

When to use

Use this page while implementing a generated business function or endpoint handler.

Behavior

  • A source endpoint converts transport input into graph values. A sink endpoint converts graph values into transport requests and optionally emits responses back into the graph.
  • Begin creates state, consume performs the protocol conversion, result correlation handles asynchronous graph responses, and end releases resources.
  • When an Input and Sink share a request/response endpoint, generated soft associations coordinate the protocol boundary but do not replace persisted stream links.

Result correlation

A source can emit work into the graph and wait for a later result. Register the callback under the same message ID returned by the handler correlation method. The framework uses the stream context to route the result back to the pending request.

Workflow and activity endpoints

Where Temporal is supported, the endpoint configuration determines whether generated code binds the function as a workflow or an activity. This is endpoint behavior; it does not introduce an additional stream type.

Source lifecycle

Common lifecycle phases; names below are normalized for readability.

Type or methodRoleDescription
concurrencyKafka source

Limits concurrently processed records. 0 means no handler-level limit; Kafka partitioning still bounds work.

begin requestSource lifecycle

Creates request-local state and may return an updated message context before any input is emitted.

consume messageSource lifecycle

Decodes the transport request or record, emits values through the source stream context, and optionally registers result correlation.

get message IDSource correlation

Returns the stable key used to route a downstream result back to the request that emitted the input. Return an empty value when no result routing is used.

end requestSource lifecycle

Runs after completion or failure and releases request-local resources. It receives the first lifecycle error.

EOFStreaming gRPC source

Signals that the client has finished sending request messages while the RPC may still be waiting for graph results.

Rust signatures

Concrete methods and helpers exposed by this runtime.

Type or methodRoleDescription
concurrency(&StreamContext) -> usizeRust Kafka source

0 removes the handler-level concurrency cap.

begin_request(context, stream) -> Result<(MessageContext, State), HandlerError>Rust source

Creates state and returns the propagated context.

consume_message(context, stream, Arc<Mutex<State>>, transport_value, Arc<ResultContext>) -> HandlerResultRust source

Decodes input, awaits graph collection, and can register async result callbacks.

get_message_id(&context, &stream, state, &result) -> StringRust source

Returns the downstream result correlation key.

end_request(context, stream, &HandlerResult, state)Rust lifecycle

Runs cleanup with the final success or error result.

ResultContext::set_result_callback / doneRust source helper

Stores an async result callback and marks synchronous production complete.

begin_request / consume_message / handle_response / end_requestRust sink

Maps graph values to supported outbound transport calls and emits results.

Sink lifecycle

Outbound lifecycle phases used when supported by the selected connector.

Type or methodRoleDescription
begin requestSink lifecycle

Creates state for one outbound interaction and may enrich the message context.

consume messageSink lifecycle

Maps a graph value to the transport request, sends it, or writes a Kafka record.

handle responseHTTP or gRPC sink

Converts a transport response to the sink result stream and can emit a typed error.

get stream IDKafka sink correlation

Selects the message context or correlation identifier attached to the outbound record when the generated signature requires it.

end requestSink lifecycle

Finalizes the interaction after success or failure and releases request-local resources.

Shared endpoint types

Roles repeated across transport-specific generated signatures.

Type or methodRoleDescription
Handler statePer request or record

State returned by the begin method and passed to every later lifecycle method. Use it instead of storing request-specific data on the singleton handler.

Source stream contextGraph boundary

Emits decoded input values and typed endpoint errors into the graph.

Sink stream contextGraph boundary

Emits decoded transport responses and typed endpoint errors from an outbound endpoint.

Result contextAsync correlation

Registers callbacks by message ID and marks synchronous request production complete.

SenderStreaming transport

Sends protocol responses or requests without exposing the connector implementation.

Transport-specific values

Connector adapters currently exposed by this framework.

ConnectorHandler valuesDescription
HTTPAxum source / Reqwest sink

Typed handlers bridge inbound Axum requests and outbound Reqwest responses.

gRPCTonic `Sender` and `ResultContext`

Supports unary and streaming RPC endpoint shapes.

Kafkardkafka `ConsumerMessage`

Owns record data safely across async callbacks and exposes marking/commit behavior.

Croncroner integration

Activates a configured input endpoint from the Tokio runtime.

Local source/sinkCustom async traits

Connects application-owned Tokio producers and consumers.

Generated extension pattern

result.set_result_callback(message_id, callback);
stream.collect(context, decoded_value).await;
// callback calls result.done() when processing is complete