events +subscribe
PREREQUISITE: Read ../gws-shared/SKILL.md for auth, global flags, and security rules. If missing, run gws generate-skills to create it.
Subscribe to Workspace events and stream them as NDJSON
Usage
CODEBLOCK0
Flags
| Flag | Required | Default | Description |
|---|
| INLINECODE2 | — | — | Workspace resource URI (e.g., //chat.googleapis.com/spaces/SPACE_ID) |
| INLINECODE3 |
— | — | Comma-separated CloudEvents types to subscribe to |
|
--project | — | — | GCP project ID for Pub/Sub resources |
|
--subscription | — | — | Existing Pub/Sub subscription name (skip setup) |
|
--max-messages | — | 10 | Max messages per pull batch (default: 10) |
|
--poll-interval | — | 5 | Seconds between pulls (default: 5) |
|
--once | — | — | Pull once and exit |
|
--cleanup | — | — | Delete created Pub/Sub resources on exit |
|
--no-ack | — | — | Don't auto-acknowledge messages |
|
--output-dir | — | — | Write each event to a separate JSON file in this directory |
Examples
CODEBLOCK1
Tips
- - Without --cleanup, Pub/Sub resources persist for reconnection.
- Press Ctrl-C to stop gracefully.
[!CAUTION]
This is a write command — confirm with the user before executing.
See Also
技能名称: gws-events-subscribe
详细描述:
events +subscribe
前置条件: 阅读 ../gws-shared/SKILL.md 了解认证、全局标志和安全规则。若文件缺失,请运行 gws generate-skills 创建。
订阅工作空间事件并以NDJSON格式流式输出
用法
bash
gws events +subscribe
标志
| 标志 | 必需 | 默认值 | 描述 |
|---|
| --target | — | — | 工作空间资源URI(例如://chat.googleapis.com/spaces/SPACE_ID) |
| --event-types |
— | — | 要订阅的CloudEvents类型(逗号分隔) |
| --project | — | — | Pub/Sub资源的GCP项目ID |
| --subscription | — | — | 现有Pub/Sub订阅名称(跳过设置) |
| --max-messages | — | 10 | 每次拉取批次的最大消息数(默认:10) |
| --poll-interval | — | 5 | 拉取间隔秒数(默认:5) |
| --once | — | — | 仅拉取一次后退出 |
| --cleanup | — | — | 退出时删除已创建的Pub/Sub资源 |
| --no-ack | — | — | 不自动确认消息 |
| --output-dir | — | — | 将每个事件写入此目录下的独立JSON文件 |
示例
bash
gws events +subscribe --target //chat.googleapis.com/spaces/SPACE --event-types google.workspace.chat.message.v1.created --project my-project
gws events +subscribe --subscription projects/p/subscriptions/my-sub --once
gws events +subscribe ... --cleanup --output-dir ./events
提示
- - 不使用 --cleanup 时,Pub/Sub资源会保留以便重新连接。
- 按 Ctrl-C 可优雅停止。
[!CAUTION]
这是一个写入命令 — 执行前需与用户确认。
另请参阅