通知管理服务,负责列出已启用的通知渠道和手动发送测试通知。系统事件(订单支付、开通完成、工单分配等)自动广播到所有启用的通知渠道。
| RPC | 描述 | 权限 |
| ListNotifiers | 列出所有通知渠道(含支持的事件类型) | admin |
| SendNotification | 手动发送测试通知 | admin |
列出所有已启用的 Notifier 类型插件接口实例,含健康状态和支持的事件类型。
无字段。
| 字段 | 类型 | 编号 | 描述 |
| notifiers | repeated NotifierInfo | 1 | 通知渠道列表 |
| 字段 | 类型 | 编号 | 描述 |
| channel_id | string | 1 | 接口实例 ID(UUID) |
| channel_name | string | 2 | 渠道显示名称 |
| supported_events | repeated string | 3 | 支持的事件类型列表(如 ["order_paid","order_provisioned"]) |
| is_healthy | bool | 4 | 是否健康 |
grpcurl -plaintext -H "authorization: Bearer <token>" \
-d '{}' \
localhost:50051 rustbill.notification.NotificationService/ListNotifiers
const resp = await api.listNotifiers({});
// resp.notifiers → [{ channel_id, channel_name, supported_events, is_healthy }]
手动发送测试通知到指定渠道或全部渠道。选择部分渠道时在其他客户端注册的回调等。
系统事件通知由服务端自动广播,无需手动调用此 RPC。
| 字段 | 类型 | 编号 | 必填 | 描述 |
| event_type | string | 1 | 是 | 事件类型(如 "order_paid", "test") |
| title | string | 2 | 是 | 通知标题 |
| body | string | 3 | 是 | 通知正文 |
| recipient | string | 4 | 是 | 接收者(如邮箱地址,为空时使用渠道默认接收者) |
| metadata | map<string,string> | 5 | 否 | 附加元数据 |
| channel_ids | repeated string | 6 | 否 | 目标渠道 ID 列表(空=全部渠道) |
| 字段 | 类型 | 编号 | 描述 |
| results | repeated NotificationResult | 1 | 各渠道发送结果 |
| 字段 | 类型 | 编号 | 描述 |
| channel_id | string | 1 | 渠道 ID |
| success | bool | 2 | 是否发送成功 |
| error_message | string | 3 | 错误信息(失败时) |
| 错误 | 说明 |
| InvalidArgument | event_type 或 title 为空 |
| PermissionDenied | 非 admin 用户 |
grpcurl -plaintext -H "authorization: Bearer <token>" \
-d '{"event_type":"test","title":"测试通知","body":"这是一条测试消息","recipient":"[email protected]","metadata":{},"channel_ids":[]}' \
localhost:50051 rustbill.notification.NotificationService/SendNotification
const resp = await api.sendNotification({
event_type: "test",
title: "测试通知",
body: "这是一条测试消息",
recipient: "[email protected]",
metadata: {},
channel_ids: []
});
// resp.results → [{ channel_id, success, error_message }]
以下事件会触发系统自动广播通知到所有已启用的通知渠道:
| 事件类型 | 触发时机 | 接收者 |
order_paid | 订单支付成功 | 客户邮箱 + 管理员通知邮箱 |
order_provisioned | 资源开通完成 | 客户邮箱 |
order_cancelled | 订单取消(含退款) | 客户邮箱 |
ticket_assigned | 工单分配处理人 | 新旧处理人 |
ticket_replied | 工单有新的公开回复 | 工单创建者 |