urbit/pkg/arvo/ted/graph/join.hoon

67 lines
1.6 KiB
Plaintext
Raw Normal View History

2020-09-02 08:18:07 +03:00
/- spider, graph-view, graph=graph-store, *metadata-store, *group
/+ strandio, resource
=>
|%
++ strand strand:spider
++ poke poke:strandio
++ poke-our poke-our:strandio
2020-09-04 10:42:20 +03:00
++ check-live
|= who=ship
=/ m (strand ,~)
^- form:m
%+ (set-timeout:strandio ,~) ~s10
;< ~ bind:m
(poke [who %hood] %helm-hi !>(~))
(pure:m ~)
2020-09-02 08:18:07 +03:00
++ scry-metadata
|= rid=resource
=/ m (strand ,(unit resource))
2020-09-04 10:42:20 +03:00
^- form:m
;< pax=(unit (set path)) bind:m
%+ scry:strandio ,(unit (set path))
2020-09-02 08:18:07 +03:00
;: weld
2020-09-04 10:42:20 +03:00
/gx/metadata-store/resource/chat
2020-09-02 08:18:07 +03:00
(en-path:resource rid)
/noun
==
2020-09-04 10:42:20 +03:00
%- pure:m
?~ pax ~
?~ u.pax ~
`(de-path:resource n.u.pax)
2020-09-02 08:18:07 +03:00
--
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<(=action:graph-view arg)
?> ?=(%join -.action)
;< =bowl:spider bind:m get-bowl:strandio
?< =(our.bowl entity.rid.action)
;< group=(unit resource) bind:m
(scry-metadata rid.action)
2020-09-04 10:42:20 +03:00
;< ~ bind:m (check-live entity.rid.action)
2020-09-02 08:18:07 +03:00
?^ group
:: We have group, graph is managed
2020-09-03 08:07:18 +03:00
;< ~ bind:m
%+ poke-our %graph-pull-hook
pull-hook-action+!>([%add ship.action rid.action])
2020-09-02 08:18:07 +03:00
(pure:m !>(~))
:: Else, add group then join
;< ~ bind:m
%+ poke
[ship.action %group-push-hook]
group-update+!>([%add-members rid.action (sy our.bowl ~)])
::
;< ~ bind:m
%+ poke-our %group-pull-hook
pull-hook-action+!>([%add ship.action rid.action])
::
;< ~ bind:m
%+ poke-our %metadata-hook
metadata-hook-action+!>([%add-synced ship.action rid.action])
;< ~ bind:m
2020-09-04 10:42:20 +03:00
%+ poke-our %graph-pull-hook
pull-hook-action+!>([%add ship.action rid.action]))
2020-09-02 08:18:07 +03:00
(pure:m !>(~))