init()
Initialize a new III SDK instance and connect to the engine.
WebSocket URL of the III Engine (e.g., ws://localhost:49199)
Optional configuration for the SDK instance Show InitOptions properties
Custom worker name for identification. Defaults to hostname:pid
Enable automatic worker metrics reporting via OpenTelemetry
Default timeout for function invocations in milliseconds (2 minutes)
reconnectionConfig Partial<IIIReconnectionConfig>
WebSocket reconnection behavior configuration Show Reconnection config properties
Initial delay before first reconnection attempt
Maximum delay between reconnection attempts
Exponential backoff multiplier for reconnection delays
Random jitter factor (0-1) to prevent thundering herd
Maximum retry attempts (-1 for infinite)
OpenTelemetry configuration. OTel is enabled by default. Show OpenTelemetry config properties
Enable OpenTelemetry. Set to false or env OTEL_ENABLED=false to disable
Service name for telemetry (also reads OTEL_SERVICE_NAME env var)
Service version (also reads SERVICE_VERSION env var)
Enable metrics export (also reads OTEL_METRICS_ENABLED env var)
Metrics export interval in milliseconds
fetchInstrumentationEnabled Auto-instrument fetch() calls for HTTP client tracing
Custom OpenTelemetry instrumentations (e.g., PrismaInstrumentation)
Additional telemetry metadata Language/locale for telemetry
Project name for telemetry grouping
Framework name (e.g., “express”, “fastify”)
An initialized III SDK instance
Example
Connection Management
getConnectionState()
Get the current connection state.
Current connection state: 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'failed'
onConnectionStateChange()
Register a callback to be notified of connection state changes.
callback (state: IIIConnectionState) => void
required
Function called when connection state changes
Function to unregister the callback
Example: Connection State Handling
Lifecycle Management
shutdown()
Gracefully shutdown the SDK, cleaning up all resources.
This method:
Stops all metrics reporting
Flushes and shuts down OpenTelemetry
Rejects all pending invocations
Closes the WebSocket connection
Clears all callbacks
Example: Graceful Shutdown
Engine Queries
listFunctions()
List all functions registered across the III network.
Array of registered function information Show FunctionInfo properties
listWorkers()
List all workers connected to the engine.
Array of connected worker information Show WorkerInfo properties
Runtime identifier (e.g., “node”)
Worker status: 'connected' | 'available' | 'busy' | 'disconnected'
Number of functions registered by this worker
Number of currently executing invocations
Example: Service Discovery