Installation
Initialization
register_worker
Register the worker with a iii instance, returns a connected worker client. Blocks until the WebSocket connection is established and ready. Signature- Parameters
- Example
Methods
register_trigger
Bind a trigger configuration to a registered function. Signature- Parameters
- Example
A
RegisterTriggerInput or dict with type, function_id, and optional config.register_function
Register a function with the engine. Pass a handler for local execution, or anHttpInvocationConfig
for HTTP-invoked functions (Lambda, Cloudflare Workers, etc.).
Handlers can be synchronous or asynchronous. Sync handlers are
automatically wrapped with run_in_executor so they do not
block the event loop. Each handler receives a data argument
containing the trigger payload, and may optionally accept a second
metadata argument carrying per-invocation metadata (e.g.
def handler(data, metadata=None) or def handler(data, *, metadata=None)). Metadata is only forwarded to handlers that
declare a parameter literally named metadata, so existing
handlers, including ones with unrelated extra parameters,
*args, or **kwargs, keep working unchanged.
request_format and response_format are auto-extracted
from the handler’s type hints when omitted or passed as None
(the default). To opt out of auto-extraction, pass an explicit
schema (RegisterFunctionFormat or dict). This behavior
is Python-specific; the Node SDK relies on explicit schemas because
TypeScript types are erased at runtime.
Signature
- Parameters
- Example
Unique string identifier for the function.
A callable handler or
HttpInvocationConfig. Callable handlers receive data (the trigger payload) as the first argument and may optionally accept metadata (per-invocation metadata) as a second argument; they may return a value.Human-readable description of what the function does.
Arbitrary metadata attached to the function.
Schema describing expected input. When
None (default), auto-extracted from the handler’s first-parameter type hint. Pass an explicit schema to override; there is no way to register with no schema when the handler is typed.Schema describing expected output. Same auto-extraction semantics as
request_format.trigger
Invoke a remote function. The routing behavior and return type depend on theaction field:
- No action: synchronous, waits for the function to return.
TriggerAction.Enqueue(...): async via named queue, returns a dict withmessageReceiptId.TriggerAction.Void(): fire-and-forget, returnsNone.
- Parameters
- Example
A
TriggerRequest or dict with function_id, payload, and optional action / timeout_ms.register_trigger_type
Register a custom trigger type with the engine. Returns a :class:TriggerTypeRef handle with register_trigger
and register_function methods.
Signature
- Parameters
- Example
unregister_trigger_type
Unregister a previously registered trigger type. Signature- Parameters
- Example
A
RegisterTriggerTypeInput or dict with id and optional description.connect_async
Connect to the III Engine via WebSocket. Initializes OpenTelemetry (if configured), attaches the event loop, and establishes the WebSocket connection. This is called automatically during construction; use it only if you need to reconnect manually from an async context. Signatureget_connection_state
Return the current WebSocket connection state. SignatureExample
shutdown
Gracefully shut down the client, releasing all resources. Cancels any pending reconnection attempts, rejects all in-flight invocations with an error, closes the WebSocket connection, and stops the background event-loop thread. After this call the instance must not be reused. SignatureExample
shutdown_async
Gracefully shut down the client, releasing all resources. Cancels any pending reconnection attempts, rejects all in-flight invocations with an error, closes the WebSocket connection, and stops the background event-loop thread. After this call the instance must not be reused. SignatureExample
trigger_async
Invoke a remote function. The routing behavior and return type depend on theaction field:
- No action: synchronous, waits for the function to return.
TriggerAction.Enqueue(...): async via named queue, returns a dict withmessageReceiptId.TriggerAction.Void(): fire-and-forget, returnsNone.
- Parameters
- Example
A
TriggerRequest or dict with function_id, payload, and optional action / timeout_ms.Types
iii
EnqueueResult · InitOptions · MiddlewareFunctionInput · StreamRequest · StreamResponse · TelemetryOptions · TriggerAction · TriggerActionEnqueue
EnqueueResult
Result returned when a function is invoked withTriggerAction.Enqueue.
InitOptions
Configuration options passed toregister_worker.
MiddlewareFunctionInput
Input passed to the RBAC middleware function on every function invocation through the RBAC port.StreamRequest
Incoming streaming request received by a function registered with a stream trigger.StreamResponse
Streaming response built on top of a ChannelWriter.TelemetryOptions
Worker metadata reported to the engine (language, framework, project).TriggerAction
Factory for creating trigger actions used withtrigger().
TriggerActionEnqueue
Routes the invocation through a named queue for async processing. Requires a queue worker in the project. Runiii worker add queue.
Without it the trigger rejects with enqueue_error (no queue provider).
iii.channel
Channel · ChannelReader · ChannelWriter · StreamChannelRef
Channel
A streaming channel pair for worker-to-worker data transfer.ChannelReader
WebSocket-backed reader for streaming binary data and text messages.ChannelWriter
WebSocket-backed writer for streaming binary data and text messages.StreamChannelRef
Reference to a streaming channel for worker-to-worker data transfer.iii.engine
EngineFunctions · EngineTriggers
EngineFunctions
Engine function ids for internal operations (parity with the Node SDK).EngineTriggers
Engine trigger ids (parity with the Node SDK).iii.errors
InvocationError
InvocationError
Raised when an invocation dispatched by the SDK fails. Inspecterr.code to react to a specific category (e.g.
'FORBIDDEN' for RBAC denials, 'TIMEOUT' for timeouts). Catch
this class to handle every rejection. except Exception continues to
work because InvocationError inherits from Exception.
Attributes are read-only after construction. stacktrace is the
engine-side trace when the remote handler raised; it may include
internal file paths and should not be surfaced to end users. str(err)
intentionally never includes the stacktrace.
iii.protocol
MessageType · RegisterFunctionFormat · RegisterFunctionInput · RegisterFunctionMessage · RegisterTriggerInput · RegisterTriggerMessage · RegisterTriggerTypeInput · RegisterTriggerTypeMessage · TriggerRequest
MessageType
Message types for iii communication.RegisterFunctionFormat
Format definition for function parameters.RegisterFunctionInput
Input for registering a function, matches Node.js RegisterFunctionInput.RegisterFunctionMessage
RegisterTriggerInput
Input for registering a trigger (matches Node SDK’s RegisterTriggerInput).RegisterTriggerMessage
RegisterTriggerTypeInput
Input for registering a trigger type.RegisterTriggerTypeMessage
TriggerRequest
Request object fortrigger().
iii.runtime
FunctionRef · TriggerTypeRef
FunctionRef
Reference to a registered function, allowing programmatic unregistration.TriggerTypeRef
Typed handle returned by :meth:iii.III.register_trigger_type.
Type parameters:
C: configuration type for :meth:register_triggerR: call-request type for :meth:register_function
iii.state
IState · StateDeleteInput · StateDeleteResult · StateEventData · StateEventType · StateGetInput · StateListInput · StateSetInput · StateSetResult · StateUpdateInput · StateUpdateResult
IState
Abstract interface for state management operations.StateDeleteInput
Input for deleting a state value.StateDeleteResult
Result of a state delete operation.StateEventData
Payload for state change events.StateEventType
Types of state change events.StateGetInput
Input for retrieving a state value.StateListInput
Input for listing all values in a state scope.StateSetInput
Input for setting a state value.StateSetResult
Result of a state set operation.StateUpdateInput
Input for atomically updating a state value.StateUpdateResult
Result of a state update operation.iii.stream
IStream · StreamDeleteInput · StreamDeleteResult · StreamGetInput · StreamListGroupsInput · StreamListInput · StreamSetInput · StreamSetResult · StreamUpdateInput · StreamUpdateResult
IStream
Abstract interface for stream operations.StreamDeleteInput
Input for stream delete operation.StreamDeleteResult
Result of stream delete operation.StreamGetInput
Input for stream get operation.StreamListGroupsInput
Input for stream list groups operation.StreamListInput
Input for stream list operation.StreamSetInput
Input for stream set operation.StreamSetResult
Result of stream set operation.StreamUpdateInput
Input for stream update operation.StreamUpdateResult
Result of stream update operation.iii.trigger
Trigger · TriggerActionVoid · TriggerConfig · TriggerHandler