Files
orbit/examples/result-inbox/README.md

22 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 独立 MySQL Inbox 示例
这是接收方应用示例,使用正式 Orbit Go SDK 和自己的 MySQL 数据库。核心 SDK 不依赖数据库驱动;示例是独立 Go module,通过本地 replace 引用 SDK。
完整前置、调用、输出、故障处理与事务边界见 [运行手册](../../docs/examples/result-inbox.md)。
从本目录执行:
```sh
GOWORK=off go run ./cmd/receiver init
GOWORK=off go run ./cmd/receiver demo
GOWORK=off go run ./cmd/receiver consume
```
- `init`:使用 ORBIT_RECEIVER_DSN 初始化专用空数据库,不自动升级已有表。
- `demo`:使用事件凭据和隔离队列产生结果,验证两次业务处理只推进一次,再确认并暂停本次订阅。
- `consume`:消费 ORBIT_SUBSCRIPTION_ID 指定的已有订阅,RECEIVER_NAME 在重启和多实例之间保持固定。
[业务事务](internal/inbox/store.go) 同时写入 [Inbox 与视图](internal/inbox/schema.sql),两张表、17个中文字段注释、零外键。模型见 [model.go](internal/inbox/model.go)。
根目录 `make test/vet/build` 包含本模块;`make integration` 创建独立临时数据库,运行数据库、COMMIT响应丢失、真实消费者强杀回归和demo,结束清理自建容器。未设置集成环境时普通go test跳过外部测试,不表示这些故障已经验证。