mirror of
https://github.com/urbit/shrub.git
synced 2024-12-14 11:08:45 +03:00
Don't send null ducts in subscriptions to clay.
We were previously sending ~ as the duct to clay for our %multi subscriptions. This caused arvo to drop events. Keep track of the last duct which issued a subscription on a disc and cancel old subscriptions if the duct changed.
This commit is contained in:
parent
ddf0334b15
commit
df008e95ae
@ -1040,8 +1040,6 @@
|
||||
moves=~
|
||||
==
|
||||
::
|
||||
:: CORRECTNESS QUESTION: Are we supposed to cancel on the first duct?
|
||||
::
|
||||
=^ results4 ford-gate
|
||||
%- test-ford-call :*
|
||||
ford-gate
|
||||
@ -1051,7 +1049,9 @@
|
||||
call-args=[duct=~[/second] type=~ %kill ~nul]
|
||||
::
|
||||
^= moves
|
||||
:~ :* duct=~[/second] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
:: the cancellation should go on the duct that made it: /first
|
||||
::
|
||||
:~ :* duct=~[/first] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk ~
|
||||
== == ==
|
||||
::
|
||||
@ -2108,7 +2108,7 @@
|
||||
scry=scry
|
||||
::
|
||||
^= call-args
|
||||
:* wire=/~nul/clay-sub/~nul/desk duct=~
|
||||
:* wire=/~nul/clay-sub/~nul/desk duct=~[/call]
|
||||
^= wrapped-sign ^- (hypo sign:ford-gate) :- *type
|
||||
[%c %wris [%da ~1234.5.7] (sy [%x /timer]~)]
|
||||
==
|
||||
@ -2137,7 +2137,7 @@
|
||||
::
|
||||
%- expect-eq !>
|
||||
:_ i.t.moves
|
||||
:* duct=~ %pass wire=/~nul/clay-sub/~nul/desk
|
||||
:* duct=~[/call] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk
|
||||
`[%mult [%da ~1234.5.7] (sy [%x /timer] ~)]
|
||||
== ==
|
||||
@ -2824,7 +2824,7 @@
|
||||
scry=scry
|
||||
::
|
||||
^= take-args
|
||||
:* wire=/~nul/clay-sub/~nul/desk duct=~
|
||||
:* wire=/~nul/clay-sub/~nul/desk duct=~[/post-a]
|
||||
^= wrapped-sign ^- (hypo sign:ford-gate) :- *type
|
||||
[%c %wris [%da ~1234.5.8] (sy [%x /posts/a]~)]
|
||||
==
|
||||
@ -3056,6 +3056,9 @@
|
||||
:~ :* duct=~[/alts] %give %made ~1234.5.7 %complete
|
||||
%success %alts %success %scry %noun scry-type 'scry-two'
|
||||
==
|
||||
:* duct=~[/same] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk ~
|
||||
==
|
||||
:* duct=~[/alts] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk
|
||||
`[%mult [%da ~1234.5.7] (sy [%x /scry/two] [%x /scry/one] ~)]
|
||||
@ -3100,7 +3103,10 @@
|
||||
call-args=[duct=~[/same] type=~ %kill ~nul]
|
||||
::
|
||||
^= moves
|
||||
:~ :* duct=~[/same] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
:~ :* duct=~[/alts] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk ~
|
||||
==
|
||||
:* duct=~[/same] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk
|
||||
`[%mult [%da ~1234.5.8] (sy [%x /scry/one] ~)]
|
||||
== == ==
|
||||
@ -3114,7 +3120,7 @@
|
||||
call-args=[duct=~[/alts] type=~ %kill ~nul]
|
||||
::
|
||||
^= moves
|
||||
:~ :* duct=~[/alts] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
:~ :* duct=~[/same] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk ~
|
||||
== == ==
|
||||
::
|
||||
@ -3198,6 +3204,9 @@
|
||||
:~ :* duct=~[/second] %give %made ~1234.5.7 %complete
|
||||
%success %alts %success %scry %noun scry-type 'scry-two'
|
||||
==
|
||||
:* duct=~[/first] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk ~
|
||||
==
|
||||
:* duct=~[/second] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk ~ %mult [%da ~1234.5.7]
|
||||
(sy [%x /scry/one] [%x /scry/two] [%x /scry/three] ~)
|
||||
@ -3258,7 +3267,10 @@
|
||||
call-args=[duct=~[/first] type=~ %kill ~nul]
|
||||
::
|
||||
^= moves
|
||||
:~ :* duct=~[/first] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
:~ :* duct=~[/second] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk ~
|
||||
==
|
||||
:* duct=~[/first] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk ~ %mult [%da ~1234.5.9]
|
||||
(sy [%x /scry/three] ~)
|
||||
== == ==
|
||||
@ -3272,7 +3284,7 @@
|
||||
call-args=[duct=~[/second] type=~ %kill ~nul]
|
||||
::
|
||||
^= moves
|
||||
:~ :* duct=~[/second] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
:~ :* duct=~[/first] %pass wire=/~nul/clay-sub/~nul/desk
|
||||
%c %warp [~nul ~nul] %desk ~
|
||||
== == ==
|
||||
::
|
||||
@ -3590,7 +3602,7 @@
|
||||
now=~1234.5.8
|
||||
scry=scry-is-forbidden
|
||||
::
|
||||
call-args=[duct=~ type=~ %wipe ~]
|
||||
call-args=[duct=~[/wipe] type=~ %wipe ~]
|
||||
moves=~
|
||||
==
|
||||
::
|
||||
@ -3601,7 +3613,7 @@
|
||||
scry=scry
|
||||
::
|
||||
^= take-args
|
||||
:* wire=/~nul/clay-sub/~nul/desk duct=~
|
||||
:* wire=/~nul/clay-sub/~nul/desk duct=~[/post-a]
|
||||
^= wrapped-sign ^- (hypo sign:ford-gate) :- *type
|
||||
[%c %wris [%da ~1234.5.9] (sy [%x /posts/a]~)]
|
||||
==
|
||||
|
@ -194,7 +194,7 @@
|
||||
latest-by-disc=(map disc @da)
|
||||
:: clay-subscriptions: ducts we'll use to cancel existing clay requests
|
||||
::
|
||||
clay-subscriptions=(set disc)
|
||||
clay-subscriptions=(map disc duct)
|
||||
:: resource-updates: all clay updates we need to know about
|
||||
::
|
||||
:: resource-updates stores all Clay changes at dates that
|
||||
@ -1009,7 +1009,7 @@
|
||||
=/ =disc [ship desk]
|
||||
:: delete the now-dead clay subscription
|
||||
::
|
||||
=. clay-subscriptions.state (~(del in clay-subscriptions.state) disc)
|
||||
=. clay-subscriptions.state (~(del by clay-subscriptions.state) disc)
|
||||
::
|
||||
=/ resources=(list resource)
|
||||
%+ turn ~(tap in care-paths)
|
||||
@ -4872,27 +4872,25 @@
|
||||
::
|
||||
=/ resources=(set resource)
|
||||
(fall (~(get by resources-by-disc.state) disc) ~)
|
||||
:: subscription-duct: if any, the duct that previously made a subscription
|
||||
::
|
||||
=/ subscription-duct
|
||||
(~(get by original-clay-subscriptions) disc)
|
||||
:: if no resources on :disc, don't make a new clay subscription
|
||||
::
|
||||
?~ resources
|
||||
:: cancel clay subscriptions when we don't have any resources left
|
||||
:: no resources, no subscriptions, no action.
|
||||
::
|
||||
?: (~(has in original-clay-subscriptions) disc)
|
||||
=+ [their desk]=disc
|
||||
=/ =note
|
||||
:^ %c %warp sock=[our their]
|
||||
^- riff:clay
|
||||
[desk ~]
|
||||
::
|
||||
=. moves :_ moves
|
||||
^- move
|
||||
[duct [%pass wire=(clay-sub-wire disc) note]]
|
||||
::
|
||||
=. clay-subscriptions.state (~(del in clay-subscriptions.state) disc)
|
||||
::
|
||||
=. latest-by-disc.state (~(del by latest-by-disc.state) disc)
|
||||
::
|
||||
?~ subscription-duct
|
||||
$(discs t.discs)
|
||||
:: cancel any clay subscriptions since we don't have any resources left
|
||||
::
|
||||
=. moves :_ moves
|
||||
(clay-cancel-subscription-move u.subscription-duct disc)
|
||||
::
|
||||
=. clay-subscriptions.state (~(del by clay-subscriptions.state) disc)
|
||||
::
|
||||
=. latest-by-disc.state (~(del by latest-by-disc.state) disc)
|
||||
::
|
||||
$(discs t.discs)
|
||||
:: prevent thrashing; don't unsubscribe then immediately resubscribe
|
||||
@ -4902,43 +4900,26 @@
|
||||
:: canceling and then resubscribing might cause the foreign ship
|
||||
:: to send the response twice, which would be extra network traffic.
|
||||
::
|
||||
?: ?& (~(has in original-clay-subscriptions) disc)
|
||||
?: ?& (~(has by original-clay-subscriptions) disc)
|
||||
::
|
||||
(~(has in clay-subscriptions.state) disc)
|
||||
(~(has by clay-subscriptions.state) disc)
|
||||
::
|
||||
.= (~(get by original-resources-by-disc) disc)
|
||||
(~(get by resources-by-disc.state) disc)
|
||||
==
|
||||
::
|
||||
$(discs t.discs)
|
||||
:: request-contents: the set of [care path]s to subscribe to in clay
|
||||
:: if we had a previous subscription on a different duct, send a cancel.
|
||||
::
|
||||
=/ request-contents=(set [care:clay path])
|
||||
%- sy ^- (list [care:clay path])
|
||||
%+ murn ~(tap in `(set resource)`resources)
|
||||
|= =resource ^- (unit [care:clay path])
|
||||
::
|
||||
?. ?=(%c -.resource) ~
|
||||
::
|
||||
`[care.resource (flop spur.rail.resource)]
|
||||
:: if :request-contents is `~`, this code is incorrect
|
||||
::
|
||||
?< ?=(~ request-contents)
|
||||
:: their: requestee +ship
|
||||
::
|
||||
=+ [their desk]=disc
|
||||
=/ latest-date (~(got by latest-by-disc.state) disc)
|
||||
::
|
||||
=/ =note
|
||||
:^ %c %warp sock=[our their]
|
||||
^- riff:clay
|
||||
[desk `[%mult case=[%da latest-date] request-contents]]
|
||||
=? moves &(?=(^ subscription-duct) !=(duct u.subscription-duct))
|
||||
:_ moves
|
||||
(clay-cancel-subscription-move u.subscription-duct disc)
|
||||
:: send a new clay request using the current duct
|
||||
::
|
||||
=. moves :_ moves
|
||||
^- move
|
||||
[duct [%pass wire=(clay-sub-wire disc) note]]
|
||||
(clay-add-subscription-move disc resources)
|
||||
::
|
||||
=. clay-subscriptions.state (~(put in clay-subscriptions.state) disc)
|
||||
=. clay-subscriptions.state (~(put by clay-subscriptions.state) disc duct)
|
||||
::
|
||||
$(discs t.discs)
|
||||
:: +cleanup: try to clean up a build and its sub-builds
|
||||
@ -5051,6 +5032,49 @@
|
||||
=+ [their desk]=disc
|
||||
::
|
||||
/(scot %p our)/clay-sub/(scot %p their)/[desk]
|
||||
:: +clay-add-subscription-move: subscribes to :resources
|
||||
::
|
||||
++ clay-add-subscription-move
|
||||
|= [=disc resources=(set resource)]
|
||||
^- move
|
||||
:: request-contents: the set of [care path]s to subscribe to in clay
|
||||
::
|
||||
=/ request-contents=(set [care:clay path])
|
||||
%- sy ^- (list [care:clay path])
|
||||
%+ murn ~(tap in `(set resource)`resources)
|
||||
|= =resource ^- (unit [care:clay path])
|
||||
::
|
||||
?. ?=(%c -.resource) ~
|
||||
::
|
||||
`[care.resource (flop spur.rail.resource)]
|
||||
:: if :request-contents is `~`, this code is incorrect
|
||||
::
|
||||
?< ?=(~ request-contents)
|
||||
:: their: requestee +ship
|
||||
::
|
||||
=+ [their desk]=disc
|
||||
=/ latest-date (~(got by latest-by-disc.state) disc)
|
||||
::
|
||||
=/ =note
|
||||
:^ %c %warp sock=[our their]
|
||||
^- riff:clay
|
||||
[desk `[%mult case=[%da latest-date] request-contents]]
|
||||
::
|
||||
[duct [%pass wire=(clay-sub-wire disc) note]]
|
||||
|
||||
:: +clay-cancel-subscription-move: builds a cancel move
|
||||
::
|
||||
++ clay-cancel-subscription-move
|
||||
|= [old-duct=^duct =disc]
|
||||
^- move
|
||||
::
|
||||
=+ [their desk]=disc
|
||||
=/ =note
|
||||
:^ %c %warp sock=[our their]
|
||||
^- riff:clay
|
||||
[desk ~]
|
||||
::
|
||||
[old-duct [%pass wire=(clay-sub-wire disc) note]]
|
||||
--
|
||||
--
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user