Installation
Initialization
Create and return a connected SDK instance. The WebSocket connection is established automatically in a background Tokio task.Methods
shutdown
Shutdown the III client. This stops the connection loop and sends a shutdown signal. If theotel feature is enabled, this will spawn a background task
to flush telemetry data, but does NOT wait for it to complete.
For guaranteed telemetry flush, use shutdown_async() instead.
Signature
shutdown_async
Shutdown the III client and flush all pending telemetry data. This method stops the connection loop and sends a shutdown signal. When theotel feature is enabled, it additionally awaits the
OpenTelemetry flush, ensuring all spans, metrics, and logs are
exported before returning.
Signature
register
Register a function using theRegisterFunction builder.
This is the recommended API — combines ID, handler, and auto-generated
request_format/response_format schemas in one step.
Signature
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
reg | RegisterFunction | Yes | Function registration built with RegisterFunction::new or RegisterFunction::new_async. |
Example
register_function
Register a function with the engine. Accepts any type implementingIntoFunctionRegistration:
a RegisterFunction builder (preferred), or a (RegisterFunctionMessage, Handler) tuple.
For the simplest API with auto-generated schemas, use RegisterFunction::new / RegisterFunction::new_async.
Signature
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
registration | R: IntoFunctionRegistration | Yes | A RegisterFunction builder, or a (RegisterFunctionMessage, H) tuple where H is a handler or HttpInvocationConfig. |
Example
register_service
Register a service with the engine. SignatureParameters
| Name | Type | Required | Description |
|---|---|---|---|
message | RegisterServiceMessage | Yes | Service registration message with id, name, and optional metadata. |
register_trigger_type
Register a custom trigger type with the engine. SignatureParameters
| Name | Type | Required | Description |
|---|---|---|---|
id | impl Into<String> | Yes | Unique trigger type identifier. |
description | impl Into<String> | Yes | Human-readable description. |
handler | H | Yes | Handler implementing [TriggerHandler]. |
unregister_trigger_type
Unregister a previously registered trigger type. SignatureParameters
| Name | Type | Required | Description |
|---|---|---|---|
id | impl Into<String> | Yes | - |
register_trigger
Bind a trigger configuration to a registered function. SignatureParameters
| Name | Type | Required | Description |
|---|---|---|---|
input | RegisterTriggerInput | Yes | Trigger registration input with trigger_type, function_id, and config. |
Example
trigger
Invoke a remote function. The routing behavior depends on theaction field of the request:
- No action: synchronous — waits for the function to return.
- [
TriggerAction::Enqueue] - async via named queue. - [
TriggerAction::Void] — fire-and-forget.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
request | impl Into<TriggerRequest> | Yes | - |
Example
get_connection_state
Get the current connection state. Signaturelist_functions
List all registered functions from the engine Signatureon_functions_available
Subscribe to function availability events Returns a guard that will unsubscribe when dropped SignatureParameters
| Name | Type | Required | Description |
|---|---|---|---|
callback | F | Yes | - |
list_workers
List all connected workers from the engine Signaturelist_triggers
List all registered triggers from the engine SignatureParameters
| Name | Type | Required | Description |
|---|---|---|---|
include_internal | bool | Yes | - |
create_channel
Create a streaming channel pair for worker-to-worker data transfer. Returns aChannel with writer, reader, and their serializable refs
that can be passed as fields in invocation data to other functions.
Signature
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
buffer_size | Option<usize> | No | - |
Logger
Structured logger that emits logs as OpenTelemetry LogRecords. Every log call automatically captures the active trace and span context, correlating your logs with distributed traces without any manual wiring. When OTel is not initialized, Logger gracefully falls back to thetracing
crate.
Pass structured data as the second argument to any log method. Using a
serde_json::Value object of key-value pairs (instead of string
interpolation) lets you filter, aggregate, and build dashboards in your
observability backend.
info
Log an info-level message. SignatureParameters
| Name | Type | Required | Description |
|---|---|---|---|
message | &str | Yes | Human-readable log message. |
data | Option<Value> | No | Structured context attached as OTel log attributes. Use serde_json::json! objects to enable filtering and aggregation in your observability backend (e.g. Grafana, Datadog, New Relic). |
Example
warn
Log a warning-level message. SignatureParameters
| Name | Type | Required | Description |
|---|---|---|---|
message | &str | Yes | Human-readable log message. |
data | Option<Value> | No | Structured context attached as OTel log attributes. Use serde_json::json! objects to enable filtering and aggregation in your observability backend (e.g. Grafana, Datadog, New Relic). |
Example
error
Log an error-level message. SignatureParameters
| Name | Type | Required | Description |
|---|---|---|---|
message | &str | Yes | Human-readable log message. |
data | Option<Value> | No | Structured context attached as OTel log attributes. Use serde_json::json! objects to enable filtering and aggregation in your observability backend (e.g. Grafana, Datadog, New Relic). |
Example
debug
Log a debug-level message. SignatureParameters
| Name | Type | Required | Description |
|---|---|---|---|
message | &str | Yes | Human-readable log message. |
data | Option<Value> | No | Structured context attached as OTel log attributes. Use serde_json::json! objects to enable filtering and aggregation in your observability backend (e.g. Grafana, Datadog, New Relic). |
Example
Types
RegisterFunction · iii_fn · iii_async_fn · InitOptions · IIIError · IIIConnectionState · TriggerRequest · TriggerAction · HttpInvocationConfig · HttpAuthConfig · HttpMethod · Channel · ChannelReader · ChannelWriter · ChannelDirection · StreamChannelRef · FunctionInfo · FunctionRef · TriggerInfo · WorkerInfo · WorkerMetadata · Trigger · RegisterFunctionMessage · RegisterServiceMessage · OtelConfig · ReconnectionConfig
RegisterFunction
One-step function registration combining ID, handler, and auto-generated schemas. UseRegisterFunction::new for sync functions or RegisterFunction::new_async
for async functions, then pass to III::register.
Constructors
| Name | Description |
|---|---|
new(id, f) | Wrap a sync function. Each param must impl DeserializeOwned, return must be Result<R: Serialize, E: Display>. |
new_async(id, f) | Wrap an async function. Same constraints as new. |
| Name | Type | Description |
|---|---|---|
description(desc) | impl Into<String> | Set the function description. |
metadata(meta) | Value | Set function metadata. |
| Args | JSON input format | Deserialization |
|---|---|---|
| 0 | ignored | none |
| 1 | {"field": "value"} | Entire JSON deserialized as the arg type (use #[derive(Deserialize, JsonSchema)] structs) |
request_format and response_format are automatically
populated as JSON Schema (draft-07) using
schemars. Input and output types must derive
schemars::JsonSchema alongside serde::Deserialize/serde::Serialize.
iii_fn
pub fn iii_fn<F, M>(f: F) -> IIIFn<F>
Wraps a sync function into an III-compatible handler.
The input type must implement DeserializeOwned + JsonSchema and the return
type must implement Serialize + JsonSchema.
iii_async_fn
pub fn iii_async_fn<F, M>(f: F) -> IIIAsyncFn<F>
Wraps an async function into an III-compatible handler. Same semantics as iii_fn.
InitOptions
Configuration options passed to [register_worker].
| Name | Type | Required | Description |
|---|---|---|---|
metadata | Option<WorkerMetadata> | No | Custom worker metadata. Auto-detected if None. |
otel | Option<OtelConfig> | No | OpenTelemetry configuration. Requires the otel feature. |
IIIError
Errors returned by the III SDK.| Name | Type | Required | Description |
|---|---|---|---|
NotConnected | unit | Yes | - |
Timeout | unit | Yes | - |
Runtime | (String) | Yes | - |
Remote | { code: String, message: String, stacktrace: Option<String> } | Yes | - |
Handler | (String) | Yes | - |
Serde | (String) | Yes | - |
WebSocket | (String) | Yes | - |
IIIConnectionState
Connection state for the III WebSocket client| Name | Type | Required | Description |
|---|---|---|---|
Disconnected | unit | Yes | - |
Connecting | unit | Yes | - |
Connected | unit | Yes | - |
Reconnecting | unit | Yes | - |
Failed | unit | Yes | - |
TriggerRequest
Request object fortrigger(). Matches the Node/Python SDK signature:
trigger({ function_id, payload, action?, timeout_ms? })
| Name | Type | Required | Description |
|---|---|---|---|
function_id | String | Yes | - |
payload | Value | Yes | - |
action | Option<TriggerAction> | No | - |
timeout_ms | Option<u64> | No | - |
TriggerAction
Routing action for [TriggerRequest]. Determines how the engine handles
the invocation.
Enqueue— Routes through a named queue for async processing.Void— Fire-and-forget, no response.
| Name | Type | Required | Description |
|---|---|---|---|
Enqueue | { queue: String } | Yes | Routes the invocation through a named queue. |
Void | unit | Yes | Fire-and-forget routing. |
HttpInvocationConfig
Configuration for registering an HTTP-invoked function (Lambda, Cloudflare Workers, etc.) instead of a local handler.| Name | Type | Required | Description |
|---|---|---|---|
url | String | Yes | - |
method | HttpMethod | Yes | - |
timeout_ms | Option<u64> | No | - |
headers | HashMap<String, String> | Yes | - |
auth | Option<HttpAuthConfig> | No | - |
HttpAuthConfig
Authentication configuration for HTTP-invoked functions.Hmac— HMAC signature verification using a shared secret.Bearer— Bearer token authentication.ApiKey— API key sent via a custom header.
| Name | Type | Required | Description |
|---|---|---|---|
Hmac | { secret_key: String } | Yes | - |
Bearer | { token_key: String } | Yes | - |
ApiKey | { header: String, value_key: String } | Yes | - |
HttpMethod
| Name | Type | Required | Description |
|---|---|---|---|
Get | unit | Yes | - |
Post | unit | Yes | - |
Put | unit | Yes | - |
Patch | unit | Yes | - |
Delete | unit | Yes | - |
Channel
A streaming channel pair for worker-to-worker data transfer.| Name | Type | Required | Description |
|---|---|---|---|
writer | ChannelWriter | Yes | - |
reader | ChannelReader | Yes | - |
writer_ref | StreamChannelRef | Yes | - |
reader_ref | StreamChannelRef | Yes | - |
ChannelReader
WebSocket-backed reader for streaming binary data and text messages.| Name | Type | Required | Description |
|---|---|---|---|
on_message | async fn(callback: F) | Yes | Register a callback for text messages received on this channel. |
next_binary | async fn() -> Result<Option<Vec<u8>>, IIIError> | Yes | Read the next binary chunk from the channel. Text messages are dispatched to registered callbacks. Returns None when the stream is closed. |
read_all | async fn() -> Result<Vec<u8>, IIIError> | Yes | Read the entire stream into a single Vec<u8>. |
close | async fn() -> Result<(), IIIError> | Yes | - |
ChannelWriter
WebSocket-backed writer for streaming binary data and text messages.ChannelDirection
| Name | Type | Required | Description |
|---|---|---|---|
Read | unit | Yes | - |
Write | unit | Yes | - |
StreamChannelRef
| Name | Type | Required | Description |
|---|---|---|---|
channel_id | String | Yes | - |
access_key | String | Yes | - |
direction | ChannelDirection | Yes | - |
FunctionInfo
Function information returned byengine::functions::list. The engine auto-generates standard JSON Schema for request_format and response_format from Rust types using schemars.
| Name | Type | Required | Description |
|---|---|---|---|
function_id | String | Yes | Unique function identifier. |
description | Option<String> | No | Human-readable description. |
request_format | Option<Value> | No | JSON Schema describing expected input. Auto-generated for functions registered via the #[service] macro. |
response_format | Option<Value> | No | JSON Schema describing expected output. Auto-generated for functions registered via the #[service] macro. |
metadata | Option<Value> | No | Arbitrary metadata attached to the function. |
FunctionRef
| Name | Type | Required | Description |
|---|---|---|---|
id | String | Yes | - |
unregister | fn() | Yes | - |
TriggerInfo
Trigger information returned byengine::triggers::list
| Name | Type | Required | Description |
|---|---|---|---|
id | String | Yes | - |
trigger_type | String | Yes | - |
function_id | String | Yes | - |
config | Value | Yes | - |
WorkerInfo
Worker information returned byengine::workers::list
| Name | Type | Required | Description |
|---|---|---|---|
id | String | Yes | - |
name | Option<String> | No | - |
runtime | Option<String> | No | - |
version | Option<String> | No | - |
os | Option<String> | No | - |
ip_address | Option<String> | No | - |
status | String | Yes | - |
connected_at_ms | u64 | Yes | - |
function_count | usize | Yes | - |
functions | Vec<String> | Yes | - |
active_invocations | usize | Yes | - |
WorkerMetadata
Worker metadata for auto-registration| Name | Type | Required | Description |
|---|---|---|---|
runtime | String | Yes | - |
version | String | Yes | - |
name | String | Yes | - |
os | String | Yes | - |
pid | Option<u32> | No | - |
telemetry | Option<WorkerTelemetryMeta> | No | - |
Trigger
Handle returned byIII::register_trigger.
Call unregister to remove the trigger from the engine.
| Name | Type | Required | Description |
|---|---|---|---|
unregister | fn() | Yes | Remove this trigger from the engine. |
RegisterFunctionMessage
| Name | Type | Required | Description |
|---|---|---|---|
id | String | Yes | Unique function identifier. |
description | Option<String> | No | Human-readable description. |
request_format | Option<Value> | No | JSON Schema describing expected input. |
response_format | Option<Value> | No | JSON Schema describing expected output. |
metadata | Option<Value> | No | Arbitrary metadata attached to the function. |
invocation | Option<HttpInvocationConfig> | No | HTTP invocation config for externally hosted functions. |
to_message | fn() -> Message | Yes | Convert to protocol message. |
RegisterServiceMessage
| Name | Type | Required | Description |
|---|---|---|---|
id | String | Yes | - |
name | String | Yes | - |
description | Option<String> | No | - |
parent_service_id | Option<String> | No | - |
to_message | fn() -> Message | Yes | - |
OtelConfig
Configuration for OpenTelemetry initialization| Name | Type | Required | Description |
|---|---|---|---|
enabled | Option<bool> | No | - |
service_name | Option<String> | No | - |
service_version | Option<String> | No | - |
service_namespace | Option<String> | No | - |
service_instance_id | Option<String> | No | - |
engine_ws_url | Option<String> | No | - |
metrics_enabled | Option<bool> | No | - |
metrics_export_interval_ms | Option<u64> | No | - |
reconnection_config | Option<ReconnectionConfig> | No | - |
shutdown_timeout_ms | Option<u64> | No | Timeout in milliseconds for the shutdown sequence (default: 10,000) |
channel_capacity | Option<usize> | No | Capacity of the internal telemetry message channel (default: 10,000). This controls the in-flight message buffer between exporters and the WebSocket connection loop. Intentionally larger than ReconnectionConfig::max_pending_messages to absorb bursts duringnormal operation while limiting stale data across reconnects. |
logs_enabled | Option<bool> | No | Whether to enable the log exporter (default: true) |
logs_flush_interval_ms | Option<u64> | No | Log processor flush delay in milliseconds. Defaults to 100ms when not set. |
logs_batch_size | Option<usize> | No | Maximum number of log records exported per batch. Defaults to 1 when not set. |
fetch_instrumentation_enabled | Option<bool> | No | Whether to auto-instrument outgoing HTTP calls. When Some(true) (default), execute_traced_request() can be used tocreate CLIENT spans for reqwest requests. Set Some(false) to opt out.None is treated as true. |
ReconnectionConfig
Configuration for WebSocket reconnection behavior| Name | Type | Required | Description |
|---|---|---|---|
initial_delay_ms | u64 | Yes | - |
max_delay_ms | u64 | Yes | - |
backoff_multiplier | f64 | Yes | - |
jitter_factor | f64 | Yes | - |
max_retries | Option<u64> | No | - |
max_pending_messages | usize | Yes | Maximum messages preserved across reconnects. Messages beyond this limit are dropped to prevent delivering stale data after a long disconnect. This is intentionally smaller than OtelConfig::channel_capacity (thein-flight buffer between exporters and the WebSocket loop). |
effective_initial_delay_ms | fn() -> u64 | Yes | Returns initial_delay_ms, clamped to a minimum of 1ms to prevent division by zero. |