iii-workflow-orchestration
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWorkflow Orchestration & Durable Execution
工作流编排与持久化执行
Comparable to: Temporal, Airflow, Inngest
同类工具:Temporal、Airflow、Inngest
Key Concepts
核心概念
Use the concepts below when they fit the task. Not every workflow needs every durability or tracking mechanism shown here.
- Each pipeline step is a registered function chained via named queues with config-driven retries
- Step progress is tracked in shared state and broadcast via streams
- A cron trigger handles scheduled maintenance (e.g. stale order cleanup)
- Queue behavior (retries, backoff, concurrency, FIFO) is defined per queue in
iii-config.yaml
当任务需要时使用以下概念。并非每个工作流都需要此处展示的所有持久化或跟踪机制。
- 每个管道步骤都是一个已注册的函数,通过命名队列进行链式调用,重试由配置驱动
- 步骤进度在共享状态中跟踪,并通过流进行广播
- Cron触发器处理定时维护(如过期订单清理)
- 队列行为(重试、退避、并发、FIFO)在中按队列定义
iii-config.yaml
Architecture
架构
text
HTTP (create order)
→ Enqueue(order-validate) → validate
→ Enqueue(order-payment) → charge-payment
→ Enqueue(order-ship) → ship
→ publish(order.fulfilled)
Cron (hourly) → cleanup-stale
Queue configs (iii-config.yaml):
order-validate: max_retries: 2
order-payment: max_retries: 5, type: fifo, concurrency: 2
order-ship: max_retries: 3text
HTTP (创建订单)
→ Enqueue(order-validate) → 验证
→ Enqueue(order-payment) → 支付扣款
→ Enqueue(order-ship) → 发货
→ publish(order.fulfilled)
Cron (每小时) → 清理过期订单
队列配置 (iii-config.yaml):
order-validate: max_retries: 2
order-payment: max_retries: 5, type: fifo, concurrency: 2
order-ship: max_retries: 3iii Primitives Used
使用的iii原语
| Primitive | Purpose |
|---|---|
| Initialize the worker and connect to iii |
| Define each pipeline step |
| Durable step chaining via named queues |
| Track step progress |
| Fire-and-forget stream events and publish |
| Scheduled maintenance |
| Entry point |
| 原语 | 用途 |
|---|---|
| 初始化worker并连接到iii引擎 |
| 定义每个管道步骤 |
| 通过命名队列实现持久化步骤链式调用 |
| 跟踪步骤进度 |
| 触发即忘的流事件并发布 |
| 定时维护 |
| 入口点 |
Reference Implementation
参考实现
See ../references/workflow-orchestration.js for the full working example — an order fulfillment pipeline
with validate → charge → ship steps, retry configuration, stream-based progress tracking,
and hourly stale-order cleanup.
查看../references/workflow-orchestration.js获取完整的工作示例——一个包含验证→扣款→发货步骤、重试配置、基于流的进度跟踪以及每小时过期订单清理的订单履约管道。
Common Patterns
常见模式
Code using this pattern commonly includes, when relevant:
- — worker initialization
registerWorker(url, { workerName }) - — durable step chaining via named queues
trigger({ function_id, payload, action: TriggerAction.Enqueue({ queue }) }) - — step progress tracking
trigger({ function_id: 'state::update', payload: { scope, key, ops } }) - Named queues with a comment referencing for retry/concurrency settings
iii-config.yaml - — structured logging per step
const logger = new Logger() - Each step as its own with a single responsibility
registerFunction - — completion broadcast
trigger({ function_id: 'publish', payload, action: TriggerAction.Void() })
使用此模式的代码通常会包含以下相关内容:
- —— worker初始化
registerWorker(url, { workerName }) - —— 通过命名队列实现持久化步骤链式调用
trigger({ function_id, payload, action: TriggerAction.Enqueue({ queue }) }) - —— 步骤进度跟踪
trigger({ function_id: 'state::update', payload: { scope, key, ops } }) - 带有注释的命名队列,注释引用中的重试/并发设置
iii-config.yaml - —— 每个步骤的结构化日志
const logger = new Logger() - 每个步骤都是独立的,单一职责
registerFunction - —— 完成事件广播
trigger({ function_id: 'publish', payload, action: TriggerAction.Void() })
Adapting This Pattern
适配此模式
Use the adaptations below when they apply to the task.
- Each step should do one thing and enqueue the next function on success
- Define separate named queues in when steps need different retry/concurrency settings
iii-config.yaml - Capture enqueue receipts () for observability and DLQ correlation when needed
messageReceiptId - The helper pattern (state update + stream event) is reusable for any pipeline
trackStep - Failed jobs exhaust retries and move to a DLQ — see the dead-letter-queues HOWTO
- DLQ support for named queues is provided by the Builtin and RabbitMQ adapters (Redis is pub/sub only)
- Cron expressions use 7-position numeric format: (every hour)
0 0 * * * * *
当以下情况适用于任务时,使用相应的适配方式:
- 每个步骤应只完成一件事,并在成功时将下一个函数加入队列
- 当步骤需要不同的重试/并发设置时,在中定义单独的命名队列
iii-config.yaml - 必要时捕获入队回执(),用于可观测性和DLQ关联
messageReceiptId - 助手模式(状态更新+流事件)可复用至任何管道
trackStep - 失败任务耗尽重试次数后会转移到DLQ——请查看死信队列操作指南
- 内置适配器和RabbitMQ适配器支持命名队列的DLQ功能(Redis仅支持发布/订阅)
- Cron表达式使用7位数字格式:(每小时执行一次)
0 0 * * * * *
Engine Configuration
引擎配置
Named queues for pipeline steps are declared in iii-config.yaml under with per-queue retry, concurrency, and FIFO settings. See ../references/iii-config.yaml for the full annotated config reference.
queue_configs管道步骤的命名队列在iii-config.yaml的下声明,包含每个队列的重试、并发和FIFO设置。查看../references/iii-config.yaml获取完整的带注释配置参考。
queue_configsPattern Boundaries
模式边界
- If the task is "model HTTP endpoints as HTTP-invoked functions" (including
registerFunctionarrays iterated into registration), prefer{ path, id }.iii-http-invoked-functions - Stay with when durable step sequencing, queue retries/backoff, and workflow progress tracking are the primary concerns.
iii-workflow-orchestration
- 如果任务是“将HTTP端点建模为HTTP调用的函数”(包括迭代
registerFunction数组进行注册),请优先使用{ path, id }。iii-http-invoked-functions - 当持久化步骤排序、队列重试/退避和工作流进度跟踪是主要需求时,使用。
iii-workflow-orchestration
When to Use
使用场景
- Use this skill when the task is primarily about in the iii engine.
iii-workflow-orchestration - Triggers when the request directly asks for this pattern or an equivalent implementation.
- 当任务主要涉及在iii引擎中进行时,使用此技能。
iii-workflow-orchestration - 当请求直接要求此模式或等效实现时触发。
Boundaries
边界限制
- Never use this skill as a generic fallback for unrelated tasks.
- You must not apply this skill when a more specific iii skill is a better fit.
- Always verify environment and safety constraints before applying examples from this skill.
- 切勿将此技能用作无关任务的通用 fallback。
- 当更特定的iii技能更合适时,不得应用此技能。
- 在应用此技能中的示例之前,始终验证环境和安全约束。