Merge pull request #6519 from mopfel-winrux/lick

`%lick` vane
This commit is contained in:
Joe Bryan 2023-06-22 15:14:38 -04:00 committed by GitHub
commit 3ac2ac2fae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 179 additions and 2 deletions

View File

@ -615,7 +615,7 @@
::
?: fake.ae ~
=+ [%raw-poke %noun %refresh-rate ~s30]
[/g/aqua/reduce-refresh-rate %deal [. .]:who.ae %azimuth -]~
[/g/aqua/reduce-refresh-rate %deal [. . /]:who.ae %azimuth -]~
==
==
=. this

View File

@ -1742,6 +1742,7 @@
%i %iris
%j %jael
%k %khan
%l %lick
==
-- =>
::

View File

@ -3103,6 +3103,30 @@
:: ::
+$ shed _*form:(strand:rand ,vase) :: compute vase
-- ::khan
:: ::::
:::: ++lick :: (1j) IPC
:: ::::
++ lick ^?
|%
+$ gift :: out result <-$
$% [%spin =name] :: open an IPC port
[%shut =name] :: close an IPC port
[%spit =name =mark =noun] :: spit a noun to the IPC port
[%soak =name =mark =noun] :: soak a noun from the IPC port
==
+$ task :: in request ->$
$~ [%vega ~] ::
$% $>(%born vane-task) :: new unix process
$>(%trim vane-task) :: trim state
$>(%vega vane-task) :: report upgrade
[%spin =name] :: open an IPC port
[%shut =name] :: close an IPC port
[%spit =name =mark =noun] :: spit a noun to the IPC port
[%soak =name =mark =noun] :: soak a noun from the IPC port
==
::
+$ name path
-- ::lick
::
++ rand :: computation
|%
@ -3305,6 +3329,7 @@
gift:iris
gift:jael
gift:khan
gift:lick
==
+$ task-arvo :: in request ->$
$% task:ames
@ -3316,6 +3341,7 @@
task:iris
task:jael
task:khan
task:lick
==
+$ note-arvo :: out request $->
$~ [%b %wake ~]
@ -3328,6 +3354,7 @@
[%i task:iris]
[%j task:jael]
[%k task:khan]
[%l task:lick]
[%$ %whiz ~]
[@tas %meta vase]
==
@ -3350,6 +3377,7 @@
[%iris gift:iris]
[%jael gift:jael]
[%khan gift:khan]
[%lick gift:lick]
==
:: $unix-task: input from unix
::

View File

@ -1153,7 +1153,13 @@
=/ =note-arvo
=/ prov=path /gall/[agent-name]
?- -.neet
%arvo +.neet
%arvo ?. ?=([%l *] +.neet)
+.neet
?+ +.neet
~|(%nope !!)
[%l ?(%spin %shut) *] +.neet(name [agent-name name.+.neet])
[%l %spit *] +.neet(name [agent-name name.+.neet])
==
%huck note-arvo.neet
%agent [%g %deal [our ship.neet prov] [name task]:neet]
==
@ -1397,6 +1403,15 @@
~/ %ap-generic-take
|= [=wire =sign-arvo]
^+ ap-core
=? sign-arvo ?=([%lick *] sign-arvo)
?+ sign-arvo
~|(%nope !!)
::
[%lick %soak *]
=- sign-arvo(name -)
?> &(?=(^ name.sign-arvo) =(agent-name i.name.sign-arvo))
t.name.sign-arvo
==
=^ maybe-tang ap-core
%+ ap-ingest ~ |.
(on-arvo:ap-agent-core wire sign-arvo)

133
pkg/arvo/sys/vane/lick.hoon Normal file
View File

@ -0,0 +1,133 @@
:: %lick
!:
!? 164
::
=, lick
|= our=ship
=> |%
+$ move [p=duct q=(wite note gift)]
+$ note ~ :: out request $->
+$ sign ~
::
+$ lick-state
$: %0
unix-duct=duct
owners=(map name duct)
==
::
+$ name path
--
::
~% %lick ..part ~
::
=| lick-state
=* state -
|= [now=@da eny=@uvJ rof=roof]
=* lick-gate .
^?
|%
:: +register: Create a move to register an agent with vere
::
++ register
|= =name
^- move
[unix-duct.state %give [%spin name]]
:: +disconnect: Create Move to send a disconnect soak to am agent
::
++ disconnect
|= =name
^- move
=/ =duct (~(get by owners) name)
[+.duct %give [%soak name %disconnect ~]]
:: +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]
%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)
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))
::
%shut :: shut down a communication line
:- [unix-duct.state %give [%shut name.task]]~
lick-gate(owners (~(del by owners) name.task))
::
%soak :: push a soak to the ipc's owner
=/ ner=duct (~(get by owners.state) name.task)
:_ lick-gate
[+.ner %give [%soak name.task mark.task noun.task]]~
::
%spit :: push a spit to ipc
:_ lick-gate
[unix-duct.state %give [%spit name.task mark.task noun.task]]~
==
:: +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
++ scry
^- roon
|= [lyc=gang pov=path car=term bem=beam]
^- (unit (unit cage))
|^
:: only respond for the local identity, current timestamp
::
?. ?& =(our p.bem)
=(%$ q.bem)
=([%da now] r.bem)
==
~
?+ 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))
``[%noun !>((~(has by owners) s.bem))]
::
--
::
++ 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]
--