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

84 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
2021-02-04 04:37:43 +03:00
synced=(map path ship)
2020-02-15 03:31:52 +03:00
==
2020-07-23 08:02:54 +03:00
+$ state-one
$: %1
2021-02-04 04:37:43 +03:00
synced=(map path ship)
2020-07-23 08:02:54 +03:00
==
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 .
2021-02-12 05:14:56 +03:00
def ~(. (default-agent this %|) bowl)
2021-01-14 06:10:32 +03:00
++ on-init on-init:def
++ on-save !>(state)
++ on-load
|= =vase
2021-02-12 04:58:18 +03:00
=/ m-old=(unit versioned-state)
(mole |.(!<(versioned-state vase)))
?~ m-old `this
=* old u.m-old
2021-01-14 06:10:32 +03:00
|^
?: ?=(%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
--