Overview
Functions are the core building blocks of the III SDK. They are named, remotely-invocable units of work that can be called by any worker connected to the Engine. Functions support typed inputs/outputs, automatic tracing, and both synchronous and asynchronous invocation patterns.Function Registration
Local Functions
Register a function with a handler that executes in your worker:Function IDs use
:: as namespace separator (e.g., service::resource::action). This convention helps organize functions and avoid naming conflicts.Function Naming Best Practices
1
Use Namespaces
Prefix functions with service name:
2
Action-Oriented Names
Use verbs that describe the operation:
3
Reserved Prefixes
Avoid these Engine-reserved prefixes:
engine::*- Internal Engine functionsstream::*- Stream API functionslog::*- Logging functions
HTTP Functions
Register external HTTP endpoints (Lambda, Cloudflare Workers, etc.) as functions:- Bearer Token
- API Key Header
- HMAC Signature
HTTP functions are invoked by the Engine, not the worker. The Engine handles authentication, retries, and timeout enforcement.
Function Handlers
Handler Signature
Handlers are async functions that receive input and return output:Context Access
Access request context (logger, trace) usinggetContext():
packages/node/iii/src/context.ts for implementation.
Automatic Tracing
All function handlers are automatically wrapped in OpenTelemetry spans:Function Invocation
Synchronous Call (await response)
Wait for function result with optional timeout:Asynchronous Call (fire-and-forget)
Invoke without waiting for response:Invocation Errors
Functions can fail in several ways:1
Function Not Found
2
Handler Exception
3
Timeout
Rejected locally by SDK after timeout expires:
Function Discovery
List Available Functions
Query all registered functions across workers:React to Function Changes
Subscribe to function availability events:Unregistering Functions
Functions can be unregistered dynamically:Channel Arguments
Functions can accept streaming channels as arguments:Multi-Language Examples
- TypeScript
- Python
- Rust
Next Steps
Triggers
Learn how to invoke functions from HTTP, events, and schedules
Channels
Stream data between functions with channels