Skip to content

NApp 可观测 ​

NApp 自身的运行事件使用 napp: 命名空间,并通过 app.bus 发布。

js
const listenerId = app.bus.listen("napp:internal:*:*", (payload, hitKey) => {
  console.log(hitKey, payload)
})

INFO

NApp的总线同时还被内置NACP、NACT共同使用。

本章只阐述NApp自身的事件

NotifyStream 溢出 ​

text
napp:internal:notify:warning

Event Request 或 Subscribe 的迭代器来不及消费消息,且缓冲数量超过 queueMaxCount 时,NApp 会丢弃最旧的一条消息并发布该事件。

js
app.bus.listen(
  "napp:internal:notify:warning",
  ({ appId, subId, targetSubName, dropped, reason }) => {
    console.warn(appId, subId, targetSubName, dropped, reason)
  },
)
字段说明
appId该消息流对应的远端 NApp
subIdSubscribe 的订阅 ID;Event Request 中等于 reqId
targetSubName对应的远端 EventBus 事件名
dropped被丢弃的完整 NotifyMessage
reason固定为 "stream-overflow"

WARNING

只有迭代器使用 NotifyStream 缓冲队列。回调没有该队列,因此回调本身不会触发此溢出事件。

事件表 ​

key触发时机
napp:internal:notify:warningNotifyStream 溢出并丢弃最旧消息时

Released under the MIT License.