urbit/pkg/arvo/lib/aqua-vane-thread.hoon

64 lines
1.7 KiB
Plaintext
Raw Normal View History

2019-09-29 07:44:31 +03:00
/- spider, *aquarium
/+ ph-io, strandio
=, strand=strand:spider
2019-09-29 07:44:31 +03:00
|%
++ vane-handler
$_ ^|
2019-11-10 10:27:07 +03:00
|_ bowl:spider
2019-09-29 07:44:31 +03:00
++ handle-unix-effect
|~ [ship unix-effect]
2019-11-19 07:36:21 +03:00
*(quip card:agent:gall _^|(..handle-unix-effect))
2019-09-29 07:44:31 +03:00
::
++ handle-arvo-response
|~ [wire sign-arvo]
2019-11-19 07:36:21 +03:00
*(quip card:agent:gall _^|(..handle-unix-effect))
2019-09-29 07:44:31 +03:00
--
--
::
=; core
|= handler=vane-handler
^- thread:spider
2019-11-16 04:37:20 +03:00
|= vase
=/ m (strand ,vase)
2019-09-29 07:44:31 +03:00
^- form:m
;< ~ bind:m (watch-our:strandio /effects %aqua /effect)
;< ~ bind:m
%- (main-loop:strandio ,_handler)
:~ handle-unix-effect:core
handle-arvo-response:core
pure:(strand ,vane-handler)
==
(pure:m *vase)
2019-09-29 07:44:31 +03:00
::
|%
++ handle-unix-effect
|= handler=vane-handler
=/ m (strand ,vane-handler)
2019-09-29 07:44:31 +03:00
^- form:m
;< [her=ship =unix-effect] bind:m
((handle:strandio ,[ship unix-effect]) take-unix-effect:ph-io)
;< =bowl:spider bind:m get-bowl:strandio
2019-09-29 07:44:31 +03:00
=^ cards handler
(~(handle-unix-effect handler bowl) her unix-effect)
?~ cards
(pure:m handler)
:: send in next event to avoid inverting subscription flow. real
:: solution is probably for gall to drip subscription updates.
::
;< ~ bind:m (sleep:strandio ~s0)
;< ~ bind:m (send-raw-cards:strandio cards)
2019-09-29 07:44:31 +03:00
(pure:m handler)
::
++ handle-arvo-response
|= handler=vane-handler
=/ m (strand ,vane-handler)
2019-09-29 07:44:31 +03:00
^- form:m
;< [=wire =sign-arvo] bind:m
((handle:strandio ,[wire sign-arvo]) take-sign-arvo:strandio)
;< =bowl:spider bind:m get-bowl:strandio
2019-09-29 07:44:31 +03:00
=^ cards handler
(~(handle-arvo-response handler bowl) wire sign-arvo)
;< ~ bind:m (send-raw-cards:strandio cards)
2019-09-29 07:44:31 +03:00
(pure:m handler)
--