type field.
Message Types
All messages are defined insrc/protocol.rs:34.
Worker Registration
WorkerRegistered
Sent by the engine to confirm worker connection.RegisterService
Register a service namespace for organizing functions.Function Management
RegisterFunction
Register a new function with the engine.id(required): Unique function identifierdescription(optional): Human-readable descriptionrequest_format(optional): JSON Schema for input validationresponse_format(optional): JSON Schema for output validationmetadata(optional): Arbitrary metadata for the functioninvocation(optional): HTTP invocation config for external functions (see below)
HTTP Invocation Reference
For external HTTP functions, specify theinvocation field:
src/invocation/auth.rs:13):
Auth configurations reference environment variable names (not values) for security. The engine resolves these at runtime.
UnregisterFunction
Remove a function from the engine.Trigger Management
RegisterTriggerType
Register a custom trigger type.RegisterTrigger
Register a trigger to invoke a function.TriggerRegistrationResult
Confirms trigger registration (sent by engine).UnregisterTrigger
Remove a trigger.Function Invocation
InvokeFunction
Invoke a function (sent by engine or worker).invocation_id(optional): UUID for tracking (engine generates if omitted)function_id(required): Function to invokedata(required): Input datatraceparent(optional): W3C trace context for distributed tracingbaggage(optional): W3C baggage for cross-cutting context
InvocationResult
Return function result (sent by worker). Success:Health & Monitoring
Ping / Pong
Keep-alive messages.WorkerMetrics
Workers can report resource metrics for monitoring (src/protocol.rs:123).
Error Body Structure
All errors follow this structure (src/protocol.rs:156):
function_not_found: Function ID not registeredvalidation_error: Input validation failedinvocation_timeout: Function execution timeoutinternal_error: Engine internal errormissing_env_var: Required environment variable missing (auth)
Distributed Tracing
iii supports W3C Trace Context for distributed tracing:-
traceparent: Trace context propagation header
- Format:
version-trace_id-parent_id-trace_flags - Example:
00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01
- Format:
-
baggage: Cross-cutting context propagation
- Format:
key1=value1,key2=value2 - Example:
user_id=123,session_id=abc
- Format:
Best Practices
Message Ordering
- RegisterService (optional)
- RegisterFunction (for each function)
- RegisterTrigger (after function exists)
- Wait for TriggerRegistrationResult
- Handle InvokeFunction messages
- Send InvocationResult responses
Error Handling
- Always check for
errorfield in result messages - Implement exponential backoff for reconnections
- Handle partial failures gracefully
Performance
- Reuse WebSocket connections
- Batch trigger registrations when possible
- Use
invocation_idfor request-response correlation - Include distributed tracing headers for observability
Security
- Never hardcode secrets in message payloads
- Use environment variable references for auth configs
- Validate all input data before processing
- Use TLS for production WebSocket connections
Example: Complete Flow
Type Definitions
For full type definitions, see:- Protocol messages:
src/protocol.rs - Auth configurations:
src/invocation/auth.rs - HTTP methods:
src/invocation/method.rs