From 6355cc42262588334bd0dd4a507533964e7066ed Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Sun, 2 Jul 2023 12:17:53 -0600 Subject: [PATCH] Moved timeout info to thread state, and fixed restore to add handlers and actions --- lockable.go | 2 +- thread.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lockable.go b/lockable.go index 6c6f001..7e2f219 100644 --- a/lockable.go +++ b/lockable.go @@ -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)), diff --git a/thread.go b/thread.go index f238fbf..d30682f 100644 --- a/thread.go +++ b/thread.go @@ -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 {