From 2ce654555c2f7c84f76086fb648b09f4b057e1cd Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Mon, 25 Jan 2021 13:07:47 +1000 Subject: [PATCH] pull-hook: add +take-update arm --- pkg/arvo/app/graph-pull-hook.hoon | 2 ++ pkg/arvo/app/group-pull-hook.hoon | 2 ++ pkg/arvo/app/metadata-pull-hook.hoon | 49 ++++++++-------------------- pkg/arvo/lib/pull-hook.hoon | 14 +++++++- 4 files changed, 30 insertions(+), 37 deletions(-) diff --git a/pkg/arvo/app/graph-pull-hook.hoon b/pkg/arvo/app/graph-pull-hook.hoon index ee7d73796..1c6ec0b90 100644 --- a/pkg/arvo/app/graph-pull-hook.hoon +++ b/pkg/arvo/app/graph-pull-hook.hoon @@ -48,4 +48,6 @@ =/ maybe-time (peek-update-log:gra resource) ?~ maybe-time `/ `/(scot %da u.maybe-time) +:: +++ take-update take-update:dep -- diff --git a/pkg/arvo/app/group-pull-hook.hoon b/pkg/arvo/app/group-pull-hook.hoon index 9141c8e82..b3b089665 100644 --- a/pkg/arvo/app/group-pull-hook.hoon +++ b/pkg/arvo/app/group-pull-hook.hoon @@ -49,4 +49,6 @@ |= =resource ^- (unit path) `/ +:: +++ take-update take-update:dep -- diff --git a/pkg/arvo/app/metadata-pull-hook.hoon b/pkg/arvo/app/metadata-pull-hook.hoon index 7e4ef7178..17e068c2e 100644 --- a/pkg/arvo/app/metadata-pull-hook.hoon +++ b/pkg/arvo/app/metadata-pull-hook.hoon @@ -17,7 +17,7 @@ %metadata-push-hook == +$ state-zero - [%0 previews=(map resource group-preview)] + [%0 ~] :: -- :: @@ -31,14 +31,11 @@ =* state - => |_ =bowl:gall ++ def ~(. (default-agent state %|) bowl) - ++ watch-preview + ++ add-resource |= rid=resource ^- card - =/ =path - preview+(en-path:resource rid) - =/ =dock - [entity.rid %metadata-push-hook] - [%pass path %agent dock %watch path] + =- [%pass / %agent [our dap]:bowl %poke -] + pull-hook-action+!>(`action:pull-hook`[%add [entity .]:rid]) :: ++ watch-invites ^- card @@ -54,40 +51,17 @@ :_ state ?. ?=(%invite -.update) ~ ?. =(%contacts term.update) ~ - (watch-preview resource.invite.update)^~ + (add-resource resource.invite.update)^~ :: %kick [watch-invites^~ state] == - :: - ++ take-preview - |= [=wire =sign:agent:gall] - ^- (quip card _state) - ?> ?=([%preview @ *] wire) - =/ rid=resource - (de-path:resource t.wire) - ?+ -.sign (on-agent:def wire sign) - %fact - ?> =(%metadata-update p.cage.sign) - =+ !<(upd=metadata-update q.cage.sign) - ?> ?=(%preview -.upd) - :_ state(previews (~(put by previews) rid +.upd)) - :~ [%give %fact ~[wire] cage.sign] - [%give %kick ~[wire] ~] - == - :: - %watch-ack - :_ state - ?~ p.sign ~ - :~ [%give %fact ~[wire] tang+!>(u.p.sign)] - [%give %kick ~[wire] ~] - == - == -- |_ =bowl:gall +* this . def ~(. (default-agent this %|) bowl) dep ~(. (default:pull-hook this config) bowl) met ~(. mdl bowl) + grp ~(. grpl bowl) hc ~(. +> bowl) :: ++ on-init on-init:def @@ -106,7 +80,6 @@ =^ cards state ?+ wire (on-agent:def:hc wire sign) [%invites ~] (take-invites:hc sign) - [%preview @ @ @ ~] (take-preview:hc wire sign) == [cards this] :: @@ -117,8 +90,7 @@ (on-watch:def path) =/ rid=resource (de-path:resource t.path) - =/ prev=(unit group-preview) - (~(get by previews) rid) + =/ prev=(unit group-preview) ~ :_ this ?^ prev :~ [%give %fact ~ metadata-update+!>([%preview u.prev])] @@ -147,7 +119,12 @@ [%remove resource md-resource] :: ++ on-pull-kick - |= =resource + |= rid=resource ^- (unit path) + ?. (is-member:grp our.bowl rid) ~ `/ +:: +++ take-update + |= [rid=resource =vase] + `this -- diff --git a/pkg/arvo/lib/pull-hook.hoon b/pkg/arvo/lib/pull-hook.hoon index a8baae867..f0a6ff0b1 100644 --- a/pkg/arvo/lib/pull-hook.hoon +++ b/pkg/arvo/lib/pull-hook.hoon @@ -76,6 +76,10 @@ %- (slog tank tang) [~ pull-hook] :: + ++ take-update + |= [=resource =vase] + `pull-hook + :: ++ on-pull-kick |= =resource *(unit path) @@ -106,6 +110,12 @@ ++ on-pull-kick |~ resource *(unit path) + :: +take-update: process store update + :: + :: Perform actions before the store receives the update + ++ take-update + |~ [resource vase] + *[(list card) _^|(..on-init)] :: :: from agent:gall ++ on-init @@ -292,8 +302,10 @@ =^ cards pull-hook (on-agent:og wire sign) [cards this] + =^ cards pull-hook + (take-update:og rid q.cage.sign) :_ this - ~[(update-store:hc rid q.cage.sign)] + (snoc cards (update-store:hc rid q.cage.sign)) == ++ on-leave |= =path