Fixed always initializing timeout on thread load. TODO: look at why loading it on thread load was causing the aborted event to not be sent

graph-rework-2
noah metz 2023-07-10 01:07:56 -06:00
parent 6a0a0762ad
commit 14b084b081
3 changed files with 14 additions and 15 deletions

@ -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)
}

@ -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")
}

@ -340,7 +340,9 @@ func (thread * SimpleThread) DeserializeInfo(ctx *Context, data []byte) (ThreadI
}
func RestoreSimpleThread(ctx *Context, thread Thread, j SimpleThreadJSON, nodes NodeMap) error {
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)