2023-07-09 14:30:30 -06:00
|
|
|
package graphvent
|
|
|
|
|
|
|
|
import (
|
2023-09-05 00:08:09 -06:00
|
|
|
"crypto/ecdh"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"reflect"
|
|
|
|
"runtime"
|
|
|
|
"sync"
|
2023-10-29 18:26:14 -06:00
|
|
|
"time"
|
2023-09-12 19:00:48 -06:00
|
|
|
"github.com/google/uuid"
|
2023-09-05 00:08:09 -06:00
|
|
|
|
|
|
|
badger "github.com/dgraph-io/badger/v3"
|
2023-07-27 23:15:58 -06:00
|
|
|
)
|
|
|
|
|
2023-07-28 00:04:18 -06:00
|
|
|
var (
|
|
|
|
NodeNotFoundError = errors.New("Node not found in DB")
|
2023-08-07 20:26:02 -06:00
|
|
|
ECDH = ecdh.X25519()
|
2023-07-28 00:04:18 -06:00
|
|
|
)
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type ExtensionInfo struct {
|
|
|
|
Type reflect.Type
|
|
|
|
Data interface{}
|
|
|
|
}
|
2023-08-01 20:55:15 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type NodeInfo struct {
|
|
|
|
Extensions []ExtType
|
2023-08-01 20:55:15 -06:00
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
type TypeInfo struct {
|
2023-09-06 18:29:35 -06:00
|
|
|
Reflect reflect.Type
|
|
|
|
Type SerializedType
|
2023-10-29 18:26:14 -06:00
|
|
|
TypeSerialize TypeSerializeFn
|
|
|
|
Serialize SerializeFn
|
|
|
|
TypeDeserialize TypeDeserializeFn
|
|
|
|
Deserialize DeserializeFn
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
|
|
|
|
2023-09-05 00:08:09 -06:00
|
|
|
type KindInfo struct {
|
2023-09-06 18:29:35 -06:00
|
|
|
Reflect reflect.Kind
|
2023-10-29 18:26:14 -06:00
|
|
|
Base reflect.Type
|
2023-09-05 00:08:09 -06:00
|
|
|
Type SerializedType
|
2023-10-29 18:26:14 -06:00
|
|
|
TypeSerialize TypeSerializeFn
|
|
|
|
Serialize SerializeFn
|
|
|
|
TypeDeserialize TypeDeserializeFn
|
|
|
|
Deserialize DeserializeFn
|
2023-09-05 00:08:09 -06:00
|
|
|
}
|
|
|
|
|
2023-07-27 16:06:56 -06:00
|
|
|
// A Context stores all the data to run a graphvent process
|
2023-07-09 14:30:30 -06:00
|
|
|
type Context struct {
|
2023-07-10 22:31:43 -06:00
|
|
|
// DB is the database connection used to load and write nodes
|
2023-07-09 14:30:30 -06:00
|
|
|
DB * badger.DB
|
2023-07-27 16:06:56 -06:00
|
|
|
// Logging interface
|
2023-07-09 14:30:30 -06:00
|
|
|
Log Logger
|
2023-07-27 16:06:56 -06:00
|
|
|
// Map between database extension hashes and the registered info
|
2023-08-31 19:50:32 -06:00
|
|
|
Extensions map[ExtType]ExtensionInfo
|
|
|
|
ExtensionTypes map[reflect.Type]ExtType
|
2023-08-07 20:26:02 -06:00
|
|
|
// Map between databse policy hashes and the registered info
|
2023-08-31 19:50:32 -06:00
|
|
|
Policies map[PolicyType]reflect.Type
|
|
|
|
PolicyTypes map[reflect.Type]PolicyType
|
2023-07-29 00:28:44 -06:00
|
|
|
// Map between serialized signal hashes and the registered info
|
2023-08-31 19:50:32 -06:00
|
|
|
Signals map[SignalType]reflect.Type
|
|
|
|
SignalTypes map[reflect.Type]SignalType
|
2023-07-27 16:06:56 -06:00
|
|
|
// Map between database type hashes and the registered info
|
2023-08-31 19:50:32 -06:00
|
|
|
Nodes map[NodeType]NodeInfo
|
|
|
|
// Map between go types and registered info
|
2023-09-06 18:29:35 -06:00
|
|
|
Types map[SerializedType]*TypeInfo
|
|
|
|
TypeReflects map[reflect.Type]*TypeInfo
|
2023-08-31 19:50:32 -06:00
|
|
|
|
2023-09-06 18:29:35 -06:00
|
|
|
Kinds map[reflect.Kind]*KindInfo
|
|
|
|
KindTypes map[SerializedType]*KindInfo
|
2023-09-02 17:30:52 -06:00
|
|
|
|
2023-07-27 16:06:56 -06:00
|
|
|
// Routing map to all the nodes local to this context
|
2023-08-31 19:50:32 -06:00
|
|
|
nodeMapLock sync.RWMutex
|
|
|
|
nodeMap map[NodeID]*Node
|
2023-07-10 21:15:01 -06:00
|
|
|
}
|
|
|
|
|
2023-07-27 16:06:56 -06:00
|
|
|
// Register a NodeType to the context, with the list of extensions it requires
|
2023-07-26 00:42:12 -06:00
|
|
|
func (ctx *Context) RegisterNodeType(node_type NodeType, extensions []ExtType) error {
|
2023-08-31 19:50:32 -06:00
|
|
|
_, exists := ctx.Nodes[node_type]
|
2023-07-26 00:18:11 -06:00
|
|
|
if exists == true {
|
2023-08-31 19:50:32 -06:00
|
|
|
return fmt.Errorf("Cannot register node type %+v, type already exists in context", node_type)
|
2023-07-26 00:18:11 -06:00
|
|
|
}
|
|
|
|
|
2023-07-26 00:42:12 -06:00
|
|
|
ext_found := map[ExtType]bool{}
|
|
|
|
for _, extension := range(extensions) {
|
2023-08-31 19:50:32 -06:00
|
|
|
_, in_ctx := ctx.Extensions[extension]
|
2023-07-26 00:42:12 -06:00
|
|
|
if in_ctx == false {
|
2023-08-31 19:50:32 -06:00
|
|
|
return fmt.Errorf("Cannot register node type %+v, required extension %+v not in context", node_type, extension)
|
2023-07-26 00:42:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
_, duplicate := ext_found[extension]
|
|
|
|
if duplicate == true {
|
2023-08-31 19:50:32 -06:00
|
|
|
return fmt.Errorf("Duplicate extension %+v found in extension list", extension)
|
2023-07-26 00:42:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
ext_found[extension] = true
|
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
ctx.Nodes[node_type] = NodeInfo{
|
2023-07-26 00:42:12 -06:00
|
|
|
Extensions: extensions,
|
2023-07-26 00:18:11 -06:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func (ctx *Context) RegisterPolicy(reflect_type reflect.Type, policy_type PolicyType) error {
|
|
|
|
_, exists := ctx.Policies[policy_type]
|
2023-07-29 00:28:44 -06:00
|
|
|
if exists == true {
|
2023-08-31 19:50:32 -06:00
|
|
|
return fmt.Errorf("Cannot register policy of type %+v, type already exists in context", policy_type)
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
policy_info, err := GetStructInfo(ctx, reflect_type)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ctx.RegisterType(reflect_type, SerializedType(policy_type), nil, SerializeStruct(policy_info), nil, DeserializeStruct(policy_info))
|
2023-09-12 20:30:18 -06:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
ctx.Log.Logf("serialize_types", "Registered PolicyType: %+v - %+v", reflect_type, policy_type)
|
2023-09-12 20:30:18 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
ctx.Policies[policy_type] = reflect_type
|
|
|
|
ctx.PolicyTypes[reflect_type] = policy_type
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *Context)RegisterSignal(reflect_type reflect.Type, signal_type SignalType) error {
|
|
|
|
_, exists := ctx.Signals[signal_type]
|
|
|
|
if exists == true {
|
|
|
|
return fmt.Errorf("Cannot register signal of type %+v, type already exists in context", signal_type)
|
2023-07-29 00:28:44 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
signal_info, err := GetStructInfo(ctx, reflect_type)
|
2023-09-12 20:30:18 -06:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect_type, SerializedType(signal_type), nil, SerializeStruct(signal_info), nil, DeserializeStruct(signal_info))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Log.Logf("serialize_types", "Registered SignalType: %+v - %+v", reflect_type, signal_type)
|
2023-09-12 20:30:18 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
ctx.Signals[signal_type] = reflect_type
|
|
|
|
ctx.SignalTypes[reflect_type] = signal_type
|
2023-07-29 00:28:44 -06:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
func (ctx *Context)RegisterExtension(reflect_type reflect.Type, ext_type ExtType, data interface{}) error {
|
|
|
|
_, exists := ctx.Extensions[ext_type]
|
2023-07-09 14:30:30 -06:00
|
|
|
if exists == true {
|
2023-08-31 19:50:32 -06:00
|
|
|
return fmt.Errorf("Cannot register extension of type %+v, type already exists in context", ext_type)
|
2023-07-09 14:30:30 -06:00
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
elem_type := reflect_type.Elem()
|
2023-10-29 18:26:14 -06:00
|
|
|
elem_info, err := GetStructInfo(ctx, elem_type)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ctx.RegisterType(elem_type, SerializedType(ext_type), nil, SerializeStruct(elem_info), nil, DeserializeStruct(elem_info))
|
2023-09-12 20:30:18 -06:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
ctx.Log.Logf("serialize_types", "Registered ExtType: %+v - %+v", reflect_type, ext_type)
|
2023-09-12 19:00:48 -06:00
|
|
|
|
2023-08-31 19:50:32 -06:00
|
|
|
ctx.Extensions[ext_type] = ExtensionInfo{
|
|
|
|
Type: reflect_type,
|
2023-07-26 00:18:11 -06:00
|
|
|
Data: data,
|
2023-07-10 21:15:01 -06:00
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
ctx.ExtensionTypes[reflect_type] = ext_type
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
func (ctx *Context)RegisterKind(kind reflect.Kind, base reflect.Type, ctx_type SerializedType, type_serialize TypeSerializeFn, serialize SerializeFn, type_deserialize TypeDeserializeFn, deserialize DeserializeFn) error {
|
2023-09-02 17:30:52 -06:00
|
|
|
_, exists := ctx.Kinds[kind]
|
|
|
|
if exists == true {
|
|
|
|
return fmt.Errorf("Cannot register kind %+v, kind already exists in context", kind)
|
|
|
|
}
|
|
|
|
_, exists = ctx.KindTypes[ctx_type]
|
|
|
|
if exists == true {
|
|
|
|
return fmt.Errorf("0x%x is already registered, cannot use for %+v", ctx_type, kind)
|
|
|
|
}
|
|
|
|
if deserialize == nil {
|
|
|
|
return fmt.Errorf("Cannot register field without deserialize function")
|
|
|
|
}
|
|
|
|
if serialize == nil {
|
|
|
|
return fmt.Errorf("Cannot register field without serialize function")
|
|
|
|
}
|
|
|
|
|
2023-09-06 18:29:35 -06:00
|
|
|
info := KindInfo{
|
2023-10-29 18:26:14 -06:00
|
|
|
Reflect: kind,
|
|
|
|
Base: base,
|
|
|
|
Type: ctx_type,
|
|
|
|
TypeSerialize: type_serialize,
|
|
|
|
Serialize: serialize,
|
|
|
|
TypeDeserialize: type_deserialize,
|
|
|
|
Deserialize: deserialize,
|
2023-09-02 17:30:52 -06:00
|
|
|
}
|
2023-09-06 18:29:35 -06:00
|
|
|
ctx.KindTypes[ctx_type] = &info
|
|
|
|
ctx.Kinds[kind] = &info
|
2023-09-02 17:30:52 -06:00
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
ctx.Log.Logf("serialize_types", "Registered kind %+v, %+v", kind, ctx_type)
|
|
|
|
|
2023-09-02 17:30:52 -06:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
func (ctx *Context)RegisterType(reflect_type reflect.Type, ctx_type SerializedType, type_serialize TypeSerializeFn, serialize SerializeFn, type_deserialize TypeDeserializeFn, deserialize DeserializeFn) error {
|
2023-08-31 19:50:32 -06:00
|
|
|
_, exists := ctx.Types[ctx_type]
|
|
|
|
if exists == true {
|
|
|
|
return fmt.Errorf("Cannot register field of type %+v, type already exists in context", ctx_type)
|
|
|
|
}
|
|
|
|
_, exists = ctx.TypeReflects[reflect_type]
|
|
|
|
if exists == true {
|
|
|
|
return fmt.Errorf("Cannot register field with type %+v, type already registered in context", reflect_type)
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
if type_serialize == nil || type_deserialize == nil {
|
|
|
|
kind_info, kind_registered := ctx.Kinds[reflect_type.Kind()]
|
|
|
|
if kind_registered == true {
|
|
|
|
if type_serialize == nil {
|
|
|
|
type_serialize = kind_info.TypeSerialize
|
|
|
|
}
|
|
|
|
if type_deserialize == nil {
|
|
|
|
type_deserialize = kind_info.TypeDeserialize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-11 21:47:53 -06:00
|
|
|
if serialize == nil || deserialize == nil {
|
2023-10-29 18:26:14 -06:00
|
|
|
kind_info, kind_registered := ctx.Kinds[reflect_type.Kind()]
|
|
|
|
if kind_registered == false {
|
|
|
|
return fmt.Errorf("No serialize/deserialize passed and none registered for kind %+v", reflect_type.Kind())
|
|
|
|
} else {
|
|
|
|
if serialize == nil {
|
|
|
|
serialize = kind_info.Serialize
|
|
|
|
}
|
|
|
|
if deserialize == nil {
|
|
|
|
deserialize = kind_info.Deserialize
|
|
|
|
}
|
|
|
|
}
|
2023-09-11 21:47:53 -06:00
|
|
|
}
|
|
|
|
|
2023-09-06 18:29:35 -06:00
|
|
|
type_info := TypeInfo{
|
|
|
|
Reflect: reflect_type,
|
|
|
|
Type: ctx_type,
|
2023-10-29 18:26:14 -06:00
|
|
|
TypeSerialize: type_serialize,
|
2023-08-31 19:50:32 -06:00
|
|
|
Serialize: serialize,
|
2023-10-29 18:26:14 -06:00
|
|
|
TypeDeserialize: type_deserialize,
|
2023-08-31 19:50:32 -06:00
|
|
|
Deserialize: deserialize,
|
|
|
|
}
|
2023-10-29 18:26:14 -06:00
|
|
|
|
2023-09-06 18:29:35 -06:00
|
|
|
ctx.Types[ctx_type] = &type_info
|
|
|
|
ctx.TypeReflects[reflect_type] = &type_info
|
2023-08-31 19:50:32 -06:00
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
ctx.Log.Logf("serialize_types", "Registered Type: %+v - %+v", reflect_type, ctx_type)
|
2023-09-11 21:47:53 -06:00
|
|
|
|
2023-07-09 14:30:30 -06:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-28 12:46:06 -06:00
|
|
|
func (ctx *Context) AddNode(id NodeID, node *Node) {
|
2023-08-31 19:50:32 -06:00
|
|
|
ctx.nodeMapLock.Lock()
|
|
|
|
ctx.nodeMap[id] = node
|
|
|
|
ctx.nodeMapLock.Unlock()
|
2023-07-28 12:46:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *Context) Node(id NodeID) (*Node, bool) {
|
2023-08-31 19:50:32 -06:00
|
|
|
ctx.nodeMapLock.RLock()
|
|
|
|
node, exists := ctx.nodeMap[id]
|
|
|
|
ctx.nodeMapLock.RUnlock()
|
2023-07-28 12:46:06 -06:00
|
|
|
return node, exists
|
|
|
|
}
|
|
|
|
|
2023-10-06 20:04:53 -06:00
|
|
|
func (ctx *Context) Stop(id NodeID) error {
|
|
|
|
ctx.nodeMapLock.Lock()
|
|
|
|
defer ctx.nodeMapLock.Unlock()
|
|
|
|
node, exists := ctx.nodeMap[id]
|
|
|
|
if exists == false {
|
|
|
|
return fmt.Errorf("%s is not a node in ctx", id)
|
|
|
|
}
|
|
|
|
|
|
|
|
err := node.Stop(ctx)
|
|
|
|
delete(ctx.nodeMap, id)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *Context) StopAll() {
|
|
|
|
ctx.nodeMapLock.Lock()
|
|
|
|
for id, node := range(ctx.nodeMap) {
|
|
|
|
node.Stop(ctx)
|
|
|
|
delete(ctx.nodeMap, id)
|
|
|
|
}
|
|
|
|
ctx.nodeMapLock.Unlock()
|
|
|
|
}
|
|
|
|
|
2023-07-28 00:04:18 -06:00
|
|
|
// Get a node from the context, or load from the database if not loaded
|
2023-08-31 19:50:32 -06:00
|
|
|
func (ctx *Context) getNode(id NodeID) (*Node, error) {
|
2023-07-28 12:46:06 -06:00
|
|
|
target, exists := ctx.Node(id)
|
|
|
|
|
2023-07-27 15:49:21 -06:00
|
|
|
if exists == false {
|
2023-07-27 16:48:39 -06:00
|
|
|
var err error
|
|
|
|
target, err = LoadNode(ctx, id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-07-27 15:49:21 -06:00
|
|
|
}
|
2023-07-27 16:48:39 -06:00
|
|
|
return target, nil
|
|
|
|
}
|
|
|
|
|
2023-11-03 21:41:06 -06:00
|
|
|
// Route Messages to dest. Currently only local context routing is supported
|
2023-08-08 14:00:17 -06:00
|
|
|
func (ctx *Context) Send(messages Messages) error {
|
2023-08-07 20:26:02 -06:00
|
|
|
for _, msg := range(messages) {
|
2023-08-15 18:23:06 -06:00
|
|
|
if msg.Dest == ZeroID {
|
|
|
|
panic("Can't send to null ID")
|
|
|
|
}
|
2023-08-31 19:50:32 -06:00
|
|
|
target, err := ctx.getNode(msg.Dest)
|
2023-08-07 20:26:02 -06:00
|
|
|
if err == nil {
|
|
|
|
select {
|
2023-08-08 14:00:17 -06:00
|
|
|
case target.MsgChan <- msg:
|
|
|
|
ctx.Log.Logf("signal", "Sent %s -> %+v", target.ID, msg)
|
2023-08-07 20:26:02 -06:00
|
|
|
default:
|
|
|
|
buf := make([]byte, 4096)
|
|
|
|
n := runtime.Stack(buf, false)
|
|
|
|
stack_str := string(buf[:n])
|
2023-08-08 14:00:17 -06:00
|
|
|
return fmt.Errorf("SIGNAL_OVERFLOW: %s - %s", msg.Dest, stack_str)
|
2023-08-07 20:26:02 -06:00
|
|
|
}
|
|
|
|
} else if errors.Is(err, NodeNotFoundError) {
|
|
|
|
// TODO: Handle finding nodes in other contexts
|
|
|
|
return err
|
|
|
|
} else {
|
|
|
|
return err
|
2023-07-27 16:48:39 -06:00
|
|
|
}
|
2023-07-27 15:49:21 -06:00
|
|
|
}
|
2023-08-07 20:26:02 -06:00
|
|
|
return nil
|
2023-07-27 15:49:21 -06:00
|
|
|
}
|
|
|
|
|
2023-09-02 17:30:52 -06:00
|
|
|
// Create a new Context with the base library content added
|
|
|
|
func NewContext(db * badger.DB, log Logger) (*Context, error) {
|
|
|
|
ctx := &Context{
|
|
|
|
DB: db,
|
|
|
|
Log: log,
|
|
|
|
Policies: map[PolicyType]reflect.Type{},
|
|
|
|
PolicyTypes: map[reflect.Type]PolicyType{},
|
|
|
|
Extensions: map[ExtType]ExtensionInfo{},
|
|
|
|
ExtensionTypes: map[reflect.Type]ExtType{},
|
|
|
|
Signals: map[SignalType]reflect.Type{},
|
|
|
|
SignalTypes: map[reflect.Type]SignalType{},
|
|
|
|
Nodes: map[NodeType]NodeInfo{},
|
|
|
|
nodeMap: map[NodeID]*Node{},
|
2023-09-06 18:29:35 -06:00
|
|
|
Types: map[SerializedType]*TypeInfo{},
|
|
|
|
TypeReflects: map[reflect.Type]*TypeInfo{},
|
|
|
|
Kinds: map[reflect.Kind]*KindInfo{},
|
|
|
|
KindTypes: map[SerializedType]*KindInfo{},
|
2023-09-02 17:30:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Pointer, nil, PointerType, SerializeTypeElem, SerializePointer, DeserializeTypePointer, DeserializePointer)
|
2023-09-02 17:30:52 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Bool, reflect.TypeOf(true), BoolType, nil, SerializeBool, nil, DeserializeBool[bool])
|
2023-09-03 17:50:12 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-30 01:25:18 -06:00
|
|
|
err = ctx.RegisterKind(reflect.String, reflect.TypeOf(""), StringType, nil, SerializeString, nil, DeserializeString[string])
|
2023-09-03 17:50:12 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Float32, reflect.TypeOf(float32(0)), Float32Type, nil, SerializeFloat32, nil, DeserializeFloat32[float32])
|
|
|
|
if err != nil {
|
2023-09-03 17:50:12 -06:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Float64, reflect.TypeOf(float64(0)), Float64Type, nil, SerializeFloat64, nil, DeserializeFloat64[float64])
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-09-03 17:50:12 -06:00
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Uint, reflect.TypeOf(uint(0)), UIntType, nil, SerializeUint32, nil, DeserializeUint32[uint])
|
2023-09-02 17:30:52 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Uint8, reflect.TypeOf(uint8(0)), UInt8Type, nil, SerializeUint8, nil, DeserializeUint8[uint8])
|
2023-09-02 17:30:52 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Uint16, reflect.TypeOf(uint16(0)), UInt16Type, nil, SerializeUint16, nil, DeserializeUint16[uint16])
|
2023-09-02 17:30:52 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Uint32, reflect.TypeOf(uint32(0)), UInt32Type, nil, SerializeUint32, nil, DeserializeUint32[uint32])
|
2023-09-02 17:30:52 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Uint64, reflect.TypeOf(uint64(0)), UInt64Type, nil, SerializeUint64, nil, DeserializeUint64[uint64])
|
2023-09-02 17:30:52 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Int, reflect.TypeOf(int(0)), IntType, nil, SerializeInt32, nil, DeserializeUint32[int])
|
2023-09-03 17:50:12 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-09-02 17:30:52 -06:00
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Int8, reflect.TypeOf(int8(0)), Int8Type, nil, SerializeInt8, nil, DeserializeUint8[int8])
|
2023-09-03 17:50:12 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Int16, reflect.TypeOf(int16(0)), Int16Type, nil, SerializeInt16, nil, DeserializeUint16[int16])
|
2023-09-03 17:50:12 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Int32, reflect.TypeOf(int32(0)), Int32Type, nil, SerializeInt32, nil, DeserializeUint32[int32])
|
2023-09-03 17:50:12 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Int64, reflect.TypeOf(int64(0)), Int64Type, nil, SerializeInt64, nil, DeserializeUint64[int64])
|
2023-09-03 17:50:12 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-11-03 21:41:06 -06:00
|
|
|
wait_info_type := reflect.TypeOf(WaitInfo{})
|
|
|
|
wait_info_info, err := GetStructInfo(ctx, wait_info_type)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = ctx.RegisterType(wait_info_type, WaitInfoType, nil, SerializeStruct(wait_info_info), nil, DeserializeStruct(wait_info_info))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.TypeOf(time.Duration(0)), DurationType, nil, nil, nil, DeserializeUint64[time.Duration])
|
2023-09-02 17:30:52 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.TypeOf(time.Time{}), TimeType, nil, SerializeGob, nil, DeserializeGob[time.Time])
|
2023-09-11 21:47:53 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-09-03 17:50:12 -06:00
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Map, nil, MapType, SerializeTypeMap, SerializeMap, DeserializeTypeMap, DeserializeMap)
|
2023-09-03 17:50:12 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Array, nil, ArrayType, SerializeTypeArray, SerializeArray, DeserializeTypeArray, DeserializeArray)
|
2023-09-11 21:47:53 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-09-03 17:50:12 -06:00
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterKind(reflect.Slice, nil, SliceType, SerializeTypeElem, SerializeSlice, DeserializeTypeSlice, DeserializeSlice)
|
2023-09-02 17:30:52 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
var ptr interface{} = nil
|
|
|
|
err = ctx.RegisterKind(reflect.Interface, reflect.TypeOf(&ptr).Elem(), InterfaceType, nil, SerializeInterface, nil, DeserializeInterface)
|
2023-09-02 18:49:37 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.TypeOf(SerializedType(0)), SerializedTypeSerialized, nil, SerializeUint64, nil, DeserializeUint64[SerializedType])
|
2023-09-20 19:14:28 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.TypeOf(Changes{}), ChangesSerialized, SerializeTypeStub, SerializeSlice, DeserializeTypeStub[Changes], DeserializeSlice)
|
2023-10-10 11:23:44 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.TypeOf(ExtType(0)), ExtTypeSerialized, nil, SerializeUint64, nil, DeserializeUint64[ExtType])
|
2023-09-12 19:00:48 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.TypeOf(NodeType(0)), NodeTypeSerialized, nil, SerializeUint64, nil, DeserializeUint64[NodeType])
|
2023-09-11 21:47:53 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.TypeOf(PolicyType(0)), PolicyTypeSerialized, nil, SerializeUint64, nil, DeserializeUint64[PolicyType])
|
2023-09-11 21:47:53 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-01 20:45:44 -06:00
|
|
|
node_id_type := reflect.TypeOf(RandID())
|
2023-10-30 01:25:18 -06:00
|
|
|
err = ctx.RegisterType(node_id_type, NodeIDType, SerializeTypeStub, SerializeUUID, DeserializeTypeStub[NodeID], DeserializeUUID[NodeID])
|
2023-09-11 21:47:53 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-01 20:45:44 -06:00
|
|
|
uuid_type := reflect.TypeOf(uuid.UUID{})
|
2023-10-30 01:25:18 -06:00
|
|
|
err = ctx.RegisterType(uuid_type, UUIDType, SerializeTypeStub, SerializeUUID, DeserializeTypeStub[uuid.UUID], DeserializeUUID[uuid.UUID])
|
2023-09-12 19:00:48 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.TypeOf(Up), SignalDirectionType, nil, SerializeUint8, nil, DeserializeUint8[SignalDirection])
|
2023-09-12 19:00:48 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.TypeOf(ReqState(0)), ReqStateType, nil, SerializeUint8, nil, DeserializeUint8[ReqState])
|
2023-09-12 19:00:48 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.TypeOf(Tree{}), TreeType, SerializeTypeStub, nil, DeserializeTypeStub[Tree], nil)
|
2023-09-12 19:40:06 -06:00
|
|
|
|
2023-09-12 16:56:01 -06:00
|
|
|
var extension Extension = nil
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.ValueOf(&extension).Type().Elem(), ExtSerialized, nil, SerializeInterface, nil, DeserializeInterface)
|
2023-09-12 19:00:48 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
var policy Policy = nil
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.ValueOf(&policy).Type().Elem(), PolicySerialized, nil, SerializeInterface, nil, DeserializeInterface)
|
2023-09-11 21:47:53 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 19:40:06 -06:00
|
|
|
var signal Signal = nil
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterType(reflect.ValueOf(&signal).Type().Elem(), SignalSerialized, nil, SerializeInterface, nil, DeserializeInterface)
|
2023-09-12 19:40:06 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
pending_acl_type := reflect.TypeOf(PendingACL{})
|
2023-10-29 18:26:14 -06:00
|
|
|
pending_acl_info, err := GetStructInfo(ctx, pending_acl_type)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = ctx.RegisterType(pending_acl_type, PendingACLType, nil, SerializeStruct(pending_acl_info), nil, DeserializeStruct(pending_acl_info))
|
2023-09-12 19:40:06 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
pending_signal_type := reflect.TypeOf(PendingSignal{})
|
2023-10-29 18:26:14 -06:00
|
|
|
pending_signal_info, err := GetStructInfo(ctx, pending_signal_type)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = ctx.RegisterType(pending_signal_type, PendingSignalType, nil, SerializeStruct(pending_signal_info), nil, DeserializeStruct(pending_signal_info))
|
2023-09-11 21:47:53 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
queued_signal_type := reflect.TypeOf(QueuedSignal{})
|
2023-10-29 18:26:14 -06:00
|
|
|
queued_signal_info, err := GetStructInfo(ctx, queued_signal_type)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = ctx.RegisterType(queued_signal_type, QueuedSignalType, nil, SerializeStruct(queued_signal_info), nil, DeserializeStruct(queued_signal_info))
|
2023-09-11 21:47:53 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
node_type := reflect.TypeOf(Node{})
|
2023-10-29 18:26:14 -06:00
|
|
|
node_info, err := GetStructInfo(ctx, node_type)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = ctx.RegisterType(node_type, NodeStructType, nil, SerializeStruct(node_info), nil, DeserializeStruct(node_info))
|
2023-09-11 21:47:53 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-09-02 18:49:37 -06:00
|
|
|
|
2023-10-01 20:45:44 -06:00
|
|
|
req_info_type := reflect.TypeOf(ReqInfo{})
|
2023-10-29 18:26:14 -06:00
|
|
|
req_info_info, err := GetStructInfo(ctx, req_info_type)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = ctx.RegisterType(req_info_type, ReqInfoType, nil, SerializeStruct(req_info_info), nil, DeserializeStruct(req_info_info))
|
2023-10-01 20:45:44 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterExtension(reflect.TypeOf((*LockableExt)(nil)), LockableExtType, nil)
|
2023-09-02 17:30:52 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterExtension(reflect.TypeOf((*ListenerExt)(nil)), ListenerExtType, nil)
|
2023-09-12 19:00:48 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterExtension(reflect.TypeOf((*GroupExt)(nil)), GroupExtType, nil)
|
2023-09-12 19:00:48 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-09-12 16:56:01 -06:00
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
gql_ctx := NewGQLExtContext()
|
|
|
|
err = ctx.RegisterExtension(reflect.TypeOf((*GQLExt)(nil)), GQLExtType, gql_ctx)
|
2023-09-12 19:48:16 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-13 00:32:24 -06:00
|
|
|
err = ctx.RegisterExtension(reflect.TypeOf((*ACLExt)(nil)), ACLExtType, nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterExtension(reflect.TypeOf((*EventExt)(nil)), EventExtType, nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-13 10:56:49 -06:00
|
|
|
err = ctx.RegisterPolicy(reflect.TypeOf(MemberOfPolicy{}), MemberOfPolicyType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterPolicy(reflect.TypeOf(AllNodesPolicy{}), AllNodesPolicyType)
|
2023-09-12 19:48:16 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterPolicy(reflect.TypeOf(PerNodePolicy{}), PerNodePolicyType)
|
2023-08-31 19:50:32 -06:00
|
|
|
if err != nil {
|
2023-10-13 00:32:24 -06:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-13 13:45:30 -06:00
|
|
|
err = ctx.RegisterPolicy(reflect.TypeOf(ACLProxyPolicy{}), ACLProxyPolicyType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-16 00:54:10 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(StoppedSignal{}), StoppedSignalType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-15 15:14:33 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(AddSubGroupSignal{}), AddSubGroupSignalType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(RemoveSubGroupSignal{}), RemoveSubGroupSignalType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-13 00:32:24 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(ACLTimeoutSignal{}), ACLTimeoutSignalType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(ACLSignal{}), ACLSignalType)
|
|
|
|
if err != nil {
|
2023-09-02 17:30:52 -06:00
|
|
|
return nil, err
|
2023-07-09 14:30:30 -06:00
|
|
|
}
|
|
|
|
|
2023-10-11 18:11:24 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(RemoveMemberSignal{}), RemoveMemberSignalType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(AddMemberSignal{}), AddMemberSignalType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(StopSignal{}), StopSignalType)
|
2023-07-26 00:18:11 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(CreateSignal{}), CreateSignalType)
|
2023-07-26 11:56:10 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(StartSignal{}), StartSignalType)
|
2023-07-26 00:18:11 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(StatusSignal{}), StatusSignalType)
|
2023-07-26 00:18:11 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(ReadSignal{}), ReadSignalType)
|
2023-08-31 19:50:32 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(LockSignal{}), LockSignalType)
|
2023-07-25 09:51:55 -06:00
|
|
|
if err != nil {
|
2023-07-25 21:43:15 -06:00
|
|
|
return nil, err
|
2023-07-25 09:51:55 -06:00
|
|
|
}
|
2023-07-10 21:15:01 -06:00
|
|
|
|
2023-10-01 20:45:44 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(TimeoutSignal{}), TimeoutSignalType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(LinkSignal{}), LinkSignalType)
|
2023-08-01 20:55:15 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(ErrorSignal{}), ErrorSignalType)
|
2023-08-06 12:47:47 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-20 19:14:28 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(SuccessSignal{}), SuccessSignalType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-12 20:30:18 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(ReadResultSignal{}), ReadResultSignalType)
|
2023-08-06 12:47:47 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-29 18:26:14 -06:00
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(EventControlSignal{}), EventControlSignalType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ctx.RegisterSignal(reflect.TypeOf(EventStateSignal{}), EventStateSignalType)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-09-27 19:47:48 -06:00
|
|
|
err = ctx.RegisterNodeType(BaseNodeType, []ExtType{})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-10-03 20:14:26 -06:00
|
|
|
err = ctx.RegisterNodeType(GroupNodeType, []ExtType{GroupExtType})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ctx.RegisterNodeType(GQLNodeType, []ExtType{GQLExtType})
|
2023-07-26 23:57:50 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
schema, err := BuildSchema(gql_ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
gql_ctx.Schema = schema
|
|
|
|
|
2023-07-25 21:43:15 -06:00
|
|
|
return ctx, nil
|
2023-07-09 14:30:30 -06:00
|
|
|
}
|