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

115 lines
2.1 KiB
Plaintext
Raw Normal View History

:: group-hook [landscape]:
::
:: allow syncing group data from foreign paths to local paths
2019-11-21 02:37:43 +03:00
::
2020-05-21 07:30:02 +03:00
/- *group, hook=group-hook, *invite-store
2020-06-24 03:28:57 +03:00
/+ default-agent, verb, dbug, store=group-store, grpl=group, pull-hook, push-hook, resource
~% %group-hook-top ..is ~
2019-11-21 02:37:43 +03:00
|%
+$ card card:agent:gall
::
++ versioned-state
$% state-zero
2020-05-15 01:50:04 +03:00
state-one
2019-11-21 02:37:43 +03:00
==
::
::
+$ state-zero
$: %0
synced=(map path ship)
==
::
2020-05-15 01:50:04 +03:00
+$ state-one
$: %1
2020-06-24 03:28:57 +03:00
~
2020-05-15 01:50:04 +03:00
==
::
2019-11-21 02:37:43 +03:00
--
::
2020-05-15 01:50:04 +03:00
=| state-one
2019-11-21 02:37:43 +03:00
=* state -
::
%- agent:dbug
%+ verb |
2019-11-21 02:37:43 +03:00
^- agent:gall
2020-06-24 03:28:57 +03:00
|_ =bowl:gall
+* this .
group-core +>
gc ~(. group-core bowl)
def ~(. (default-agent this %|) bowl)
::
++ on-init on-init:def
:: ^- (quip card _this)
:: :_ this
:: ~[watch-store:gc]
++ on-save !>(state)
++ on-load
|= =vase
^- (quip card _this)
=/ old !<(versioned-state vase)
?- -.old
%1 [~ this(state old)]
%0
:_ this(state *state-one)
|^
2020-07-09 02:52:41 +03:00
%+ murn
2020-06-24 03:28:57 +03:00
~(tap by synced.old)
|= [=path host=ship]
2020-07-09 02:52:41 +03:00
^- (unit card)
2020-06-24 03:28:57 +03:00
?> ?=([@ @ *] path)
2020-07-09 02:52:41 +03:00
:: ignore duplicate publish groups
?: =(4 (lent path))
~& "ignoring: {<path>}"
~
2020-06-24 03:28:57 +03:00
=/ pax=^path
?: =('~' i.path)
t.path
path
=/ rid=resource
?> ?=([@ @ *] pax)
=/ ship
(slav %p i.pax)
[ship i.t.pax]
?: =(our.bowl host)
2020-07-09 02:52:41 +03:00
`(add-push rid)
`(add-pull rid host)
2020-06-24 03:28:57 +03:00
::
++ poke-our
|= [app=term =cage]
^- card
[%pass / %agent [our.bowl app] %poke cage]
++ add-pull
|= [rid=resource host=ship]
^- card
%+ poke-our
%group-pull-hook
:- %pull-hook-action
!> ^- action:pull-hook
[%add host rid]
::
++ add-push
|= rid=resource
^- card
%+ poke-our
%group-push-hook
:- %push-hook-action
!> ^- action:push-hook
[%add rid]
--
2020-06-02 09:24:37 +03:00
2020-05-19 23:53:55 +03:00
==
2020-06-24 03:28:57 +03:00
2020-05-21 07:30:02 +03:00
::
2020-06-24 03:28:57 +03:00
++ on-poke on-poke:def
2020-05-21 07:30:02 +03:00
::
2020-06-24 03:28:57 +03:00
++ on-agent on-agent:def
2020-05-21 07:30:02 +03:00
::
2020-06-24 03:28:57 +03:00
++ on-watch on-watch:def
2020-05-21 07:30:02 +03:00
::
2020-06-24 03:28:57 +03:00
++ on-leave on-leave:def
++ on-peek on-peek:def
++ on-arvo on-arvo:def
++ on-fail on-fail:def
2019-11-21 02:37:43 +03:00
--