iii-functions-triggers
by @rohitg00
Registers functions and triggers on the iii engine across TypeScript, Python, and Rust. Use when creating workers, registering function handlers, binding tri...
clawhub install iii-functions-triggersπ About This Skill
name: iii-functions-and-triggers description: >- Registers functions and triggers on the iii engine across TypeScript, Python, and Rust. Use when creating workers, registering function handlers, binding triggers, or invoking functions across languages.
Functions & Triggers
Comparable to: Serverless function runtimes, Lambda, Cloud Functions
Key Concepts
Use the concepts below when they fit the task. Not every worker needs all of them.
trigger() regardless of language or worker locationschemars::JsonSchema) and Python (via type hints / Pydantic), or manually provided in Node.jsArchitecture
registerWorker() connects the worker to the engine, registerFunction defines handlers, registerTrigger binds event sources to those handlers, and the engine routes incoming events to the correct function. Functions can invoke other functions across workers and languages via trigger().
iii Primitives Used
| Primitive | Purpose |
| ------------------------------------------------------------ | ---------------------------------- |
| registerWorker(url, options?) | Connect worker to engine |
| registerFunction(id, handler) | Define a function handler |
| registerTrigger({ type, function_id, config, metadata? }) | Bind an event source to a function |
| trigger({ function_id, payload }) | Invoke a function synchronously |
| trigger({ ..., action: TriggerAction.Void() }) | Fire-and-forget invocation |
| trigger({ ..., action: TriggerAction.Enqueue({ queue }) }) | Durable async invocation via queue |
Reference Implementation
Each reference shows the same patterns (function registration, trigger binding, cross-function invocation) in its respective language.
Common Patterns
Code using this pattern commonly includes, when relevant:
registerWorker('ws://localhost:49134', { workerName: 'my-worker' }) β connect to the engineregisterFunction('namespace::name', async (input) => { ... }) β register a handlerregisterTrigger({ type: 'http', function_id, config: { api_path, http_method, middleware_function_ids? } }) β HTTP trigger (with optional middleware)registerTrigger({ type: 'durable:subscriber', function_id, config: { topic } }) β queue triggerregisterTrigger({ type: 'cron', function_id, config: { expression } }) β cron triggerregisterTrigger({ type: 'state', function_id, config: { scope, key } }) β state change triggerregisterTrigger({ type: 'stream', function_id, config: { stream } }) β stream triggerregisterTrigger({ type: 'subscribe', function_id, config: { topic } }) β pubsub subscriberregisterTrigger({ ..., metadata: { owner: 'team', priority: 'high' } }) β optional trigger metadataRequest/Response Format (Auto-Registration)
Functions can declare their input/output schemas for documentation and discovery:
schemars::JsonSchema on handler input/output types β RegisterFunction::new() auto-generates JSON Schema (Draft 7) from the typeregister_function() auto-extracts JSON Schema (Draft 2020-12)request_format / response_format manually in the registration message (e.g., via Zod's toJSONSchema())Adapting This Pattern
Use the adaptations below when they apply to the task.
namespace::name convention for function IDs to group related functionsapi_path and http_method in the trigger configTriggerAction.Enqueue({ queue }) instead of synchronous triggerTriggerAction.Void()Pattern Boundaries
iii-http-endpoints.iii-queue-processing.iii-cron-scheduling.iii-trigger-actions.iii-functions-and-triggers when the primary problem is registering functions, binding triggers, or cross-language invocation.When to Use
iii-functions-and-triggers in the iii engine.