shrub/pkg/arvo/app/metadata-hook.hoon

81 lines
1.6 KiB
Plaintext
Raw Normal View History

:: metadata-hook [landscape]:
::
:: allow syncing foreign metadata
2020-02-15 03:31:52 +03:00
::
2020-02-22 03:13:22 +03:00
:: watch paths:
:: /group/%group-path all updates related to this group
::
2020-02-19 04:35:00 +03:00
/- *metadata-store, *metadata-hook
2021-01-14 06:10:32 +03:00
/+ default-agent, dbug, verb, grpl=group, *migrate, resource
~% %metadata-hook-top ..part ~
2020-02-15 03:31:52 +03:00
|%
+$ card card:agent:gall
+$ versioned-state
2020-02-15 03:31:52 +03:00
$% state-zero
2020-07-23 08:02:54 +03:00
state-one
2021-01-14 06:10:32 +03:00
state-two
2020-02-15 03:31:52 +03:00
==
::
+$ state-zero
$: %0
2020-02-19 04:35:00 +03:00
synced=(map group-path ship)
2020-02-15 03:31:52 +03:00
==
2020-07-23 08:02:54 +03:00
+$ state-one
$: %1
synced=(map group-path ship)
==
2021-01-14 06:10:32 +03:00
+$ state-two
[%2 ~]
2020-02-15 03:31:52 +03:00
--
=| state-two
2020-02-15 03:31:52 +03:00
=* state -
2020-03-27 03:30:30 +03:00
%- agent:dbug
2020-05-25 08:52:54 +03:00
%+ verb |
2020-02-15 03:31:52 +03:00
^- agent:gall
2021-01-14 06:10:32 +03:00
|_ =bowl:gall
+* this .
def ~(. (default-agent *agent:gall %|) bowl)
++ on-init on-init:def
++ on-save !>(state)
++ on-load
|= =vase
=+ !<(old=versioned-state vase)
|^
?: ?=(%2 -.old)
`this
:_ this
%+ murn
~(tap by synced.old)
|= [group=path =ship]
%+ bind
(de-path-soft:resource group)
|= rid=resource
?: =(our.bowl ship)
(push-metadata rid)
(pull-metadata rid ship)
::
++ poke-our
|= [app=term =cage]
^- card
[%pass / %agent [our.bowl app] %poke cage]
::
++ push-metadata
|= rid=resource
^- card
(poke-our %metadata-push-hook push-hook-action+!>([%add rid]))
::
++ pull-metadata
|= [rid=resource =ship]
^- card
(poke-our %metadata-pull-hook pull-hook-action+!>([%add ship rid]))
--
2020-02-19 04:35:00 +03:00
::
2021-01-14 06:10:32 +03:00
++ on-poke on-poke:def
++ on-watch on-watch:def
++ on-peek on-peek:def
++ on-leave on-leave:def
++ on-agent on-agent:def
++ on-arvo on-arvo:def
++ on-fail on-fail:def
--