metadata-hook: implemented watch, kick, added group-scry to store

This commit is contained in:
Logan Allen 2020-02-20 14:55:46 -08:00
parent 99663fec50
commit 5ef4cd50ac
2 changed files with 47 additions and 5 deletions

View File

@ -4,7 +4,7 @@
/+ default-agent
|%
+$ card card:agent:gall
++ versioned-state
+$ versioned-state
$% state-zero
==
::
@ -107,8 +107,27 @@
++ watch-group
|= =path
^- (list card)
|^
?> (~(has by synced) path)
~
?> (is-permitted [(scot %p src.bowl) path])
%+ turn ~(tap by (metadata-scry path))
|= [[=group-path =resource] =metadata]
^- card
[%give %fact ~ %metadata-update !>([%add group-path resource metadata])]
::
++ is-permitted
|= pax=^path
^- ?
=. pax
;:(weld /=permission-store/(scot %da now.bowl)/permitted pax /noun)
.^(? %gx pax)
::
++ metadata-scry
|= pax=^path
^- associations
=. pax ;:(weld /=metadata-store/(scot %da now.bowl)/group pax /noun)
(need .^((unit associations) %gx pax))
--
::
++ fact-metadata-update
|= [wir=wire fact=metadata-update]
@ -160,12 +179,22 @@
++ kick
|= wir=wire
^- (quip card _state)
[~ state]
:_ state
?+ wir !!
[%updates ~]
[%pass /updates %agent [our.bowl %metadata-store] %watch /updates]~
::
[%group @ *]
?. (~(has by synced) t.wir) ~
=/ =ship (~(got by synced) t.wir)
?: =(ship our.bowl)
[%pass wir %agent [our.bowl %metadata-store] %watch wir]~
[%pass wir %agent [ship %metadata-hook] %watch wir]~
==
::
++ watch-ack
|= [wir=wire saw=(unit tang)]
^- (quip card _state)
?~ saw [~ state]
?> ?=(^ wir)
[~ state(synced (~(del by synced) t.wir))]
[~ ?~(saw state state(synced (~(del by synced) t.wir)))]
--

View File

@ -19,6 +19,7 @@
:: /resource-indices all resource indices
:: /metadata/%group-path/%app-name/%app-path specific metadatum
:: /app-name/%app-name associations for app
:: /group/%group-path associations for group
::
/- *metadata-store
/+ default-agent
@ -99,6 +100,10 @@
[%x %app-name @ ~]
=/ =app-name i.t.t.path
``noun+!>((metadata-for-app:mc app-name))
::
[%x %group *]
=/ =group-path t.t.path
``noun+!>((metadata-for-group:mc group-path))
::
[%x %metadata @ @ @ ~]
=/ =group-path (stab (slav %t i.t.t.path))
@ -171,6 +176,14 @@
:- [group-path [app-name app-path]]
(~(got by associations) [group-path [app-name app-path]])
::
++ metadata-for-group
|= =group-path
%- ~(gas by *(map [^group-path resource] metadata))
%+ turn ~(tap in (~(got by group-indices) group-path))
|= =resource
:- [group-path resource]
(~(got by associations) [group-path resource])
::
++ send-diff
|= [=app-name upd=metadata-update]
^- (list card)