diff --git a/node.go b/node.go index e3df35b..a4b1bea 100644 --- a/node.go +++ b/node.go @@ -508,7 +508,7 @@ func (node *Node) Process(ctx *Context, source NodeID, signal Signal) error { return ctx.Send(messages) } -func GetCtx[T Extension, C any](ctx *Context, ext_type ExtType) (C, error) { +func GetCtx[C any](ctx *Context, ext_type ExtType) (C, error) { var zero_ctx C ext_info, ok := ctx.Extensions[ext_type] if ok == false { diff --git a/signal.go b/signal.go index 1aa6468..cd4570d 100644 --- a/signal.go +++ b/signal.go @@ -20,8 +20,12 @@ type SignalHeader struct { ReqID uuid.UUID `gv:"req_id"` } +func (header SignalHeader) Header() SignalHeader { + return header +} + type Signal interface { - Header() *SignalHeader + Header() SignalHeader Permission() Tree } @@ -95,9 +99,6 @@ type CreateSignal struct { SignalHeader } -func (signal CreateSignal) Header() *SignalHeader { - return &signal.SignalHeader -} func (signal CreateSignal) Permission() Tree { return Tree{ SerializedType(CreateSignalType): nil, @@ -113,9 +114,6 @@ func NewCreateSignal() *CreateSignal { type StartSignal struct { SignalHeader } -func (signal StartSignal) Header() *SignalHeader { - return &signal.SignalHeader -} func (signal StartSignal) Permission() Tree { return Tree{ SerializedType(StartSignalType): nil, @@ -130,9 +128,6 @@ func NewStartSignal() *StartSignal { type StopSignal struct { SignalHeader } -func (signal StopSignal) Header() *SignalHeader { - return &signal.SignalHeader -} func (signal StopSignal) Permission() Tree { return Tree{ SerializedType(StopSignalType): nil, @@ -148,9 +143,6 @@ type ErrorSignal struct { SignalHeader Error string } -func (signal ErrorSignal) Header() *SignalHeader { - return &signal.SignalHeader -} func (signal ErrorSignal) Permission() Tree { return Tree{ SerializedType(ErrorSignalType): nil, @@ -166,9 +158,6 @@ func NewErrorSignal(req_id uuid.UUID, fmt_string string, args ...interface{}) Si type ACLTimeoutSignal struct { SignalHeader } -func (signal ACLTimeoutSignal) Header() *SignalHeader { - return &signal.SignalHeader -} func (signal ACLTimeoutSignal) Permission() Tree { return Tree{ SerializedType(ACLTimeoutSignalType): nil, @@ -186,9 +175,6 @@ type StatusSignal struct { Source NodeID `gv:"source"` Status string `gv:"status"` } -func (signal StatusSignal) Header() *SignalHeader { - return &signal.SignalHeader -} func (signal StatusSignal) Permission() Tree { return Tree{ SerializedType(StatusSignalType): nil, @@ -207,9 +193,6 @@ type LinkSignal struct { NodeID Action string } -func (signal LinkSignal) Header() *SignalHeader { - return &signal.SignalHeader -} const ( LinkActionBase = "LINK_ACTION" @@ -235,9 +218,6 @@ type LockSignal struct { SignalHeader State string } -func (signal LockSignal) Header() *SignalHeader { - return &signal.SignalHeader -} const ( LockStateBase = "LOCK_STATE" @@ -262,9 +242,6 @@ type ReadSignal struct { SignalHeader Extensions map[ExtType][]string `json:"extensions"` } -func (signal ReadSignal) Header() *SignalHeader { - return &signal.SignalHeader -} func (signal ReadSignal) Permission() Tree { ret := Tree{} @@ -290,9 +267,6 @@ type ReadResultSignal struct { NodeType NodeType Extensions map[ExtType]map[string]SerializedValue } -func (signal ReadResultSignal) Header() *SignalHeader { - return &signal.SignalHeader -} func (signal ReadResultSignal) Permission() Tree { return Tree{ SerializedType(ReadResultSignalType): nil,