iii-stream
它能做什么
在命名的流中存储实时数据,并把变化推送给已连接的客户端,使实时功能无需轮询。它适用于维护现有 iii 系统的开发者,因为该工作进程已被弃用并将被移除。
适用场景
- ✓当你正在维护一个已经使用流的现有 iii 系统的时候。
- ✓当你需要一个向订阅者推送更新的实时数据流的时候。
- ✓当你计划把流式功能迁移到更新方案的时候。
技能链接
https://github.com/iii-hq/iii/blob/main/engine/src/workers/stream/skills/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请给我看现有的 iii 流如何向已订阅的客户端推送更新,以便我规划迁移。”
每周 5 个新技能,1 分钟读完。
工作原理
该工作进程以三层结构存储条目,并把每次变化发送给订阅该流的客户端。客户端加入时可以运行授权检查。目前其行为保持不变,迁移指南已在其文档中链接。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
iii-stream
Deprecated. iii-stream is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is unchanged for now. Migration guide: https://iii.dev/docs/upgrading/migrate-from-streams
The iii-stream worker stores real-time data as a three-level hierarchy (stream_name -> group_id -> item_id) in the configured adapter and exposes two surfaces: a CRUD-shaped stream::* function namespace for reading and writing items, and reactive trigger types (stream, stream:join, stream:leave) that fire on data changes and on WebSocket subscriber connect/disconnect. Reactive backends are built by binding handlers to those triggers rather than by polling.
A write persists the new value, dispatches matching stream triggers on a spawned task (fire-and-forget, so the originating call returns before handlers finish), and broadcasts the change to every WebSocket client subscribed to that (stream_name, group_id). The stream:join trigger doubles as an authorization gate: returning { unauthorized: true } from its handler rejects the subscription before any data flows. Pair it with the worker's auth_function config, which runs once per WebSocket handshake and stamps a context value into every join/leave event.
Adapters: kv (default; in-memory or file-backed; single-instance only, no cross-process fan-out) or redis (required for multi-instance fleets that need real-time fan-out). Browser and client subscriptions use the Browser SDK (iii-browser-sdk), which subscribes to stream changes over a single engine WebSocket. Connecting directly to the stream port (ws://host:{port}/stream/{stream_name}/{group_id}) is deprecated in favor of the Browser SDK.
When to Use
- A stream change should kick off side effects elsewhere (derived projections, audit logs, notifications) without polling
stream::list. - You need to gate WebSocket subscriptions server-side instead of trusting client-side filtering.
- You want server-side reactions to subscriber connect/disconnect for presence counters, per-subscription rate buckets, or audit trails.
- An item needs atomic partial updates that concurrent writers would otherwise race on.
Boundaries
- Not a general key/value store — data is stream-shaped (
stream_name/group_id/item_id). Use the standalonestateworker for scope/key values. - The default
kvadapter does not fan out across processes; multi-instance fleets that need real-time broadcast must useredis. stream:leaveis not an authorization gate — the subscription is already gone by the time it fires, and its return value is ignored.- Trigger handlers run after the originating write returns; a handler failure neither rolls back the write nor surfaces to the caller.
Functions
stream::set— persist an item and broadcast a create/update event; returns the previous value alongside the new one.stream::update— atomically apply orderedset/merge/increment/decrement/append/removeops to an existing item.stream::delete— remove an item and broadcast a delete event carrying the removed value.stream::send— broadcast a transient event to a group's subscribers without persisting it (typing indicators, cursor positions).stream::get— read one item by its full(stream, group, item)triple.stream::list— enumerate items in a group.stream::list_groups— enumerate groups in a stream.stream::list_all— enumerate every stream's metadata.
Reactive triggers
Bind a stream-family trigger when a function should run automatically on stream activity — without polling stream::list. Three types cover two concerns: stream reacts to data changes, while stream:join / stream:leave react to WebSocket subscriber lifecycle.
Reach for them when:
- A
set/update/delete/sendshould drive a projection, audit log, or downstream notification. - Subscriptions need server-side authorization (
stream:join) or paired setup/teardown (stream:join+stream:leave).
If you only need the current value on demand, call stream::get instead of binding a trigger.
How to bind
- Register a handler:
iii.registerFunction('presence::on-change', handler). - Register the trigger:
iii.registerTrigger({
type: 'stream',
function_id: 'presence::on-change',
config: {
stream_name: 'presence', // required for `stream`; the worker indexes triggers by it.
group_id: 'room-1', // optional. Empty/omitte
常见问题
这个工作进程仍受支持吗?
它已被弃用,并将在即将发布的版本中移除,不过目前其行为未变。
迁移指南在哪里?
该工作进程的文档链接到 iii 网站上的一份迁移指南。
它能跨多个服务器进程运行吗?
只有使用 Redis 适配器时可以,因为默认存储不会在进程之间共享更新。
详情
作者的原始描述
Durable real-time streams with a CRUD function surface plus reactive triggers that fire on item changes and WebSocket subscriber lifecycle — reach for it to build live backends without polling. iii-stream is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is unchanged for now. Migration guide: https://iii.dev/docs/upgrading/migrate-from-streams
repo: iii-hq/iii
热度
- GitHub 星标
- 19k
- 排名
- #10489
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
iii-sandbox
19k帮你的智能体在临时隔离的虚拟机中安全运行不可信或由 AI 生成的代码,完成后将其丢弃。
configuration
19k让你的智能体设置一个共享的命名配置值注册表,并按模式进行检查,使工作进程可以读取并响应变化。
iii
19k教你的智能体了解 iii 工作进程如何运作,使其可以先检查已有的功能,再构建新的工作进程来添加能力。
iii-observability
19k帮你的智能体使用 OpenTelemetry 为 iii 引擎添加追踪、结构化日志、指标和告警,让你看清系统正在发生什么。