2023-07-09 14:30:30 -06:00
|
|
|
package graphvent
|
|
|
|
|
|
|
|
import (
|
2023-07-28 19:32:27 -06:00
|
|
|
"fmt"
|
2023-08-31 19:50:32 -06:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"capnproto.org/go/capnp/v3"
|
2023-07-29 16:00:01 -06:00
|
|
|
"github.com/google/uuid"
|
2023-08-31 19:50:32 -06:00
|
|
|
schema "github.com/mekkanized/graphvent/signal"
|
2023-07-28 10:04:31 -06:00
|
|
|
)
|
|
|
|
|
2023-07-09 14:30:30 -06:00
|
|
|
type SignalDirection int
|
|
|
|
const (
|
|
|
|
Up SignalDirection = iota
|
|
|
|
Down
|
|
|
|
Direct
|
|
|
|
)
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type SignalHeader struct {
|
2023-09-02 17:30:52 -06:00
|
|
|
Direction SignalDirection `gv:"0"`
|
|
|
|
ID uuid.UUID `gv:"1"`
|
|
|
|
ReqID uuid.UUID `gv:"2"`
|
2023-08-31 19:50:32 -06:00
|
|
|
}
|
2023-07-26 15:08:14 -06:00
|
|
|
|
|
|
|
type Signal interface {
|
2023-08-31 19:50:32 -06:00
|
|
|
Header() *SignalHeader
|
2023-08-10 23:43:10 -06:00
|
|
|
Permission() Tree
|
2023-07-09 14:30:30 -06:00
|
|
|
}
|
|
|
|
|
2023-08-12 11:26:19 -06:00
|
|
|
func WaitForResponse(listener chan Signal, timeout time.Duration, req_id uuid.UUID) (Signal, error) {
|
|
|
|
var timeout_channel <- chan time.Time
|
|
|
|
if timeout > 0 {
|
|
|
|
timeout_channel = time.After(timeout)
|
|
|
|
}
|
|
|
|
|
|
|
|
for true {
|
|
|
|
select {
|
|
|
|
case signal := <- listener:
|
|
|
|
if signal == nil {
|
|
|
|
return nil, fmt.Errorf("LISTENER_CLOSED")
|
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
if signal.Header().ReqID == req_id {
|
2023-08-12 11:26:19 -06:00
|
|
|
return signal, nil
|
|
|
|
}
|
|
|
|
case <-timeout_channel:
|
|
|
|
return nil, fmt.Errorf("LISTENER_TIMEOUT")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("UNREACHABLE")
|
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func WaitForSignal[S Signal](listener chan Signal, timeout time.Duration, check func(S)bool) (S, error) {
|
2023-07-28 19:32:27 -06:00
|
|
|
var zero S
|
2023-07-30 13:19:51 -06:00
|
|
|
var timeout_channel <- chan time.Time
|
|
|
|
if timeout > 0 {
|
|
|
|
timeout_channel = time.After(timeout)
|
|
|
|
}
|
2023-07-28 19:32:27 -06:00
|
|
|
for true {
|
|
|
|
select {
|
2023-08-08 14:00:17 -06:00
|
|
|
case signal := <- listener:
|
|
|
|
if signal == nil {
|
2023-08-31 19:50:32 -06:00
|
|
|
return zero, fmt.Errorf("LISTENER_CLOSED")
|
2023-07-28 19:32:27 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
sig, ok := signal.(S)
|
|
|
|
if ok == true {
|
|
|
|
if check(sig) == true {
|
|
|
|
return sig, nil
|
2023-07-28 19:32:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case <-timeout_channel:
|
2023-08-31 19:50:32 -06:00
|
|
|
return zero, fmt.Errorf("LISTENER_TIMEOUT")
|
2023-07-28 19:32:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return zero, fmt.Errorf("LOOP_ENDED")
|
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func NewSignalHeader(direction SignalDirection) SignalHeader {
|
2023-08-10 23:43:10 -06:00
|
|
|
id := uuid.New()
|
2023-08-31 19:50:32 -06:00
|
|
|
header := SignalHeader{
|
|
|
|
ID: id,
|
|
|
|
ReqID: id,
|
|
|
|
Direction: direction,
|
2023-08-10 23:43:10 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
return header
|
2023-08-10 23:43:10 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func NewRespHeader(req_id uuid.UUID, direction SignalDirection) SignalHeader {
|
|
|
|
header := SignalHeader{
|
|
|
|
ID: uuid.New(),
|
|
|
|
ReqID: req_id,
|
|
|
|
Direction: direction,
|
2023-07-09 14:30:30 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
return header
|
2023-07-09 14:30:30 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func SerializeHeader(header SignalHeader, root schema.SignalHeader) error {
|
|
|
|
root.SetDirection(uint8(header.Direction))
|
|
|
|
id_ser, err := header.ID.MarshalBinary()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
root.SetId(id_ser)
|
2023-08-07 20:26:02 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
req_id_ser, err := header.ReqID.MarshalBinary()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
root.SetReqID(req_id_ser)
|
|
|
|
return nil
|
2023-08-01 20:55:15 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func DeserializeHeader(header schema.SignalHeader) (SignalHeader, error) {
|
|
|
|
id_ser, err := header.Id()
|
|
|
|
if err != nil {
|
|
|
|
return SignalHeader{}, err
|
|
|
|
}
|
|
|
|
id, err := uuid.FromBytes(id_ser)
|
|
|
|
if err != nil {
|
|
|
|
return SignalHeader{}, err
|
2023-08-01 20:55:15 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
req_id_ser, err := header.ReqID()
|
|
|
|
if err != nil {
|
|
|
|
return SignalHeader{}, err
|
|
|
|
}
|
|
|
|
req_id, err := uuid.FromBytes(req_id_ser)
|
|
|
|
if err != nil {
|
|
|
|
return SignalHeader{}, err
|
|
|
|
}
|
2023-08-10 23:43:10 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
return SignalHeader{
|
|
|
|
ID: id,
|
|
|
|
ReqID: req_id,
|
|
|
|
Direction: SignalDirection(header.Direction()),
|
|
|
|
}, nil
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type CreateSignal struct {
|
|
|
|
SignalHeader
|
2023-07-23 21:14:15 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func (signal *CreateSignal) Header() *SignalHeader {
|
|
|
|
return &signal.SignalHeader
|
2023-08-07 20:26:02 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
func (signal *CreateSignal) Permission() Tree {
|
|
|
|
return Tree{
|
|
|
|
uint64(CreateSignalType): nil,
|
2023-07-23 21:14:15 -06:00
|
|
|
}
|
2023-07-09 14:30:30 -06:00
|
|
|
}
|
2023-07-21 13:59:52 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func NewCreateSignal() *CreateSignal {
|
|
|
|
return &CreateSignal{
|
|
|
|
NewSignalHeader(Direct),
|
2023-07-27 16:21:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type StartSignal struct {
|
|
|
|
SignalHeader
|
2023-07-27 18:37:06 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
func (signal *StartSignal) Header() *SignalHeader {
|
|
|
|
return &signal.SignalHeader
|
|
|
|
}
|
|
|
|
func (signal *StartSignal) Permission() Tree {
|
2023-08-10 23:43:10 -06:00
|
|
|
return Tree{
|
2023-08-31 19:50:32 -06:00
|
|
|
uint64(StartSignalType): nil,
|
2023-08-10 23:43:10 -06:00
|
|
|
}
|
2023-07-28 10:04:31 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
func NewStartSignal() *StartSignal {
|
|
|
|
return &StartSignal{
|
|
|
|
NewSignalHeader(Direct),
|
2023-07-21 13:59:52 -06:00
|
|
|
}
|
|
|
|
}
|
2023-07-28 11:59:01 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type StopSignal struct {
|
|
|
|
SignalHeader
|
2023-08-10 23:43:10 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
func (signal *StopSignal) Header() *SignalHeader {
|
|
|
|
return &signal.SignalHeader
|
2023-07-28 11:59:01 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
func (signal *StopSignal) Permission() Tree {
|
2023-08-10 23:43:10 -06:00
|
|
|
return Tree{
|
2023-08-31 19:50:32 -06:00
|
|
|
uint64(StopSignalType): nil,
|
2023-08-10 23:43:10 -06:00
|
|
|
}
|
2023-07-31 19:22:33 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
func NewStopSignal() *StopSignal {
|
|
|
|
return &StopSignal{
|
|
|
|
NewSignalHeader(Direct),
|
2023-07-28 11:59:01 -06:00
|
|
|
}
|
|
|
|
}
|
2023-07-28 12:46:06 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type ErrorSignal struct {
|
|
|
|
SignalHeader
|
|
|
|
Error string
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
func (signal *ErrorSignal) Header() *SignalHeader {
|
|
|
|
return &signal.SignalHeader
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
func (signal *ErrorSignal) MarshalBinary() ([]byte, error) {
|
|
|
|
arena := capnp.SingleSegment(nil)
|
|
|
|
msg, seg, err := capnp.NewMessage(arena)
|
2023-07-28 19:32:27 -06:00
|
|
|
if err != nil {
|
2023-08-31 19:50:32 -06:00
|
|
|
return nil, err
|
2023-07-28 19:32:27 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
root, err := schema.NewRootErrorSignal(seg)
|
2023-07-28 19:32:27 -06:00
|
|
|
if err != nil {
|
2023-08-31 19:50:32 -06:00
|
|
|
return nil, err
|
2023-07-28 19:32:27 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
root.SetError(signal.Error)
|
2023-08-06 12:47:47 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
header, err := root.NewHeader()
|
2023-07-28 19:32:27 -06:00
|
|
|
if err != nil {
|
2023-08-31 19:50:32 -06:00
|
|
|
return nil, err
|
2023-07-28 19:32:27 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
err = SerializeHeader(signal.SignalHeader, header)
|
2023-07-28 19:32:27 -06:00
|
|
|
if err != nil {
|
2023-08-31 19:50:32 -06:00
|
|
|
return nil, err
|
2023-07-28 19:32:27 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
return msg.Marshal()
|
|
|
|
}
|
|
|
|
func (signal *ErrorSignal) Deserialize(ctx *Context, data []byte) error {
|
|
|
|
msg, err := capnp.Unmarshal(data)
|
2023-07-28 19:32:27 -06:00
|
|
|
if err != nil {
|
2023-08-31 19:50:32 -06:00
|
|
|
return err
|
2023-07-28 19:32:27 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
root, err := schema.ReadRootErrorSignal(msg)
|
2023-07-28 19:32:27 -06:00
|
|
|
if err != nil {
|
2023-08-31 19:50:32 -06:00
|
|
|
return err
|
2023-07-28 19:32:27 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
header, err := root.Header()
|
2023-07-28 19:32:27 -06:00
|
|
|
if err != nil {
|
2023-08-31 19:50:32 -06:00
|
|
|
return err
|
2023-07-28 19:32:27 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
signal.Error, err = root.Error()
|
2023-07-28 19:32:27 -06:00
|
|
|
if err != nil {
|
2023-08-31 19:50:32 -06:00
|
|
|
return err
|
2023-07-28 19:32:27 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
signal.SignalHeader, err = DeserializeHeader(header)
|
2023-07-28 19:32:27 -06:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
func (signal *ErrorSignal) Permission() Tree {
|
|
|
|
return Tree{
|
|
|
|
uint64(ErrorSignalType): nil,
|
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
func NewErrorSignal(req_id uuid.UUID, fmt_string string, args ...interface{}) Signal {
|
|
|
|
return &ErrorSignal{
|
|
|
|
NewRespHeader(req_id, Direct),
|
|
|
|
fmt.Sprintf(fmt_string, args...),
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type ACLTimeoutSignal struct {
|
|
|
|
SignalHeader
|
|
|
|
}
|
|
|
|
func (signal *ACLTimeoutSignal) Header() *SignalHeader {
|
|
|
|
return &signal.SignalHeader
|
|
|
|
}
|
|
|
|
func (signal *ACLTimeoutSignal) Permission() Tree {
|
|
|
|
return Tree{
|
|
|
|
uint64(ACLTimeoutSignalType): nil,
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
}
|
|
|
|
func NewACLTimeoutSignal(req_id uuid.UUID) *ACLTimeoutSignal {
|
|
|
|
sig := &ACLTimeoutSignal{
|
|
|
|
NewRespHeader(req_id, Direct),
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
return sig
|
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type StatusSignal struct {
|
|
|
|
SignalHeader
|
|
|
|
Source NodeID
|
|
|
|
Status string
|
|
|
|
}
|
|
|
|
func (signal *StatusSignal) Header() *SignalHeader {
|
|
|
|
return &signal.SignalHeader
|
|
|
|
}
|
|
|
|
func (signal *StatusSignal) Permission() Tree {
|
|
|
|
return Tree{
|
|
|
|
uint64(StatusSignalType): nil,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func NewStatusSignal(source NodeID, status string) *StatusSignal {
|
|
|
|
return &StatusSignal{
|
|
|
|
NewSignalHeader(Up),
|
|
|
|
source,
|
|
|
|
status,
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type LinkSignal struct {
|
|
|
|
SignalHeader
|
|
|
|
NodeID
|
|
|
|
Action string
|
|
|
|
}
|
|
|
|
func (signal *LinkSignal) Header() *SignalHeader {
|
|
|
|
return &signal.SignalHeader
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
const (
|
|
|
|
LinkActionBase = "LINK_ACTION"
|
|
|
|
LinkActionAdd = "ADD"
|
|
|
|
)
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func (signal *LinkSignal) Permission() Tree {
|
|
|
|
return Tree{
|
|
|
|
uint64(LinkSignalType): Tree{
|
|
|
|
Hash(LinkActionBase, signal.Action): nil,
|
|
|
|
},
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
}
|
|
|
|
func NewLinkSignal(action string, id NodeID) Signal {
|
|
|
|
return &LinkSignal{
|
|
|
|
NewSignalHeader(Direct),
|
|
|
|
id,
|
|
|
|
action,
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type LockSignal struct {
|
|
|
|
SignalHeader
|
|
|
|
State string
|
|
|
|
}
|
|
|
|
func (signal *LockSignal) Header() *SignalHeader {
|
|
|
|
return &signal.SignalHeader
|
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
const (
|
|
|
|
LockStateBase = "LOCK_STATE"
|
|
|
|
)
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func (signal *LockSignal) Permission() Tree {
|
|
|
|
return Tree{
|
|
|
|
uint64(LockSignalType): Tree{
|
|
|
|
Hash(LockStateBase, signal.State): nil,
|
|
|
|
},
|
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func NewLockSignal(state string) *LockSignal {
|
|
|
|
return &LockSignal{
|
|
|
|
NewSignalHeader(Direct),
|
|
|
|
state,
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type ReadSignal struct {
|
|
|
|
SignalHeader
|
|
|
|
Extensions map[ExtType][]string `json:"extensions"`
|
|
|
|
}
|
|
|
|
func (signal *ReadSignal) MarshalBinary() ([]byte, error) {
|
|
|
|
arena := capnp.SingleSegment(nil)
|
|
|
|
msg, seg, err := capnp.NewMessage(arena)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
root, err := schema.NewRootReadSignal(seg)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
header, err := root.NewHeader()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
err = SerializeHeader(signal.SignalHeader, header)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
extensions, err := root.NewExtensions(int32(len(signal.Extensions)))
|
2023-07-29 00:28:44 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
i := 0
|
|
|
|
for ext_type, fields := range(signal.Extensions) {
|
|
|
|
extension := extensions.At(i)
|
|
|
|
extension.SetType(uint64(ext_type))
|
|
|
|
f, err := extension.NewFields(int32(len(fields)))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
for j, field := range(fields) {
|
|
|
|
err := f.Set(j, field)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
i += 1
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
return msg.Marshal()
|
|
|
|
}
|
|
|
|
func (signal *ReadSignal) Header() *SignalHeader {
|
|
|
|
return &signal.SignalHeader
|
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func (signal *ReadSignal) Permission() Tree {
|
|
|
|
ret := Tree{}
|
|
|
|
for ext, fields := range(signal.Extensions) {
|
|
|
|
field_tree := Tree{}
|
|
|
|
for _, field := range(fields) {
|
|
|
|
field_tree[Hash(FieldNameBase, field)] = nil
|
|
|
|
}
|
|
|
|
ret[uint64(ext)] = field_tree
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
return Tree{uint64(ReadSignalType): ret}
|
|
|
|
}
|
|
|
|
func NewReadSignal(exts map[ExtType][]string) *ReadSignal {
|
|
|
|
return &ReadSignal{
|
|
|
|
NewSignalHeader(Direct),
|
|
|
|
exts,
|
|
|
|
}
|
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type ReadResultSignal struct {
|
|
|
|
SignalHeader
|
|
|
|
NodeID NodeID
|
|
|
|
NodeType NodeType
|
|
|
|
Extensions map[ExtType]map[string]SerializedValue
|
|
|
|
}
|
|
|
|
func (signal *ReadResultSignal) Header() *SignalHeader {
|
|
|
|
return &signal.SignalHeader
|
|
|
|
}
|
|
|
|
func (signal *ReadResultSignal) Permission() Tree {
|
|
|
|
return Tree{
|
|
|
|
uint64(ReadResultSignalType): nil,
|
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
func NewReadResultSignal(req_id uuid.UUID, node_id NodeID, node_type NodeType, exts map[ExtType]map[string]SerializedValue) *ReadResultSignal {
|
|
|
|
return &ReadResultSignal{
|
|
|
|
NewRespHeader(req_id, Direct),
|
|
|
|
node_id,
|
|
|
|
node_type,
|
|
|
|
exts,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|