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

143 lines
3.2 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)]
2023-02-24 01:16:58 +03:00
+$ note ~ :: out request $->
::$% $: %g :: to %gall
::$>(%deal task:gall) :: full transmission
::== ::
::== ::
2023-02-09 22:05:23 +03:00
::
2023-02-24 01:16:58 +03:00
+$ sign ~
::$% [%loch $>(%red gift)] :: read
:: [%loch $>(%read gift)]
::==
2023-02-09 22:05:23 +03:00
::
+$ loch-state
$: %0
unix-duct=duct
2023-02-16 00:35:09 +03:00
devices=(map @tas device)
commands=(list cmd)
2023-02-22 00:44:00 +03:00
pathing=(map dev duct)
2023-02-09 22:05:23 +03:00
==
::
2023-02-22 00:44:00 +03:00
+$ cmd [cmd=@tas =wut =dev =duct]
2023-02-16 00:35:09 +03:00
::
+$ 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)
2023-02-22 00:44:00 +03:00
~& > ["1 loch call task:" task]
~& >> ["2 loch hen:" hen]
::~& >> :* "loch"
::["unix duct" unix-duct:loch-gate]
::["devices" devices:loch-gate]
::["commands" commands:loch-gate]
::["pathing" pathing:loch-gate]
::==
2023-02-15 22:26:38 +03:00
::?^ dud
::~|(%loch-call-dud (mean tang.u.dud))
2023-02-22 00:44:00 +03:00
?+ -.task [~ loch-gate]
2023-02-16 00:35:09 +03:00
%born :: When born you need to wipe your current state
:- ~
2023-02-22 00:44:00 +03:00
loch-gate(unix-duct hen, commands [~], devices ~, pathing ~)
::
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
2023-02-22 00:44:00 +03:00
::~& >> ['param' param]
:- ~[[unix-duct.state %give [%read param]]]
2023-02-22 00:44:00 +03:00
%_ loch-gate
pathing (~(put by pathing) dev.param hen)
==
::
%devs
=/ dev +.task
2023-02-16 00:35:09 +03:00
:- ~
%_ loch-gate
devices (~(put by devices) name.dev [name.dev stat.dev ~])
==
2023-02-22 00:44:00 +03:00
::
2023-02-24 01:16:58 +03:00
%seen
2023-02-22 00:44:00 +03:00
=/ duct (~(get by pathing) dev.task)
2023-02-24 01:16:58 +03:00
:- ~[[+.duct %give %seen dev.task dat.task]]
2023-02-22 00:44:00 +03:00
loch-gate
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]
--