Moved timeout info to thread state, and fixed restore to add handlers and actions

graph-rework-2
noah metz 2023-07-02 12:17:53 -06:00
parent c9d9b9ac03
commit 6355cc4226
2 changed files with 7 additions and 2 deletions

@ -555,7 +555,7 @@ func LoadSimpleLockable(ctx * GraphContext, id NodeID) (GraphNode, error) {
func RestoreBaseLockableState(ctx * GraphContext, j BaseLockableStateJSON, loaded_nodes NodeMap) (*BaseLockableState, error) { func RestoreBaseLockableState(ctx * GraphContext, j BaseLockableStateJSON, loaded_nodes NodeMap) (*BaseLockableState, error) {
state := BaseLockableState{ state := BaseLockableState{
_type: "base_lockable", _type: j.Type,
name: j.Name, name: j.Name,
owner: nil, owner: nil,
dependencies: make([]Lockable, len(j.Dependencies)), dependencies: make([]Lockable, len(j.Dependencies)),

@ -77,6 +77,8 @@ type BaseThreadState struct {
type BaseThreadStateJSON struct { type BaseThreadStateJSON struct {
Parent *NodeID `json:"parent"` Parent *NodeID `json:"parent"`
Children map[NodeID]interface{} `json:"children"` Children map[NodeID]interface{} `json:"children"`
Timeout time.Time `json:"timeout"`
TimeoutAction string `json:"timeout_action"`
BaseLockableStateJSON BaseLockableStateJSON
} }
@ -97,6 +99,8 @@ func SaveBaseThreadState(state * BaseThreadState) BaseThreadStateJSON {
return BaseThreadStateJSON{ return BaseThreadStateJSON{
Parent: parent_id, Parent: parent_id,
Children: children, Children: children,
Timeout: state.timeout,
TimeoutAction: state.timeout_action,
BaseLockableStateJSON: lockable_state, BaseLockableStateJSON: lockable_state,
} }
} }
@ -122,7 +126,6 @@ func RestoreBaseThreadState(ctx * GraphContext, j BaseThreadStateJSON, loaded_no
if err != nil { if err != nil {
return nil, err return nil, err
} }
lockable_state._type = "thread_state"
state := BaseThreadState{ state := BaseThreadState{
BaseLockableState: *lockable_state, BaseLockableState: *lockable_state,
@ -131,6 +134,8 @@ func RestoreBaseThreadState(ctx * GraphContext, j BaseThreadStateJSON, loaded_no
child_info: map[NodeID]ThreadInfo{}, child_info: map[NodeID]ThreadInfo{},
InfoType: nil, InfoType: nil,
running: false, running: false,
timeout: j.Timeout,
timeout_action: j.TimeoutAction,
} }
if j.Parent != nil { if j.Parent != nil {