Changed event to require parent

gql_cataclysm
noah metz 2023-11-04 18:56:35 -06:00
parent ddb3854d00
commit c773ea2b14
4 changed files with 16 additions and 13 deletions

@ -8,10 +8,10 @@ import (
type EventExt struct {
Name string `gv:"name"`
State string `gv:"state"`
Parent *NodeID `gv:"parent"`
Parent NodeID `gv:"parent"`
}
func NewEventExt(parent *NodeID, name string) *EventExt {
func NewEventExt(parent NodeID, name string) *EventExt {
return &EventExt{
Name: name,
State: "init",
@ -80,8 +80,8 @@ func (ext *EventExt) Process(ctx *Context, node *Node, source NodeID, signal Sig
var messages Messages = nil
var changes Changes = nil
if signal.Direction() == Up && ext.Parent != nil {
messages = messages.Add(ctx, *ext.Parent, node, nil, signal)
if signal.Direction() == Up && ext.Parent != node.ID {
messages = messages.Add(ctx, ext.Parent, node, nil, signal)
}
return messages, changes

@ -1,9 +1,11 @@
package graphvent
import (
"reflect"
"testing"
"time"
"crypto/ed25519"
"reflect"
"testing"
"time"
"crypto/rand"
)
func TestEvent(t *testing.T) {
@ -12,8 +14,9 @@ func TestEvent(t *testing.T) {
fatalErr(t, err)
event_public, event_private, err := ed25519.GenerateKey(rand.Reader)
event_listener := NewListenerExt(100)
event, err := NewNode(ctx, nil, BaseNodeType, 100, nil, NewEventExt(nil, "Test Event"), &TestEventExt{time.Second}, event_listener)
event, err := NewNode(ctx, event_private, BaseNodeType, 100, nil, NewEventExt(KeyID(event_public), "Test Event"), &TestEventExt{time.Second}, event_listener)
fatalErr(t, err)
response, signals := testSend(t, ctx, NewEventControlSignal("ready?"), event, event)

@ -29,8 +29,8 @@ func (listener *ListenerExt) Type() ExtType {
// Send the signal to the channel, logging an overflow if it occurs
func (ext *ListenerExt) Process(ctx *Context, node *Node, source NodeID, signal Signal) (Messages, Changes) {
ctx.Log.Logf("listener", "LISTENER_PROCESS: %s - %+v", node.ID, reflect.TypeOf(signal))
ctx.Log.Logf("listener_debug", "LISTENER_DETAIL %+v", signal)
ctx.Log.Logf("listener", "%s - %+v", node.ID, reflect.TypeOf(signal))
ctx.Log.Logf("listener_debug", "%s->%s - %+v", source, node.ID, signal)
select {
case ext.Chan <- signal:
default:

@ -208,7 +208,7 @@ type SuccessSignal struct {
}
func (signal SuccessSignal) String() string {
return fmt.Sprintf("SuccessSignal(%s)", signal.SignalHeader)
return fmt.Sprintf("SuccessSignal(%s)", signal.ResponseHeader)
}
func (signal SuccessSignal) Permission() Tree {
@ -229,7 +229,7 @@ type ErrorSignal struct {
Error string
}
func (signal ErrorSignal) String() string {
return fmt.Sprintf("ErrorSignal(%s, %s)", signal.SignalHeader, signal.Error)
return fmt.Sprintf("ErrorSignal(%s, %s)", signal.ResponseHeader, signal.Error)
}
func (signal ErrorSignal) Permission() Tree {
return Tree{
@ -371,7 +371,7 @@ type ReadResultSignal struct {
}
func (signal ReadResultSignal) String() string {
return fmt.Sprintf("ReadResultSignal(%s, %s, %+v, %+v)", signal.SignalHeader, signal.NodeID, signal.NodeType, signal.Extensions)
return fmt.Sprintf("ReadResultSignal(%s, %s, %+v, %+v)", signal.ResponseHeader, signal.NodeID, signal.NodeType, signal.Extensions)
}
func (signal ReadResultSignal) Permission() Tree {