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

135 lines
3.1 KiB
Plaintext
Raw Normal View History

2023-04-12 17:50:29 +03:00
:: %lick
!:
!? 164
::
=, lick
|= our=ship
=> |%
+$ move [p=duct q=(wite note gift)]
2023-04-20 19:25:57 +03:00
+$ note ~ :: out request $->
2023-04-12 17:50:29 +03:00
+$ sign ~
::
+$ lick-state
$: %0
unix-duct=_`duct`[//lick ~]
owners=(map name duct)
2023-04-12 17:50:29 +03:00
==
::
2023-04-27 22:29:54 +03:00
+$ name path
2023-04-12 17:50:29 +03:00
--
::
~% %lick ..part ~
::
=| lick-state
=* state -
|= [now=@da eny=@uvJ rof=roof]
=* lick-gate .
^?
|%
:: +register: Create a move to register an agent with vere
::
++ register
2023-04-20 19:25:57 +03:00
|= =name
2023-04-12 17:50:29 +03:00
^- move
2023-04-20 19:25:57 +03:00
[unix-duct.state %give [%spin name]]
2023-04-27 16:14:54 +03:00
:: +disconnect: Create Move to send a disconnect soak to am agent
::
++ disconnect
|= =name
^- move
=/ =duct (~(get by owners) name)
2023-04-27 16:14:54 +03:00
[+.duct %give [%soak name %disconnect ~]]
2023-04-12 17:50:29 +03:00
:: +call: handle a +task:lick request
::
++ call
|= $: hen=duct
dud=(unit goof)
wrapped-task=(hobo task)
==
^- [(list move) _lick-gate]
::
=/ =task ((harden task) wrapped-task)
?+ -.task [~ lick-gate]
2023-04-27 16:14:54 +03:00
%born :: need to register devices with vere and send disconnect soak
:- %+ weld
(turn ~(tap in ~(key by owners.state)) register)
(turn ~(tap in ~(key by owners.state)) disconnect)
2023-04-20 19:25:57 +03:00
lick-gate(unix-duct hen)
::
%spin :: A gall agent wants to spin a communication line
:- ~[(register name.task)]
lick-gate(owners (~(put by owners) name.task hen))
2023-04-20 19:25:57 +03:00
::
%shut :: shut down a communication line
:- [unix-duct.state %give [%shut name.task]]~
lick-gate(owners (~(del by owners) name.task))
2023-04-20 19:25:57 +03:00
::
%soak :: push a soak to the ipc's owner
=/ ner=duct (~(get by owners.state) name.task)
2023-04-20 19:25:57 +03:00
:_ lick-gate
[+.ner %give [%soak name.task mark.task noun.task]]~
2023-04-12 17:50:29 +03:00
::
2023-04-20 19:25:57 +03:00
%spit :: push a spit to ipc
:_ lick-gate
[unix-duct.state %give [%spit name.task mark.task noun.task]]~
2023-04-12 17:50:29 +03:00
==
:: +load: migrate an old state to a new lick version
::
++ load
|= old=lick-state
^+ lick-gate
lick-gate(state old)
:: +scry: view state
::
:: %a scry out a list of all ipc ports
:: %d get the owner of an ipc port
2023-04-12 17:50:29 +03:00
++ scry
^- roon
2023-06-22 19:25:40 +03:00
|= [lyc=gang pov=path car=term bem=beam]
2023-04-12 17:50:29 +03:00
^- (unit (unit cage))
2023-05-04 17:07:11 +03:00
|^
2023-12-13 20:49:36 +03:00
:: only respond for the local identity, current timestamp, root gang
::
?. ?& =(our p.bem)
=(%$ q.bem)
=([%da now] r.bem)
2023-12-13 20:49:36 +03:00
=([~ ~] lyc)
==
~
?+ car ~
%a read-a
%d read-d
%u read-u
==
:: +read-a: scry our list of ports
::
++ read-a
^- (unit (unit cage))
=/ ports=(list name) ~(tap in ~(key by owners))
``[%noun !>(ports)]
:: +read d: get ports owner
::
++ read-d
^- (unit (unit cage))
=/ devs=(unit duct) (~(get by owners) s.bem)
?~ devs [~ ~]
``[%noun !>(devs)]
:: +read u: does a port exist
::
++ read-u
^- (unit (unit cage))
2023-06-16 19:02:32 +03:00
``[%noun !>((~(has by owners) s.bem))]
::
--
2023-04-12 17:50:29 +03:00
::
++ stay
state
++ take
|= [tea=wire hen=duct dud=(unit goof) hin=sign]
^- [(list move) _lick-gate]
?^ dud
~|(%lick-take-dud (mean tang.u.dud))
::
[~ lick-gate]
--