Overview
The III SDK provides a distributed function execution platform that connects multiple workers (services) through a central III Engine. Workers communicate with the Engine via WebSocket connections, enabling real-time function invocation, bidirectional streaming, and event-driven architectures.System Components
1
III Engine (Central Hub)
The Engine acts as a message broker and coordinator that:
- Routes function invocations between workers
- Manages trigger registrations and event dispatching
- Provides streaming channels for data transfer
- Maintains worker registry and health status
- Handles distributed tracing with OpenTelemetry
2
Workers (SDK Clients)
Workers are applications that connect to the Engine and:
- Register functions they can execute
- Subscribe to triggers (HTTP endpoints, events, schedules)
- Invoke functions registered by other workers
- Stream data through channels
- Report metrics and telemetry
3
WebSocket Protocol
All communication uses a persistent WebSocket connection with:
- Binary message framing for efficient data transfer
- JSON-based message protocol with type discriminators
- Automatic reconnection with exponential backoff
- Distributed tracing context propagation (W3C Trace Context)
Communication Model
WebSocket Connection Lifecycle
The SDK manages WebSocket connections with automatic reconnection:The SDK automatically reconnects with exponential backoff (default: 1s initial delay, 30s max delay, infinite retries). Functions and triggers are re-registered on reconnection.
Message Flow
Message Protocol
All messages follow a consistent structure with atype field:
Function Invocation Messages
InvokeFunction (Request):Reconnection Strategy
The SDK implements resilient reconnection with configurable backoff:1
Connection Lost
WebSocket
close event detected, state changes to reconnecting2
Backoff Calculation
3
Re-registration
On successful reconnection:
- All trigger types are re-registered
- All services are re-registered
- All functions (local and HTTP) are re-registered
- All triggers are re-registered
- Queued messages are sent
Worker Registration
Workers automatically register metadata on connection:WorkerRegistered message containing a unique worker_id.
Distributed Tracing
The architecture supports W3C Trace Context for end-to-end observability:Every function invocation automatically propagates
traceparent and baggage headers, enabling distributed tracing across workers without manual instrumentation.-
Caller injects trace context:
- Engine forwards context with invocation message
-
Handler extracts context and creates child span:
- Response includes updated trace context from handler
packages/node/iii/src/iii.ts:202-217 for implementation details.
Multi-Runtime Support
The III SDK is available in three runtimes with consistent APIs:- Node.js
- Python
- Rust
packages/node/iii/src/iii.tsPerformance Considerations
Message Batching
The SDK queues messages when WebSocket is not ready and sends them in batch on connection:Invocation Timeouts
All function calls have configurable timeouts (default 30s):Connection State Management
Monitor and react to connection state changes:packages/node/iii/src/iii.ts:473-488 for implementation.
Graceful Shutdown
The SDK provides graceful shutdown that:- Stops accepting new invocations
- Rejects pending invocations with error
- Closes WebSocket connection
- Flushes OpenTelemetry data
- Clears all callbacks
Next Steps
Functions
Learn how to register and invoke functions
Triggers
Understand trigger types and event handling
Channels
Implement bidirectional streaming
Streaming
Build real-time data operations