From 55c2991a9b562905fd9363726c48ba5e727a32fd Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 14 Jan 2021 13:10:32 +1000 Subject: [PATCH] metadata-store,hook: add OTA adapter --- pkg/arvo/app/metadata-hook.hoon | 55 ++++++++++++++++++++++++++++++-- pkg/arvo/app/metadata-store.hoon | 49 ++++++++++++++++++++++++---- 2 files changed, 96 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/app/metadata-hook.hoon b/pkg/arvo/app/metadata-hook.hoon index 05939138db..823a61df1f 100644 --- a/pkg/arvo/app/metadata-hook.hoon +++ b/pkg/arvo/app/metadata-hook.hoon @@ -6,13 +6,14 @@ :: /group/%group-path all updates related to this group :: /- *metadata-store, *metadata-hook -/+ default-agent, dbug, verb, grpl=group, *migrate +/+ default-agent, dbug, verb, grpl=group, *migrate, resource ~% %metadata-hook-top ..part ~ |% +$ card card:agent:gall +$ versioned-state $% state-zero state-one + state-two == :: +$ state-zero @@ -23,10 +24,60 @@ $: %1 synced=(map group-path ship) == ++$ state-two + [%2 ~] -- =| state-one =* state - %- agent:dbug %+ verb | ^- agent:gall -(default-agent *agent:gall %|) +|_ =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])) + -- + +++ 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 +-- +:: + + diff --git a/pkg/arvo/app/metadata-store.hoon b/pkg/arvo/app/metadata-store.hoon index 4e0fb02a52..a079c60e80 100644 --- a/pkg/arvo/app/metadata-store.hoon +++ b/pkg/arvo/app/metadata-store.hoon @@ -44,9 +44,18 @@ creator=@p == :: ++$ metadata-1 + $: title=@t + description=@t + color=@ux + date-created=@da + creator=@p + module=term + == +:: +$ md-resource-1 [=app-name =app-path] :: -+$ associations-1 (map [group-path md-resource-1] metadata) ++$ associations-1 (map [group-path md-resource-1] metadata-1) :: +$ base-state-1 $: associations=associations-1 @@ -198,6 +207,7 @@ =/ old !<(versioned-state vase) =| cards=(list card) |^ + =* loop $ ?: ?=(%7 -.old) :- cards %_ state @@ -226,10 +236,37 @@ associations.old associations == :: pre-breach, can safely throw away - $(old *state-7) + loop(old *state-7) + :: ++ associations-1-to-2 - |= assoc=* - *^associations + |= assoc=associations-1 + ^- ^associations + %- ~(gas by *^associations) + %+ murn + ~(tap by assoc) + |= [[group=path m=md-resource-1] met=metadata-1] + %+ biff (de-path-soft:resource group) + |= g=resource + %+ bind (md-resource-1-to-2 m) + |= =md-resource + [md-resource g (metadata-1-to-2 met)] + :: + ++ md-resource-1-to-2 + |= m=md-resource-1 + ^- (unit md-resource) + %+ bind (de-path-soft:resource app-path.m) + |=(rid=resource [app-name.m rid]) + :: + ++ metadata-1-to-2 + |= m=metadata-1 + %* . *metadata + title title.m + description description.m + color color.m + date-created date-created.m + creator creator.m + module module.m + == :: ++ rebuild-resource-indices |= =^associations @@ -258,8 +295,8 @@ ^- associations-1 %- malt %+ turn ~(tap by associations) - |= [[=group-path md-resource=md-resource-1] m=metadata] - ^- [[^group-path md-resource-1] metadata] + |= [[=group-path md-resource=md-resource-1] m=metadata-1] + ^- [[^group-path md-resource-1] metadata-1] ?. =(app-name.md-resource app) [[group-path md-resource] m] =/ new-app-path=path