Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)19k · #10491

iii-architecture-patterns

Skill này làm gì

Chỉ cách kết hợp các khối xây dựng iii thành thiết kế backend lớn hơn, như quy trình từng bước, backend phản ứng và hệ thống hướng sự kiện. Dành cho lập trình viên thiết kế các hệ thống lớn hơn một hàm đơn lẻ.

Khi nào nên dùng

  • ✓Khi bạn cần một công việc nhiều bước với thử lại và theo dõi từng bước.
  • ✓Khi bạn muốn các view và cache luôn đồng bộ với dữ liệu thay đổi.
  • ✓Khi nhiều agent AI cần chuyển công việc cho nhau.

Liên kết skill

https://github.com/iii-hq/iii/blob/main/skills/iii-architecture-patterns/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/iii-hq/iii/blob/main/skills/iii-architecture-patterns/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thiết kế một quy trình bền vững cho việc xử lý đơn hàng của chúng tôi, có thử lại và hàng đợi thư chết cho các lỗi.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill chọn một mẫu phù hợp với yêu cầu, như quy trình bền vững để thử lại hoặc observer để phản ứng với kết quả của một hàm khác. Sau đó nó xây thiết kế từ các hàm, trigger, hàng đợi và trạng thái.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Architecture Patterns

Use this skill when the task is larger than one function or trigger. Pick the pattern from the requirement, then implement it with Function, Trigger, Worker, observers, state, queues, streams, and pub/sub.

Pattern Map

Requirement Pattern iii shape
Sequential work with retries, DLQ, step tracking Durable workflow Functions chained through named queues, progress in state
Keep views, metrics, cache, or clients in sync Reactive backend State triggers plus stream/pubsub side effects
React to another function's calls, results, or failures without changing it Observer side effect iii.observe({ function_id, on, filters }, target) (iii-observe)
Specialized AI agents hand work to each other Agentic backend One function per agent, queue handoffs, shared state
Commands publish events and projections update independently Event-driven CQRS Command functions, event log in state, subscribe triggers
Pure, traceable composition Effect pipeline Small functions composed synchronously with trigger()
Webhook/cron automation chains Low-code automation Trigger, transform, action nodes chained by enqueue

Durable Workflow

Use named queues when steps need different retry, FIFO, or concurrency policy.

TypeScript

import { registerWorker, TriggerAction } from "iii-sdk";

const iii = registerWorker("ws://localhost:49134", { workerName: "order-workflow" });

async function track(orderId: string, step: string, status: string) {
  await iii.trigger({
    function_id: "state::update",
    payload: { scope: "orders", key: orderId, ops: [{ type: "merge", path: ["steps"], value: { [step]: status } }] },
  });
}

iii.registerFunction("orders::validate", async (order) => {
  await track(order.id, "validate", "done");
  return iii.trigger({
    function_id: "orders::charge",
    payload: order,
    action: TriggerAction.Enqueue({ queue: "order-payment" }),
  });
});

iii.registerFunction("orders::charge", async (order) => {
  await track(order.id, "payment", "done");
  return iii.trigger({
    function_id: "orders::ship",
    payload: order,
    action: TriggerAction.Enqueue({ queue: "order-ship" }),
  });
});

Python

from iii import register_worker

iii = register_worker("ws://localhost:49134")

def track(order_id, step, status):
    iii.trigger({
        "function_id": "state::update",
        "payload": {
            "scope": "orders",
            "key": order_id,
            "ops": [{"type": "merge", "path": ["steps"], "value": {step: status}}],
        },
    })

def validate(order):
    track(order["id"], "validate", "done")
    return iii.trigger({
        "function_id": "orders::charge",
        "payload": order,
        "action": {"type": "enqueue", "queue": "order-payment"},
    })

iii.register_function("orders::validate", validate)

Rust

use iii_sdk::TriggerAction;
use iii_sdk::protocol::TriggerRequest;
use serde_json::json;

async fn enqueue_charge(iii: iii_sdk::IIIClient, order: serde_json::Value) -> Result<serde_json::Value, iii_sdk::Error> {
    iii.trigger(TriggerRequest {
        function_id: "state::update".into(),
        payload: json!({
            "scope": "orders",
            "key": order["id"],
            "ops": [{ "type": "merge", "path": ["steps"], "value": { "validate": "done" } }]
        }),
        action: None,
        timeout_ms: None,
    }).await?;

    iii.trigger(TriggerRequest {
        function_id: "orders::charge".into(),
        payload: order,
        action: Some(TriggerAction::Enqueue { queue: "order-payment".into() }),
        timeout_ms: None,
    }).await
}

Reactive Backend

Use state triggers when the requirement says "after create/update, do this", "avoid polling", or "push live updates".

iii.registerFunction("todos::on-change", async (event) => {
  await iii.trigger({
    function_id: "stream::send",
    payload: { stream_name: "todos-live", group_id: "default", data: event.new_value },
    action: TriggerAction.Void(),
  });
});

iii.registerTrigger({
  type: "state",
  function_id: "todos::on-change",
  config: { scope: "todos" },
});

Observer Side Effects

Use an observer when "after X runs (or fails), also do Y" and X should not know about Y: audit logs, alerts, projections, cache invalidation. Every function is observable since 0.25, and an observer failure never affects the observed cal

Câu hỏi thường gặp

Hàng đợi thư chết ở đây là gì?

Đó là hàng đợi giữ các công việc thất bại sau khi đã thử lại, để có thể xem xét sau.

Nó có sửa các hàm hiện có không?

Một số mẫu, như observer, phản ứng với lệnh gọi của hàm khác mà không thay đổi hàm đó.

Những mẫu nào được bao phủ?

Quy trình bền vững, backend phản ứng, observer, pipeline agent, thiết kế hướng sự kiện, pipeline hiệu ứng và chuỗi tự động hóa.

Chi tiết

Mô tả gốc của tác giả

Use when composing iii primitives into backend architectures: durable workflows, reactive backends, observer side effects, agentic pipelines, event-driven CQRS, effect pipelines, and trigger-transform-action automation.

repo: iii-hq/iii

Độ phổ biến

Sao GitHub
19k
Vị trí xếp hạng
#10491
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự