/connect 的帧环(C# Keelson.Agui 的 AguiReplay;keel agui/replay.ss,designs/agui-connect.md N2):按线程一只有界缓冲,
只装这一轮从 RUN_STARTED 起编好的帧(字节)。是传输缓冲不是会话存储:跑完留 keep-ms 给迟到的 /connect,
新一轮开始就覆盖。
为什么不直接用 clj-agent-agui 的事件存储(:event-store / subscribe :since):那是按条数有界、跨 run 连续的会话环,
没有 C# 契约要的三样 —— 按字节封顶且超了整轮作废(truncated ⇒ /connect 回空流,⛔ 不发半截)、跑完后按时长保留、
线程数 LRU 驱逐。那三样是小东西,就在这里补上。
超 max-bytes ⇒ 这一轮标 :truncated、清空、不再攒。线程数超 max-threads ⇒ 驱逐没在跑的里最久没碰的(全在跑时宁可多一条)。
时间由调用方传进来(毫秒)。线程安全(一把锁)。:enabled? false ⇒ 空转:不建条目、不进帧、open-cursor 恒 nil
(⇒ /connect 对任何线程回 200 空流)。
`/connect` 的帧环(C# Keelson.Agui 的 AguiReplay;keel agui/replay.ss,designs/agui-connect.md N2):按线程一只有界缓冲, 只装**这一轮**从 RUN_STARTED 起编好的帧(字节)。是**传输**缓冲不是会话存储:跑完留 keep-ms 给迟到的 `/connect`, 新一轮开始就覆盖。 为什么不直接用 clj-agent-agui 的事件存储(`:event-store` / `subscribe :since`):那是按**条数**有界、跨 run 连续的会话环, 没有 C# 契约要的三样 —— 按**字节**封顶且超了整轮作废(truncated ⇒ `/connect` 回空流,⛔ 不发半截)、跑完后按时长保留、 线程数 LRU 驱逐。那三样是小东西,就在这里补上。 超 max-bytes ⇒ 这一轮标 :truncated、清空、不再攒。线程数超 max-threads ⇒ 驱逐**没在跑的**里最久没碰的(全在跑时宁可多一条)。 时间由调用方传进来(毫秒)。线程安全(一把锁)。`:enabled? false` ⇒ 空转:不建条目、不进帧、`open-cursor` 恒 nil (⇒ `/connect` 对任何线程回 200 空流)。
(append! r tid frames)攒。回 true;超限 ⇒ 标 truncated、清空、回 false。没有这条线程 / 已 truncated / 环没开 ⇒ false。
攒。回 true;超限 ⇒ 标 truncated、清空、回 false。没有这条线程 / 已 truncated / 环没开 ⇒ false。
(begin! r tid now)新一轮:旧的(不管什么状态)整个换掉;线程数超了驱逐没在跑的。
新一轮:旧的(不管什么状态)整个换掉;线程数超了驱逐没在跑的。
(done? r {:keys [entry generation index]})那一轮已收尾且帧都读完了(或 truncated)⇒ 订阅者关流。
那一轮已收尾且帧都读完了(或 truncated)⇒ 订阅者关流。
(ensure! r tid now)有这一轮的环就保留(⛔ 不覆盖在跑的那轮);没有就开一条。外部事件源写帧用它。
有这一轮的环就保留(⛔ 不覆盖在跑的那轮);没有就开一条。外部事件源写帧用它。
(expire! r now)清掉跑完(或 truncated)且过了 keep 的;在跑的不动。回清掉几条。
清掉跑完(或 truncated)且过了 keep 的;在跑的不动。回清掉几条。
(finish! r tid now)终端事件到了(或 run 被按停):开始计 keep。truncated 的照旧 truncated。
终端事件到了(或 run 被按停):开始计 keep。truncated 的照旧 truncated。
(open-cursor r tid now)从 0 起的读位置;没有可重放的 / truncated ⇒ nil(/connect 回 200 空流)。
从 0 起的读位置;没有可重放的 / truncated ⇒ nil(`/connect` 回 200 空流)。
(replay)(replay
{:keys [max-bytes keep-ms max-threads enabled?]
:or
{max-bytes (* 4 1024 1024) keep-ms 300000 max-threads 256 enabled? true}}):max-bytes(缺省 4 MiB):keep-ms(缺省 5 分钟):max-threads(缺省 256):enabled?(缺省 true)。负数 ⇒ IllegalArgumentException。
`:max-bytes`(缺省 4 MiB)`:keep-ms`(缺省 5 分钟)`:max-threads`(缺省 256)`:enabled?`(缺省 true)。负数 ⇒ IllegalArgumentException。
(state r tid):running / :finished / :truncated;没有 ⇒ nil。
`:running` / `:finished` / `:truncated`;没有 ⇒ nil。
(take! r {:keys [entry generation index]})从上次读到的位置起取帧;空 = 暂时没有。中途 truncated 了 ⇒ 空且 done?。
从上次读到的位置起取帧;空 = 暂时没有。中途 truncated 了 ⇒ 空且 `done?`。
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |