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) {
state := BaseLockableState{
_type: "base_lockable",
_type: j.Type,
name: j.Name,
owner: nil,
dependencies: make([]Lockable, len(j.Dependencies)),

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