Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set `State["PreviousStateGuid"] in StateHistory #208

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/floe/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ def end?
def start_workflow
return if context.state_name

context.state["Name"] = start_at
context.state["Name"] = start_at
context.state["Input"] = context.execution["Input"].dup
context.state["Guid"] = SecureRandom.uuid

context.execution["StartTime"] = Time.now.utc.iso8601

self
Expand All @@ -185,7 +187,7 @@ def credentials
private

def step!
next_state = {"Name" => context.next_state}
next_state = {"Name" => context.next_state, "Guid" => SecureRandom.uuid, "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")
Expand All @@ -197,9 +199,6 @@ def step!
context.state = next_state
end

# Avoiding State#running? because that is potentially expensive.
# State#run_nonblock! already called running? via State#ready? and
# called State#finished -- which is what Context#state_finished? is detecting
def end_workflow!
context.execution["EndTime"] = context.state["FinishedTime"]
end
Expand Down
1 change: 0 additions & 1 deletion lib/floe/workflow/state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def run_nonblock!
end

def start(_input)
context.state["Guid"] = SecureRandom.uuid
context.state["EnteredTime"] = Time.now.utc.iso8601

logger.info("Running state: [#{long_name}] with input [#{context.input}]...")
Expand Down