shrub/pkg/arvo/sys/vane/loch.hoon

132 lines
2.8 KiB
Plaintext
Raw Normal View History

2023-02-09 22:05:23 +03:00
:: %loch
!:
!? 164
::
=, loch
|= our=ship
=> |%
+$ move [p=duct q=(wite note gift)]
+$ note :: out request $->
2023-02-15 22:26:38 +03:00
$% $: %g :: to %gall
$>(%deal task:gall) :: full transmission
== ::
== ::
2023-02-09 22:05:23 +03:00
::
+$ sign
$% [%loch $>(%read gift)] :: read
==
::
+$ loch-state
$: %0
unix-duct=duct
2023-02-16 00:35:09 +03:00
devices=(map @tas device)
commands=(list cmd)
2023-02-09 22:05:23 +03:00
==
::
2023-02-16 00:35:09 +03:00
+$ cmd [cmd=@tas =wut dev=@tas =duct]
::
+$ device [name=@tas status=@ reg=(unit @tas)]
2023-02-09 22:05:23 +03:00
--
::
=>
~% %loch ..part ~
|%
++ per-event
=| moves=(list move)
|= [[now=@da =duct] state=loch-state]
::
|%
++ this .
:: %entry-points
::
:: +crud: handle failure of previous arvo event
::
2023-02-15 22:26:38 +03:00
++ crud [moves state]
2023-02-09 22:05:23 +03:00
:: +read: give back
::
++ read [moves state]
:: +trim: in response to memory pressue
::
++ trim [moves state]
:: +vega: learn of a kernel upgrade
::
++ vega [moves state]
:: %utilities
::
::+|
::
++ event-core .
--
--
::
=| loch-state
=* state -
|= [now=@da eny=@uvJ rof=roof]
=* loch-gate .
^?
|%
:: +call: handle a +task:loch request
::
2023-02-15 22:26:38 +03:00
++ call
2023-02-09 22:05:23 +03:00
|= $: hen=duct
dud=(unit goof)
wrapped-task=(hobo task)
==
^- [(list move) _loch-gate]
::
=/ =task ((harden task) wrapped-task)
~& > ["loch call task:" task]
~& > :^ "loch"
["unix duct" unix-duct:loch-gate]
["devices" devices:loch-gate]
["commands" commands:loch-gate]
2023-02-15 22:26:38 +03:00
::?^ dud
::~|(%loch-call-dud (mean tang.u.dud))
2023-02-16 00:35:09 +03:00
?+ -.task [~ loch-gate]
%born :: When born you need to wipe your current state
:- ~
loch-gate(unix-duct hen, commands [~], devices ~)
::
2023-02-16 00:35:09 +03:00
%read :: When you read you need to save the command and the wire to return the results
=/ =param param:task
~& >> ['param' param]
:- ~[[unix-duct.state %give [%read param]]]
loch-gate
::
%devs
=/ dev +.task
~& > dev
2023-02-16 00:35:09 +03:00
:- ~
%_ loch-gate
devices (~(put by devices) name.dev [name.dev stat.dev ~])
==
2023-02-15 22:26:38 +03:00
==
2023-02-09 22:05:23 +03:00
:: +load: migrate an old state to a new loch version
::
++ load
|= old=loch-state
^+ loch-gate
2023-02-15 22:26:38 +03:00
~& >> "loch load:"
2023-02-09 22:05:23 +03:00
loch-gate(state old)
:: +scry: view state
::
++ scry
^- roon
|= [lyc=gang car=term bem=beam]
^- (unit (unit cage))
2023-02-15 22:26:38 +03:00
~& >> "loch scry:"
~
2023-02-09 22:05:23 +03:00
::
2023-02-15 22:26:38 +03:00
++ stay
~& >> "loch stay:"
state
2023-02-09 22:05:23 +03:00
++ take
|= [tea=wire hen=duct dud=(unit goof) hin=sign]
^- [(list move) _loch-gate]
?^ dud
~|(%loch-take-dud (mean tang.u.dud))
::
2023-02-15 22:26:38 +03:00
~& >> "loch take:"
2023-02-09 22:05:23 +03:00
[~ loch-gate]
--