mirror of
https://github.com/urbit/shrub.git
synced 2024-12-01 14:42:02 +03:00
adds poke/peer acknowledgement and %quit support to lib/tapp
This commit is contained in:
parent
31593f6800
commit
2dd739334d
@ -134,9 +134,13 @@
|
||||
(pure:m top-comments)
|
||||
::
|
||||
++ handle-take
|
||||
|= sign:tapp
|
||||
|= =sign:tapp
|
||||
=/ m tapp-async
|
||||
^- form:m
|
||||
:: ignore %poke/peer acknowledgements
|
||||
::
|
||||
?. ?=(%wake -.sign)
|
||||
(pure:m top-comments)
|
||||
;< =state bind:m (handle-poke %noun 'fetch')
|
||||
=. top-comments state
|
||||
(pure:m top-comments)
|
||||
|
@ -238,7 +238,8 @@
|
||||
|= [[her=ship app=term] =poke-data]
|
||||
=/ m (async ,~)
|
||||
^- form:m
|
||||
(send-effect %poke / [her app] poke-data)
|
||||
=/ =wire /(scot %p her)/[app]
|
||||
(send-effect %poke wire [her app] poke-data)
|
||||
::
|
||||
++ peer-app
|
||||
|= [[her=ship app=term] =path]
|
||||
|
@ -98,7 +98,20 @@
|
||||
|=(* (async-fail:async-lib %no-diff-handler ~))
|
||||
::
|
||||
++ handle-take
|
||||
|=(* (async-fail:async-lib %no-take-handler ~))
|
||||
=> |%
|
||||
++ print-if-error
|
||||
|= [msg=tape error=(unit tang)]
|
||||
%. *form:tapp-async
|
||||
?~ error
|
||||
same
|
||||
(slog [leaf+msg u.error])
|
||||
--
|
||||
|= =sign
|
||||
?: ?=(%coup -.sign)
|
||||
(print-if-error "poke failed" error.sign)
|
||||
?: ?=(%reap -.sign)
|
||||
(print-if-error "peer {<path.sign>} failed" error.sign)
|
||||
(async-fail:async-lib %no-take-handler ~)
|
||||
--
|
||||
::
|
||||
:: The form of a tapp that only handles pokes
|
||||
@ -234,6 +247,24 @@
|
||||
`this-tapp
|
||||
start-async
|
||||
::
|
||||
:: Receive acknowledgement of outgoing poke
|
||||
::
|
||||
:: XX these can be distinguished by dock, but, without a wire or
|
||||
:: some alternative, that's not very useful if you poke the same
|
||||
:: dock multiple times. %poke wires are not currently exposed ...
|
||||
:: Wat do?
|
||||
::
|
||||
++ coup
|
||||
|= [=wire error=(unit tang)]
|
||||
^- (quip move _this-tapp)
|
||||
?> ?=([@ @ *] wire)
|
||||
=/ her (slav %p i.wire)
|
||||
=* app i.t.wire
|
||||
=. waiting (~(put to waiting) %take %coup [her app] error)
|
||||
?^ active
|
||||
`this-tapp
|
||||
start-async
|
||||
::
|
||||
:: Read from tapp state
|
||||
::
|
||||
++ peek
|
||||
@ -260,6 +291,34 @@
|
||||
`this-tapp
|
||||
start-async
|
||||
::
|
||||
:: Receive (involuntary) unsubscription
|
||||
::
|
||||
++ quit
|
||||
|= =wire
|
||||
^- (quip move _this-tapp)
|
||||
?> ?=([@ @ *] wire)
|
||||
=/ her (slav %p i.wire)
|
||||
=* app i.t.wire
|
||||
=* pax t.t.wire
|
||||
=. waiting (~(put to waiting) %take %quit [her app] pax)
|
||||
?^ active
|
||||
`this-tapp
|
||||
start-async
|
||||
::
|
||||
:: Receive acknowledgement of outgoing subscription request
|
||||
::
|
||||
++ reap
|
||||
|= [=wire error=(unit tang)]
|
||||
^- (quip move _this-tapp)
|
||||
?> ?=([@ @ *] wire)
|
||||
=/ her (slav %p i.wire)
|
||||
=* app i.t.wire
|
||||
=* pax t.t.wire
|
||||
=. waiting (~(put to waiting) %take %reap [her app] pax error)
|
||||
?^ active
|
||||
`this-tapp
|
||||
start-async
|
||||
::
|
||||
:: Receive subscription response
|
||||
::
|
||||
++ diff
|
||||
@ -288,6 +347,8 @@
|
||||
^- (quip move _this-tapp)
|
||||
(oob-fail-async %failed-sigh tang)
|
||||
::
|
||||
:: Pass timer to async, or fail
|
||||
::
|
||||
++ wake-note
|
||||
|= [=wire error=(unit tang)]
|
||||
^- (quip move _this-tapp)
|
||||
@ -295,6 +356,8 @@
|
||||
(oob-fail-async %timer-fire-failed u.error)
|
||||
(take-async bowl `[wire %wake ~])
|
||||
::
|
||||
:: Enqueue timer transaction
|
||||
::
|
||||
++ wake-effect
|
||||
|= [=wire error=(unit tang)]
|
||||
^- (quip move _this-tapp)
|
||||
|
@ -18,7 +18,10 @@
|
||||
::
|
||||
+$ sign
|
||||
$% [%sigh =httr:eyre]
|
||||
[%wake (unit tang)]
|
||||
[%wake error=(unit tang)]
|
||||
[%coup =dock error=(unit tang)]
|
||||
[%quit =dock =path]
|
||||
[%reap =dock =path error=(unit tang)]
|
||||
==
|
||||
::
|
||||
:: Outstanding contracts
|
||||
|
Loading…
Reference in New Issue
Block a user