@fayz-ai/插件通知
将事实转换成消息的引擎:模板、队列、重试、分解 和接受者选择的频道.
状态 : β – 发动机完整并被犬科链(schema, queue, dedupe, ext-out, ext)分级. 前1.0:还没有管理员表面,API在1.0之前可能改变.
安装
npm install @fayz-ai/plugin-notifications
import { createNotificationsPlugin } from '@fayz-ai/plugin-notifications'
export const plugins = [createNotificationsPlugin()]
createNotificationsPlugin 无屏幕挂载。 它所做的一切都可以从
SQL和它宣布的三项活动——这是有意的:a
无法发送的窗体就是这个引擎存在用来停止运输的.
为什么它存在
SDK有两端而不是中间 它拥有 事件 - 持久木材
及其消费者——它拥有 频道数字 : plugin-conversations 拥有
编号、交货和选择退出. public.notifications 是铃声
应用它永远不会离开它。 所以,"告诉客户 他们的订单已经准备好了" 没有地方
活下来.
Dunning、任命确认、订货准备、服务后调查和 营销运动是同一个引擎,有不同的模板. 这是 发动机.
飞来飞去
| 图表 | 它所持有的 |
|---|---|
plg_notifications_templates | 每个密钥、频道和地点 |
plg_notifications_preferences | 一个人希望如何得到帮助 |
plg_notifications_queue | 等待什么,去什么, 是什么被拒绝和为什么 |
plg_notifications_deliveries | 供应商说的话 |
plg_notifications_channels | 每个租户提供频道 |
三个变化者
- 没有模板,任何东西都不会离开.
notifications_enqueue拒绝按键 无法在写东西之前解决. - 淘汰是绝对否决被屏蔽的信息是一个有原因的ROW 完全没有结果的退出是无法区分的 引擎静静地停止工作.
- 恢复活动不会发出两次.
dedupe_key单个 房客,所以再审的送货 解决已经存在的信息.
用这个
-- write the template once
INSERT INTO public.plg_notifications_templates (tenant_id, key, channel, body, is_default)
VALUES (:tenant, 'order.completed', 'whatsapp', 'Oi {{customer_name}}, seu pedido {{order_number}} está pronto!', true);
-- everything else is a reaction: the order completes, the engine enqueues
SELECT public.consume_event_log(200); -- scheduled by pg_cron (PRD 10)
SELECT public.notifications_drain(100); -- its own job: the provider is outside
下水道是 单独 从 consume_event_log() 目标:
供应商在外,队列是我们的,所以一个供应商计时出局需要重试
在这里,永远不要挂起事件记录.