From e042384b3f1adf8f2033145b2a0194e1506eef5c Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Tue, 3 Oct 2023 20:14:26 -0600 Subject: [PATCH] Made fixes for group --- context.go | 7 ++++++- gql.go | 12 ++++++++++++ node.go | 1 + serialize.go | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/context.go b/context.go index 18c313f..90344b4 100644 --- a/context.go +++ b/context.go @@ -1330,7 +1330,12 @@ func NewContext(db * badger.DB, log Logger) (*Context, error) { return nil, err } - err = ctx.RegisterNodeType(GQLNodeType, []ExtType{GroupExtType, GQLExtType}) + err = ctx.RegisterNodeType(GroupNodeType, []ExtType{GroupExtType}) + if err != nil { + return nil, err + } + + err = ctx.RegisterNodeType(GQLNodeType, []ExtType{GQLExtType}) if err != nil { return nil, err } diff --git a/gql.go b/gql.go index 38b4df9..b2bcef3 100644 --- a/gql.go +++ b/gql.go @@ -1285,6 +1285,18 @@ func (ext *GQLExt) FreeResponseChannel(req_id uuid.UUID) chan Signal { func (ext *GQLExt) Process(ctx *Context, node *Node, source NodeID, signal Signal) Messages { // Process ReadResultSignalType by forwarding it to the waiting resolver switch sig := signal.(type) { + case *SuccessSignal: + response_chan := ext.FreeResponseChannel(sig.ReqID) + if response_chan != nil { + select { + case response_chan <- sig: + ctx.Log.Logf("gql", "Forwarded success to resolver, %+v", sig.ReqID) + default: + ctx.Log.Logf("gql", "Resolver channel overflow %+v", sig) + } + } else { + ctx.Log.Logf("gql", "received success signal response %+v with no mapped resolver", sig) + } case *ErrorSignal: // TODO: Forward to resolver if waiting for it response_chan := ext.FreeResponseChannel(sig.ReqID) diff --git a/node.go b/node.go index fae514d..8eda196 100644 --- a/node.go +++ b/node.go @@ -308,6 +308,7 @@ func nodeLoop(ctx *Context, node *Node) error { } } node.PendingACLs[msg.Signal.ID()] = PendingACL{len(msgs), timeout_signal.ID(), msg.Signal.Permission(), princ_id, msgs, []Signal{}, msg.Signal, msg.Source} + ctx.Log.Logf("policy", "Sending signals for pending ACL: %+v", msgs) ctx.Send(msgs) continue } else if resp == Allow { diff --git a/serialize.go b/serialize.go index ab765ee..1e27ae5 100644 --- a/serialize.go +++ b/serialize.go @@ -86,6 +86,7 @@ var ( GQLNodeType = NewNodeType("GQL") BaseNodeType = NewNodeType("BASE") + GroupNodeType = NewNodeType("GROUP") StopSignalType = NewSignalType("STOP") CreateSignalType = NewSignalType("CREATE")