mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-06 23:16:29 +03:00
eyre: refactor %delete to reuse timeout logic
Turns +on-channel-timeout into +discard-channel, which cleans up the entirety of the channel, based on its current state. This allows us to simplify the %delete channel request into a simple function call.
This commit is contained in:
parent
74b6f26a34
commit
68491420d2
@ -1486,50 +1486,10 @@
|
|||||||
$(requests t.requests)
|
$(requests t.requests)
|
||||||
::
|
::
|
||||||
%delete
|
%delete
|
||||||
=/ unitsession
|
=^ moves state
|
||||||
(~(get by session.channel-state.state) channel-id)
|
(discard-channel channel-id |)
|
||||||
::
|
|
||||||
?~ unitsession
|
|
||||||
$(requests t.requests)
|
|
||||||
::
|
|
||||||
=/ session u.unitsession
|
|
||||||
=. session.channel-state.state
|
|
||||||
(~(del by session.channel-state.state) channel-id)
|
|
||||||
::
|
|
||||||
=. gall-moves
|
=. gall-moves
|
||||||
%+ weld gall-moves
|
(weld gall-moves moves)
|
||||||
::
|
|
||||||
:: produce a list of moves which cancels every gall subscription
|
|
||||||
::
|
|
||||||
%+ turn ~(tap by subscriptions.session)
|
|
||||||
|= [channel-wire=wire ship=@p app=term =path duc=^duct]
|
|
||||||
^- move
|
|
||||||
::
|
|
||||||
[duc %pass channel-wire [%g %deal [our ship] app %leave ~]]
|
|
||||||
::
|
|
||||||
?: ?=([%& *] state.session)
|
|
||||||
=. gall-moves
|
|
||||||
:_ gall-moves
|
|
||||||
::
|
|
||||||
^- move
|
|
||||||
?> ?=([%& *] state.session)
|
|
||||||
:^ duct.p.state.session %pass /channel/timeout/[channel-id]
|
|
||||||
[%b %rest date.p.state.session]
|
|
||||||
::
|
|
||||||
$(requests t.requests)
|
|
||||||
::
|
|
||||||
?> ?=([%| *] state.session)
|
|
||||||
=. duct-to-key.channel-state.state
|
|
||||||
(~(del by duct-to-key.channel-state.state) p.state.session)
|
|
||||||
::
|
|
||||||
?~ heartbeat.session $(requests t.requests)
|
|
||||||
=. gall-moves
|
|
||||||
%+ snoc gall-moves
|
|
||||||
%^ cancel-heartbeat-move
|
|
||||||
channel-id
|
|
||||||
date.u.heartbeat.session
|
|
||||||
duct.u.heartbeat.session
|
|
||||||
::
|
|
||||||
$(requests t.requests)
|
$(requests t.requests)
|
||||||
::
|
::
|
||||||
==
|
==
|
||||||
@ -1671,10 +1631,12 @@
|
|||||||
channel(heartbeat (some [heartbeat-time duct]))
|
channel(heartbeat (some [heartbeat-time duct]))
|
||||||
==
|
==
|
||||||
(snoc http-moves (set-heartbeat-move channel-id heartbeat-time))
|
(snoc http-moves (set-heartbeat-move channel-id heartbeat-time))
|
||||||
:: +on-channel-timeout: we received a wake to clear an old session
|
:: +discard-channel: remove a channel from state
|
||||||
::
|
::
|
||||||
++ on-channel-timeout
|
:: cleans up state, timers, and gall subscriptions of the channel
|
||||||
|= channel-id=@t
|
::
|
||||||
|
++ discard-channel
|
||||||
|
|= [channel-id=@t expired=?]
|
||||||
^- [(list move) server-state]
|
^- [(list move) server-state]
|
||||||
::
|
::
|
||||||
=/ usession=(unit channel)
|
=/ usession=(unit channel)
|
||||||
@ -1686,6 +1648,10 @@
|
|||||||
:_ %_ state
|
:_ %_ state
|
||||||
session.channel-state
|
session.channel-state
|
||||||
(~(del by session.channel-state.state) channel-id)
|
(~(del by session.channel-state.state) channel-id)
|
||||||
|
::
|
||||||
|
duct-to-key.channel-state
|
||||||
|
?. ?=(%| -.state.session) duct-to-key.channel-state.state
|
||||||
|
(~(del by duct-to-key.channel-state.state) p.state.session)
|
||||||
==
|
==
|
||||||
=/ heartbeat-cancel=(list move)
|
=/ heartbeat-cancel=(list move)
|
||||||
?~ heartbeat.session ~
|
?~ heartbeat.session ~
|
||||||
@ -1694,7 +1660,13 @@
|
|||||||
date.u.heartbeat.session
|
date.u.heartbeat.session
|
||||||
duct.u.heartbeat.session
|
duct.u.heartbeat.session
|
||||||
==
|
==
|
||||||
|
=/ expire-cancel=(list move)
|
||||||
|
?: expired ~
|
||||||
|
?. ?=(%& -.state.session) ~
|
||||||
|
=, p.state.session
|
||||||
|
[(cancel-timeout-move channel-id date duct)]~
|
||||||
%+ weld heartbeat-cancel
|
%+ weld heartbeat-cancel
|
||||||
|
%+ weld expire-cancel
|
||||||
:: produce a list of moves which cancels every gall subscription
|
:: produce a list of moves which cancels every gall subscription
|
||||||
::
|
::
|
||||||
%+ turn ~(tap by subscriptions.session)
|
%+ turn ~(tap by subscriptions.session)
|
||||||
@ -2108,13 +2080,7 @@
|
|||||||
[(zing (flop moves)) http-server-gate]
|
[(zing (flop moves)) http-server-gate]
|
||||||
:: discard channel state, and cancel any active gall subscriptions
|
:: discard channel state, and cancel any active gall subscriptions
|
||||||
::
|
::
|
||||||
=^ mov server-state.ax (on-channel-timeout:by-channel channel-id)
|
=^ mov server-state.ax (discard-channel:by-channel channel-id |)
|
||||||
:: cancel channel timer
|
|
||||||
::
|
|
||||||
=/ channel (~(got by session.channel-state) channel-id)
|
|
||||||
=? mov ?=([%& *] state.channel)
|
|
||||||
:_ mov
|
|
||||||
(cancel-timeout-move:by-channel channel-id p.state.channel)
|
|
||||||
$(moves [mov moves], inactive t.inactive)
|
$(moves [mov moves], inactive t.inactive)
|
||||||
::
|
::
|
||||||
:: %vega: notifies us of a completed kernel upgrade
|
:: %vega: notifies us of a completed kernel upgrade
|
||||||
@ -2362,10 +2328,10 @@
|
|||||||
?> ?=([%b %wake *] sign)
|
?> ?=([%b %wake *] sign)
|
||||||
?^ error.sign
|
?^ error.sign
|
||||||
[[duct %slip %d %flog %crud %wake u.error.sign]~ http-server-gate]
|
[[duct %slip %d %flog %crud %wake u.error.sign]~ http-server-gate]
|
||||||
=/ on-channel-timeout
|
=/ discard-channel
|
||||||
on-channel-timeout:by-channel:(per-server-event event-args)
|
discard-channel:by-channel:(per-server-event event-args)
|
||||||
=^ moves server-state.ax
|
=^ moves server-state.ax
|
||||||
(on-channel-timeout i.t.t.wire)
|
(discard-channel i.t.t.wire &)
|
||||||
[moves http-server-gate]
|
[moves http-server-gate]
|
||||||
::
|
::
|
||||||
%heartbeat
|
%heartbeat
|
||||||
|
Loading…
Reference in New Issue
Block a user