graph-view: refactor threads to call into %group-view

This commit is contained in:
Liam Fitzgerald 2021-02-01 14:07:39 +10:00
parent e7b404ee4e
commit 2730eb6c09
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
4 changed files with 23 additions and 107 deletions

View File

@ -1,6 +1,6 @@
/- spider,
graph=graph-store,
*metadata-store,
metadata=metadata-store,
*group,
group-store,
inv=invite-store
@ -16,13 +16,8 @@
=/ m (strand ,resource)
?: ?=(%group -.associated)
(pure:m rid.associated)
=/ =action:group-store
[%add-group rid policy.associated %&]
;< ~ bind:m (poke-our %group-store %group-action !>(action))
;< =bowl:spider bind:m get-bowl:strandio
;< ~ bind:m (poke-our %group-store %group-action !>([%add-members rid (sy our.bowl ~)]))
;< ~ bind:m
(poke-our %group-push-hook %push-hook-action !>([%add rid]))
(poke-our %metadata-push-hook %push-hook-action !>([%add rid]))
(pure:m rid)
--
::
@ -52,25 +47,21 @@
::
;< group=resource bind:m
(handle-group rid.action associated.action)
=/ group-path=path
(en-path:resource group)
::
:: Setup metadata
::
=/ =metadata
%* . *metadata
=/ =metadatum:metadata
%* . *metadatum:metadata
title title.action
description description.action
date-created now.bowl
creator our.bowl
module module.action
==
=/ =metadata-action
[%add group graph+rid.action metadata]
=/ met-action=action:metadata
[%add group graph+rid.action metadatum]
;< ~ bind:m
(poke-our %metadata-store %metadata-action !>(metadata-action))
;< ~ bind:m
(poke-our %metadata-push-hook %push-hook-action !>([%add group]))
(poke-our %metadata-push-hook metadata-update+!>(met-action))
::
:: Send invites
::

View File

@ -64,16 +64,11 @@
?~ ugroup-rid !!
;< =group bind:m
(scry-group u.ugroup-rid)
;< ~ bind:m
(delete-graph u.ugroup-rid rid.action)
?. hidden.group
;< ~ bind:m
(delete-graph u.ugroup-rid rid.action)
(pure:m !>(~))
;< ~ bind:m
(poke-our %group-store %group-action !>([%remove-group rid.action ~]))
;< ~ bind:m
(poke-our %group-push-hook %push-hook-action !>([%remove rid.action]))
;< ~ bind:m (delete-graph u.ugroup-rid rid.action)
;< ~ bind:m
%+ poke-our %metadata-hook
metadata-hook-action+!>([%remove (en-path:resource u.ugroup-rid)])
;< =thread-result:strandio bind:m
(await-thread:strandio %group-delete !>([%delete rid.action]))
(pure:m !>(~))

View File

@ -19,42 +19,6 @@
/noun
==
(pure:m res)
::
++ wait-for-group-join
|= rid=resource
=/ m (strand ,~)
^- form:m
=/ pax
(en-path:resource rid)
=/ hold=@dr ~s0..8000
|- ^- form:m
?> (lte hold ~m5)
=* loop $
;< u-group=(unit group) bind:m
(scry:strandio ,(unit group) (weld /gx/group-store/groups (snoc pax %noun)))
?^ u-group
(pure:m ~)
;< ~ bind:m (sleep:strandio hold)
=. hold (mul hold 2)
loop
::
++ wait-for-md
|= rid=resource
=/ m (strand ,~)
^- form:m
=/ pax
(en-path:resource rid)
=/ hold=@dr ~s0..8000
|- ^- form:m
?> (lte hold ~m5)
=* loop $
;< groups=(jug path md-resource) bind:m
(scry:strandio ,(jug path md-resource) /gy/metadata-store/group-indices)
?: (~(has by groups) pax)
(pure:m ~)
;< ~ bind:m (sleep:strandio hold)
=. hold (mul hold 2)
loop
--
::
^- thread:spider
@ -67,30 +31,10 @@
?: =(our.bowl entity.rid.action)
(fail %bad-request ~)
;< group=(unit resource) bind:m (scry-metadata rid.action)
?^ group
:: We have group, graph is managed
;< ~ bind:m
%+ poke-our %graph-pull-hook
pull-hook-action+!>([%add ship.action rid.action])
(pure:m !>(~))
:: Else, add group then join
?> ?=(^ group)
:: We have group, graph is managed
;< ~ bind:m
%+ (map-err:strandio ,~) |=(* [%forbidden ~])
%+ 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 (wait-for-group-join rid.action)
::
;< ~ bind:m
%+ poke-our %metadata-pull-hook
pull-hook-action+!>([%add ship.action rid.action])::
;< ~ bind:m (wait-for-md rid.action)
::
;< ~ bind:m
%+ poke-our %graph-pull-hook
pull-hook-action+!>([%add ship.action rid.action])
%+ poke-our %graph-pull-hook
pull-hook-action+!>([%add ship.action rid.action])
(pure:m !>(~))

View File

@ -10,16 +10,14 @@
|= rid=resource
=/ m (strand ,resource)
^- form:m
;< pax=(unit (set path)) bind:m
%+ scry:strandio ,(unit (set path))
;< group=(unit resource) bind:m
%+ scry:strandio ,(unit resource)
;: weld
/gx/metadata-store/resource/graph
(en-path:resource rid)
/noun
==
?> ?=(^ pax)
?> ?=(^ u.pax)
(pure:m (de-path:resource n.u.pax))
(pure:m (need group))
::
++ scry-group
|= rid=resource
@ -59,18 +57,6 @@
?. hidden.g
;< ~ bind:m (delete-graph now.bowl rid.action)
(pure:m !>(~))
;< ~ bind:m
%+ poke-our %metadata-hook
metadata-hook-action+!>([%remove (en-path:resource rid.action)])
;< ~ bind:m
%+ poke-our %metadata-store
:- %metadata-action
!> :+ %remove
(en-path:resource rid.action)
[%graph (en-path:resource rid.action)]
;< ~ bind:m
(poke-our %group-store %group-action !>([%remove-group rid.action ~]))
;< ~ bind:m
(poke-our %group-pull-hook %pull-hook-action !>([%remove rid.action]))
;< ~ bind:m (delete-graph now.bowl rid.action)
;< =thread-result:strandio bind:m
(await-thread:strandio %group-leave !>([%leave rid.action]))
(pure:m !>(~))