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

70 lines
1.7 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:51:28 +03:00
::
2020-09-04 10:42:20 +03:00
++ check-live
|= who=ship
=/ m (strand ,~)
^- form:m
2020-09-04 10:51:28 +03:00
%+ (set-timeout:strandio ,~) ~s20
2020-09-04 10:42:20 +03:00
;< ~ bind:m
(poke [who %hood] %helm-hi !>(~))
(pure:m ~)
2020-09-04 10:51:28 +03:00
::
2020-09-02 08:18:07 +03:00
++ scry-metadata
2020-09-10 13:20:00 +03:00
|= [app=app-name:graph-view rid=resource]
2020-09-02 08:18:07 +03:00
=/ 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-10 13:20:00 +03:00
/gx/metadata-store/resource/[app]
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
--
2020-09-04 10:51:28 +03:00
::
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
2020-09-11 03:10:44 +03:00
(scry-metadata app.action 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])
2020-09-10 13:20:00 +03:00
::
2020-09-02 08:18:07 +03:00
;< ~ bind:m
2020-09-04 10:42:20 +03:00
%+ poke-our %graph-pull-hook
2020-09-10 13:20:00 +03:00
pull-hook-action+!>([%add ship.action rid.action])
2020-09-02 08:18:07 +03:00
(pure:m !>(~))