urbit/pkg/arvo/sys/vane/khan.hoon

94 lines
2.1 KiB
Plaintext
Raw Normal View History

2022-01-21 21:48:05 +03:00
:: %khan, thread runner
!:
!? 164
::
|= our=ship
=> |%
+$ move [p=duct q=(wite note gift:khan)]
+$ note :: out request $->
2022-01-26 02:37:48 +03:00
$~ [%g %deal *sock *term *deal:gall]
2022-01-22 04:46:59 +03:00
$% $: %g :: to %gall
$>(%deal task:gall) :: full transmission
== == ::
2022-01-21 21:48:05 +03:00
+$ sign :: in response $<-
!!
+$ khan-state
$: %0
unix-duct=duct
==
--
2022-01-22 04:46:59 +03:00
=>
|%
++ start-spider
2022-01-26 02:37:48 +03:00
|= [our=@p =cage]
^- note
[%g %deal [our our] %spider %poke cage]
2022-01-22 04:46:59 +03:00
++ watch-spider
2022-01-26 02:37:48 +03:00
|= [our=@p =path]
^- note
[%g %deal [our our] %spider %watch path]
2022-01-22 04:46:59 +03:00
--
2022-01-21 21:48:05 +03:00
=| khan-state
=* state -
|= [now=@da eny=@uvJ rof=roof]
=* khan-gate .
^?
|%
:: +call: handle a +task:khan request
::
++ call
|= $: hen=duct
dud=(unit goof)
wrapped-task=(hobo task:khan)
==
^- [(list move) _khan-gate]
::
=/ =task:khan ((harden task:khan) wrapped-task)
2022-01-22 01:09:01 +03:00
?- -.task
%vega
[~ khan-gate]
%trim
2022-01-22 04:46:59 +03:00
[~ khan-gate]
%done
2022-01-22 01:09:01 +03:00
[~ khan-gate]
%born
[~ khan-gate(unix-duct hen)]
%fyrd
2022-01-22 04:46:59 +03:00
=/ rid=@ta (rear (head hen))
=/ tid=@ta
(cat 3 'khan-fyrd--' rid)
2022-01-26 02:37:48 +03:00
=/ args
:* ~ `tid [our q.beak.task %da now] name.task
!>(data.task)
2022-01-22 04:46:59 +03:00
==
2022-01-26 02:37:48 +03:00
=/ start-moves=(list move)
%+ turn
:~ (watch-spider p.beak.task name.task /thread-result/[tid])
(start-spider p.beak.task %noun !>(args))
==
|=(=note ^-(move [hen %pass //g note]))
2022-01-22 04:46:59 +03:00
[start-moves khan-gate]
2022-01-22 01:09:01 +03:00
==
2022-01-21 21:48:05 +03:00
:: +load: migrate an old state to a new khan version
::
++ load
|= old=khan-state
^+ khan-gate
khan-gate(state old)
:: +scry: view khan state
::
++ scry
^- roon
|= [lyc=gang car=term bem=beam]
^- (unit (unit cage))
~
++ stay state
++ take
|= [tea=wire hen=duct dud=(unit goof) hin=sign]
^- [(list move) _khan-gate]
?^ dud
~|(%khan-take-dud (mean tang.u.dud))
2022-01-22 01:09:01 +03:00
:: switch on type of thing you get back, update state
2022-01-21 21:48:05 +03:00
[~ khan-gate]
--