Skip to content

Commit

Permalink
Set State["PreviousStateGuid"] in StateHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Jun 6, 2024
1 parent 80ba650 commit 1ca465c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 13 additions & 6 deletions lib/floe/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,20 @@ def current_state
private

def step_next
if context.next_state
# if rerunning due to an error (and we are using Retry)
if context.state_name == context.next_state && context.failed? && context.state.key?("Retrier")
restore_values = context.state.slice("RetryCount", "Input", "Retrier")
end
context.state = {"Name" => context.next_state, "Input" => context.output}.merge!(restore_values || {})
context.state_history << context.state

return unless context.next_state

next_state = {"Name" => context.next_state, "PreviousStateGuid" => context.state["Guid"]}

# if rerunning due to an error (and we are using Retry)
if context.state_name == context.next_state && context.failed? && context.state.key?("Retrier")
next_state.merge!(context.state.slice("RetryCount", "Input", "Retrier"))
else
next_state["Input"] = context.output
end

context.state = next_state
end
end
end
2 changes: 0 additions & 2 deletions lib/floe/workflow/state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ def finish
level = context.output&.[]("Error") ? :error : :info
logger.public_send(level, "Running state: [#{long_name}] with input [#{context.input}]...Complete #{context.next_state ? "- next state [#{context.next_state}]" : "workflow -"} output: [#{context.output}]")

context.state_history << context.state

0
end

Expand Down

0 comments on commit 1ca465c

Please sign in to comment.