Added some logging and fixes

gql_cataclysm
noah metz 2023-11-11 14:52:08 -07:00
parent 786f374b5f
commit 59424cecc1
5 changed files with 21 additions and 19 deletions

@ -105,7 +105,7 @@ func (signal EventControlSignal) Permission() Tree {
func (ext *EventExt) UpdateState(node *Node, changes Changes, state string) {
if ext.State != state {
changes.Add(EventExtType, "changes")
changes.Add(EventExtType, "state")
ext.State = state
node.QueueSignal(time.Now(), NewEventStateSignal(node.ID, ext.State, time.Now()))
}
@ -113,7 +113,7 @@ func (ext *EventExt) UpdateState(node *Node, changes Changes, state string) {
func (ext *EventExt) Process(ctx *Context, node *Node, source NodeID, signal Signal) (Messages, Changes) {
var messages Messages = nil
var changes Changes = nil
var changes = Changes{}
if signal.Direction() == Up && ext.Parent != node.ID {
messages = messages.Add(ctx, ext.Parent, node, nil, signal)
@ -147,7 +147,7 @@ var test_event_commands = map[string]map[string]string{
func (ext *TestEventExt) Process(ctx *Context, node *Node, source NodeID, signal Signal) (Messages, Changes) {
var messages Messages = nil
var changes Changes = nil
var changes = Changes{}
switch sig := signal.(type) {
case *EventControlSignal:

@ -1656,7 +1656,7 @@ func (ext *GQLExt) FreeResponseChannel(req_id uuid.UUID) chan Signal {
func (ext *GQLExt) Process(ctx *Context, node *Node, source NodeID, signal Signal) (Messages, Changes) {
// Process ReadResultSignalType by forwarding it to the waiting resolver
var changes Changes = nil
var changes = Changes{}
switch sig := signal.(type) {
case *SuccessSignal:

@ -225,7 +225,7 @@ func NewGroupExt(sub_groups map[string][]NodeID) *GroupExt {
func (ext *GroupExt) Process(ctx *Context, node *Node, source NodeID, signal Signal) (Messages, Changes) {
var messages Messages = nil
var changes Changes = nil
var changes = Changes{}
switch sig := signal.(type) {
case *AddMemberSignal:

@ -5,6 +5,12 @@ import (
"time"
)
var AllowAnyLockPolicy = NewAllNodesPolicy(Tree{
SerializedType(LockSignalType): {
Hash(LockStateBase, "lock"): nil,
},
})
type ReqState byte
const (
Unlocked = ReqState(0)
@ -69,7 +75,7 @@ func LockLockable(ctx *Context, node *Node) (uuid.UUID, error) {
func (ext *LockableExt) HandleErrorSignal(ctx *Context, node *Node, source NodeID, signal *ErrorSignal) (Messages, Changes) {
var messages Messages = nil
var changes Changes = nil
var changes = Changes{}
info, info_found := node.ProcessResponse(ext.WaitInfos, signal)
if info_found {
@ -116,7 +122,7 @@ func (ext *LockableExt) HandleErrorSignal(ctx *Context, node *Node, source NodeI
func (ext *LockableExt) HandleLinkSignal(ctx *Context, node *Node, source NodeID, signal *LinkSignal) (Messages, Changes) {
var messages Messages = nil
var changes Changes = nil
var changes = Changes{}
if ext.State == Unlocked {
switch signal.Action {
case "add":
@ -151,7 +157,7 @@ func (ext *LockableExt) HandleLinkSignal(ctx *Context, node *Node, source NodeID
func (ext *LockableExt) HandleSuccessSignal(ctx *Context, node *Node, source NodeID, signal *SuccessSignal) (Messages, Changes) {
var messages Messages = nil
var changes Changes = nil
var changes = Changes{}
if source == node.ID {
return messages, changes
}
@ -235,7 +241,7 @@ func (ext *LockableExt) HandleSuccessSignal(ctx *Context, node *Node, source Nod
// Handle a LockSignal and update the extensions owner/requirement states
func (ext *LockableExt) HandleLockSignal(ctx *Context, node *Node, source NodeID, signal *LockSignal) (Messages, Changes) {
var messages Messages = nil
var changes Changes = nil
var changes = Changes{}
switch signal.State {
case "lock":
@ -311,7 +317,7 @@ func (ext *LockableExt) HandleLockSignal(ctx *Context, node *Node, source NodeID
func (ext *LockableExt) HandleTimeoutSignal(ctx *Context, node *Node, source NodeID, signal *TimeoutSignal) (Messages, Changes) {
var messages Messages = nil
var changes Changes = nil
var changes = Changes{}
wait_info, found := node.ProcessResponse(ext.WaitInfos, signal)
if found == true {
@ -359,7 +365,7 @@ func (ext *LockableExt) HandleTimeoutSignal(ctx *Context, node *Node, source Nod
// LockSignal and LinkSignal Direct signals are processed to update the requirement/dependency/lock state
func (ext *LockableExt) Process(ctx *Context, node *Node, source NodeID, signal Signal) (Messages, Changes) {
var messages Messages = nil
var changes Changes = nil
var changes = Changes{}
switch signal.Direction() {
case Up:

@ -49,16 +49,13 @@ func RandID() NodeID {
type Changes map[ExtType][]string
func (changes *Changes) Add(ext ExtType, fields ...string) {
if *changes == nil {
*changes = Changes{}
}
current, exists := (*changes)[ext]
func (changes Changes) Add(ext ExtType, fields ...string) {
current, exists := changes[ext]
if exists == false {
current = []string{}
}
current = append(current, fields...)
(*changes)[ext] = current
changes[ext] = current
}
// Extensions are data attached to nodes that process signals
@ -550,7 +547,6 @@ func (node *Node) Process(ctx *Context, source NodeID, signal Signal) error {
for ext_type, ext := range(node.Extensions) {
ctx.Log.Logf("node_process", "PROCESSING_EXTENSION: %s/%s", node.ID, ext_type)
ext_messages, ext_changes := ext.Process(ctx, node, source, signal)
ctx.Log.Logf("gql", "%s changes %+v", reflect.TypeOf(ext), ext_changes)
if len(ext_messages) != 0 {
messages = append(messages, ext_messages...)
}
@ -561,7 +557,7 @@ func (node *Node) Process(ctx *Context, source NodeID, signal Signal) error {
}
}
}
ctx.Log.Logf("gql", "changes after process %+v", changes)
ctx.Log.Logf("changes", "Changes for %s after %+v - %+v", node.ID, reflect.TypeOf(signal), changes)
if len(messages) != 0 {
send_err := ctx.Send(messages)