diff --git a/context.go b/context.go index 4a942cf..b8ad42b 100644 --- a/context.go +++ b/context.go @@ -69,7 +69,7 @@ type GQLContext struct { ThreadType reflect.Type } -/*func NewGQLContext(additional_types TypeList, extended_types ObjTypeMap, extended_queries FieldMap, extended_subscriptions FieldMap, extended_mutations FieldMap) (*GQLContext, error) { +func NewGQLContext(additional_types TypeList, extended_types ObjTypeMap, extended_queries FieldMap, extended_subscriptions FieldMap, extended_mutations FieldMap) (*GQLContext, error) { type_list := TypeList{ GQLTypeSignalInput(), } @@ -79,8 +79,9 @@ type GQLContext struct { } type_map := ObjTypeMap{} - type_map[reflect.TypeOf((*BaseLockable)(nil))] = GQLTypeBaseLockable() - type_map[reflect.TypeOf((*BaseThread)(nil))] = GQLTypeBaseThread() + type_map[reflect.TypeOf((*GraphNode)(nil))] = GQLTypeBaseNode() + type_map[reflect.TypeOf((*SimpleLockable)(nil))] = GQLTypeBaseLockable() + type_map[reflect.TypeOf((*SimpleThread)(nil))] = GQLTypeBaseThread() type_map[reflect.TypeOf((*GQLThread)(nil))] = GQLTypeGQLThread() type_map[reflect.TypeOf((*BaseSignal)(nil))] = GQLTypeSignal() @@ -92,7 +93,7 @@ type GQLContext struct { valid_lockables := ObjTypeMap{} valid_threads := ObjTypeMap{} - node_type := reflect.TypeOf((*GraphNode)(nil)).Elem() + node_type := reflect.TypeOf((*Node)(nil)).Elem() lockable_type := reflect.TypeOf((*Lockable)(nil)).Elem() thread_type := reflect.TypeOf((*Thread)(nil)).Elem() @@ -166,16 +167,16 @@ type GQLContext struct { } return &ctx, nil -}*/ +} func NewContext(db * badger.DB, log Logger, extra_nodes map[string]NodeLoadFunc, types TypeList, type_map ObjTypeMap, queries FieldMap, subscriptions FieldMap, mutations FieldMap) * Context { - /*gql, err := NewGQLContext(types, type_map, queries, subscriptions, mutations) + gql, err := NewGQLContext(types, type_map, queries, subscriptions, mutations) if err != nil { panic(err) - }*/ + } ctx := &Context{ - GQL: nil, + GQL: gql, DB: db, Log: log, Types: map[uint64]NodeDef{}, @@ -183,7 +184,7 @@ func NewContext(db * badger.DB, log Logger, extra_nodes map[string]NodeLoadFunc, - err := ctx.RegisterNodeType("graph_node", LoadGraphNode) + err = ctx.RegisterNodeType("graph_node", LoadGraphNode) if err != nil { panic(err) } diff --git a/gql_test.go b/gql_test.go index 99eac62..8560195 100644 --- a/gql_test.go +++ b/gql_test.go @@ -115,6 +115,6 @@ func TestGQLDBLoad(t * testing.T) { } else { fatalErr(t, err) } - (*GraphTester)(t).WaitForValue(ctx, update_channel_2, "thread_aborted", t1_loaded, 100*time.Millisecond, "Dicn't received thread_aborted on t1_loaded from t1_loaded") + (*GraphTester)(t).WaitForValue(ctx, update_channel_2, "thread_aborted", t1_loaded, 100*time.Millisecond, "Didn't received thread_aborted on t1_loaded from t1_loaded") } diff --git a/thread.go b/thread.go index db2f133..056518e 100644 --- a/thread.go +++ b/thread.go @@ -340,7 +340,9 @@ func (thread * SimpleThread) DeserializeInfo(ctx *Context, data []byte) (ThreadI } func RestoreSimpleThread(ctx *Context, thread Thread, j SimpleThreadJSON, nodes NodeMap) error { - thread.SetTimeout(j.Timeout, j.TimeoutAction) + if j.TimeoutAction != "" { + thread.SetTimeout(j.Timeout, j.TimeoutAction) + } if j.Parent != nil { p, err := LoadNodeRecurse(ctx, *j.Parent, nodes) @@ -354,9 +356,6 @@ func RestoreSimpleThread(ctx *Context, thread Thread, j SimpleThreadJSON, nodes thread.SetParent(p_t) } - // TODO: Call different loading functions(to return different ThreadInfo types, based on the j.Type, - // Will probably have to add another set of callbacks to the context for this, and since there's now 3 sets that need to be matching it could be useful to move them to a struct so it's easier to keep in sync - i := 0 for id, info_raw := range(j.Children) { child_node, err := LoadNodeRecurse(ctx, id, nodes) if err != nil { @@ -378,7 +377,6 @@ func RestoreSimpleThread(ctx *Context, thread Thread, j SimpleThreadJSON, nodes } thread.AddChild(child_t, parsed_info) - i++ } return RestoreSimpleLockable(ctx, thread, j.SimpleLockableJSON, nodes)