This commit is contained in:
Philip Monk 2019-09-10 13:12:38 -07:00
parent 1ca4c72aa5
commit abf4bc39cd
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC
3 changed files with 113 additions and 81 deletions

View File

@ -1,50 +1,22 @@
/+ default-agent
^- agent:mall
=| state=@
|_ bowl:mall
++ handle-init
`..handle-init
::
++ handle-prep
|= =old-state=vase
=/ old-state !<(@ old-state-vase)
?~ old-state
~& %prep-lost
`..handle-init
~& %prep-found
`..handle-init(state u.old-state)
::
|_ =bowl:mall
+* this .
++ handle-init ~(handle-init default-agent bowl this)
++ handle-extract-state ~(handle-extract-state default-agent bowl this)
++ handle-upgrade-state ~(handle-upgrade-state default-agent bowl this)
++ handle-poke
|= in-poke-data=cage
~& >> 'ouchies!'
~& >>> in-poke-data
~& > state=state
~& > in-poke-data
=. state +(state)
`..handle-init
`this
::
++ handle-peer
|= path
`..handle-init
::
++ handle-pull
|= path
`..handle-init
::
++ handle-peek
|= path
*(unit (unit cage))
::
++ handle-mall
|= [wire internal-gift:mall]
`..handle-init
::
++ handle-take
|= [wire vase]
`..handle-init
::
++ handle-lame
|= [term tang]
`..handle-init
::
++ handle-stay
!>(state)
++ handle-subscribe ~(handle-subscribe default-agent bowl this)
++ handle-unsubscribe ~(handle-unsubscribe default-agent bowl this)
++ handle-peek ~(handle-peek default-agent bowl this)
++ handle-agent-response ~(handle-agent-response default-agent bowl this)
++ handle-arvo-response ~(handle-arvo-response default-agent bowl this)
++ handle-error ~(handle-error default-agent bowl this)
--

View File

@ -0,0 +1,63 @@
|_ [=bowl:mall =agent:mall]
++ handle-init
`agent
::
++ handle-prep
|= old-state=vase
~& "updating agent {<dap.bowl>} by throwing away old state"
`agent
::
++ handle-poke
|= =cage
~& "unexpected poke to {<dap.bowl>} with mark {<p.cage>}"
~| "unexpected poke to {<dap.bowl>} with mark {<p.cage>}"
!!
::
++ handle-peer
|= =path
~& "unexpected subscription to {<dap.bowl>} on path {<path>}"
~| "unexpected subscription to {<dap.bowl>} on path {<path>}"
!!
::
++ handle-pull
|= path
`agent
::
++ handle-peek
|= path
~| "unexpected scry into {<dap.bowl>} on path {<path>}"
!!
::
++ handle-mall
|= [=wire =internal-gift:mall]
?- -.internal-gift
%coup `agent
%reap `agent
%quit
~| "unexpected subscription closure to {<dap.bowl>} on wire {<wire>}"
!!
::
%diff
~| "unexpected subscription update to {<dap.bowl>} on wire {<wire>}"
~| "with mark {<p.p.internal-gift>}"
!!
::
%http-response
~| "unexpected http-response to {<dap.bowl>} on wire {<wire>}"
!!
==
::
++ handle-take
|= [=wire =vase]
~| "unexpected system response {<q.vase>} to {<dap.bowl>} on wire {<wire>}"
!!
::
++ handle-lame
|= [=term =tang]
%- (slog leaf+"error in {<dap.bowl>}" >term< tang)
`agent
::
++ handle-stay
~& "extracting empty state for {<dap.bowl>}"
!>(~)
--

View File

@ -1862,7 +1862,7 @@
$% {$mass p/mass} :: memory usage
{$onto p/(each suss tang)} :: about agent
{$rend p/path q/*} :: network request
{$unto p/internal-gift} ::
{$unto p/gift:agent} ::
{$mack p/(unit tang)} :: message ack
== ::
++ task :: incoming request
@ -1901,19 +1901,12 @@
{$peer p/path} :: subscribe
{$poke p/cage} :: apply
{$puff p/mark q/noun} :: unchecked poke
{$pull ~} :: unsubscribe
{$pull ~} :: unsubscribe
{$punk p/mark q/cage} :: translated poke
{$pump ~} :: pump yes+no
{$pump ~} :: pump yes+no
{$peer-not p/tang} :: poison pill peer
== ::
++ internal-gift ::
$% {$coup p/(unit tang)} :: poke result
{$diff p/cage} :: subscription output
{$quit ~} :: close subscription
{$reap p/(unit tang)} :: peer result
[%http-response =http-event:http] :: serve http result
== ::
++ internal-task (pair term agent-action) :: internal task
++ internal-task task:agent :: internal task
++ dude term :: server identity
++ gill (pair ship term) :: general contact
++ scar :: opaque duct
@ -1924,36 +1917,43 @@
++ suss (trel dude @tas @da) :: config report
++ well (pair desk term) ::
::
:: +internal-note: +ap note
::
++ internal-note
$% [%meta =term =vase]
[%send =ship =internal-task]
==
:: +internal-move: agent-level move
::
:: Analogous to an Arvo move, except these are routed by bone, instead of
:: duct.
::
++ internal-move
$: =bone
move=(wind internal-note internal-gift)
==
:: +agent: app core
::
++ agent
=< form
|%
+$ move [=bone move=card]
+$ card (wind internal-note internal-gift)
+$ step (quip move form)
+$ step (quip card form)
+$ card (wind note gift)
+$ note
$% [%arvo note-arvo]
[%agent =ship name=term =task]
==
+$ task
$% [%subscribe-translated =mark =path]
[%subscribe =path]
[%unsubscribe ~]
[%poke =cage]
[%raw-poke =mark =noun]
[%poke-translated =mark =cage]
[%pump ~]
==
+$ gift
$% [%poke-ack p=(unit tang)]
[%subscription-update p=cage]
[%subscription-closed ~]
[%subscription-ack p=(unit tang)]
[%http-response =http-event:http]
==
++ form
$_ ^|
|_ bowl
++ handle-init
*(quip move _^|(..handle-init))
::
++ handle-prep
++ handle-extract-state
*vase
::
++ handle-upgrade-state
|~ old-state=vase
*(quip move _^|(..handle-init))
::
@ -1961,11 +1961,11 @@
|~ in-poke-data=cage
*(quip move _^|(..handle-init))
::
++ handle-peer
++ handle-subscribe
|~ path
*(quip move _^|(..handle-init))
::
++ handle-pull
++ handle-unsubscribe
|~ path
*(quip move _^|(..handle-init))
::
@ -1973,20 +1973,17 @@
|~ path
*(unit (unit cage))
::
++ handle-mall
++ handle-agent-response
|~ [wire internal-gift]
*(quip move _^|(..handle-init))
::
++ handle-take
|~ [wire sign=vase]
++ handle-arvo-response
|~ [wire =sign-arvo]
*(quip move _^|(..handle-init))
::
++ handle-lame
++ handle-error
|~ [term tang]
*(quip move _^|(..handle-init))
::
++ handle-stay
*vase
--
--
-- ::mall