mirror of
https://github.com/urbit/shrub.git
synced 2024-12-29 15:14:17 +03:00
graph-store: structure compiles
This commit is contained in:
parent
4fded00005
commit
fcfcf95aed
73
pkg/arvo/app/graph-store.hoon
Normal file
73
pkg/arvo/app/graph-store.hoon
Normal file
@ -0,0 +1,73 @@
|
||||
/+ store=graph-store, default-agent, dbug
|
||||
|%
|
||||
+$ card card:agent:gall
|
||||
+$ versioned-state
|
||||
$% state-0
|
||||
==
|
||||
+$ state-0 [%0 network:store]
|
||||
++ ordered-graph ((ordered-map ,time ,node:store) gth)
|
||||
--
|
||||
::
|
||||
=| state-0
|
||||
=* state -
|
||||
::
|
||||
%- agent:dbug
|
||||
^- agent:gall
|
||||
|_ =bowl:gall
|
||||
+* this .
|
||||
def ~(. (default-agent this %|) bowl)
|
||||
::
|
||||
++ on-init [~ this]
|
||||
++ on-save !>(state)
|
||||
++ on-load
|
||||
|= old=vase
|
||||
^- (quip card _this)
|
||||
[~ this(state !<(state-0 old))]
|
||||
::
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card _this)
|
||||
|^
|
||||
?> (team:title our.bowl src.bowl)
|
||||
=^ cards state
|
||||
?+ mark (on-poke:def mark vase)
|
||||
%graph-action (graph-action !<(action:store vase))
|
||||
==
|
||||
[cards this]
|
||||
::
|
||||
++ graph-action
|
||||
|= =action:store
|
||||
^- (quip card _state)
|
||||
[~ state]
|
||||
--
|
||||
::
|
||||
++ on-watch
|
||||
|= =path
|
||||
^- (quip card _this)
|
||||
|^
|
||||
?> (team:title our.bowl src.bowl)
|
||||
=/ cards=(list card)
|
||||
?+ path (on-watch:def path)
|
||||
[%all ~] (give [%initial graphs tags tag-queries])
|
||||
[%keys ~] (give [%keys ~(key by graphs)])
|
||||
==
|
||||
[cards this]
|
||||
::
|
||||
++ give
|
||||
|= =update:store
|
||||
^- (list card)
|
||||
[%give %fact ~ [%graph-update !>(update)]]~
|
||||
--
|
||||
::
|
||||
++ on-peek
|
||||
|= =path
|
||||
^- (unit (unit cage))
|
||||
?+ path (on-peek:def path)
|
||||
[%x %keys ~] ``noun+!>(~(key by graphs))
|
||||
==
|
||||
::
|
||||
++ on-arvo on-arvo:def
|
||||
++ on-agent on-agent:def
|
||||
++ on-leave on-leave:def
|
||||
++ on-fail on-fail:def
|
||||
--
|
35
pkg/arvo/sur/graph-store.hoon
Normal file
35
pkg/arvo/sur/graph-store.hoon
Normal file
@ -0,0 +1,35 @@
|
||||
/- *post
|
||||
|%
|
||||
+$ network
|
||||
$: graphs=(map resource graph)
|
||||
tags=(set term)
|
||||
tag-queries=(map term resources)
|
||||
==
|
||||
::
|
||||
+$ internal-graph (tree [key=time val=node])
|
||||
+$ graph
|
||||
$~ [%empty ~]
|
||||
$% [%graph u=internal-graph]
|
||||
[%empty ~]
|
||||
==
|
||||
+$ node [=post replies=graph]
|
||||
+$ action
|
||||
$% [%add-graph =resource =graph]
|
||||
[%remove-graph =resource]
|
||||
::
|
||||
[%add-nodes uids=(set [=uid =node])]
|
||||
[%remove-nodes uids=(set uid)]
|
||||
::
|
||||
[%add-signatures =uid =signatures]
|
||||
[%remove-signatures =uid =signatures]
|
||||
::
|
||||
[%add-tag =term =resources]
|
||||
[%remove-tag =term =resources]
|
||||
==
|
||||
::
|
||||
+$ update
|
||||
$% [%keys =resources]
|
||||
[%initial =network]
|
||||
action
|
||||
==
|
||||
--
|
Loading…
Reference in New Issue
Block a user