lib/floe/workflow/state.rb in floe-0.8.0 vs lib/floe/workflow/state.rb in floe-0.9.0
- old
+ new
@@ -31,16 +31,16 @@
raise Floe::InvalidWorkflowError, "Missing \"Type\" field in state [#{name}]" if payload["Type"].nil?
raise Floe::InvalidWorkflowError, "State name [#{name}] must be less than or equal to 80 characters" if name.length > 80
end
- def wait(timeout: 5)
+ def wait(timeout: nil)
start = Time.now.utc
loop do
return 0 if ready?
- return Errno::EAGAIN if timeout.zero? || Time.now.utc - start > timeout
+ return Errno::EAGAIN if timeout && (timeout.zero? || Time.now.utc - start > timeout)
sleep(1)
end
end
@@ -91,10 +91,18 @@
def finished?
context.state.key?("FinishedTime")
end
+ def waiting?
+ context.state["WaitUntil"] && Time.now.utc <= Time.parse(context.state["WaitUntil"])
+ end
+
+ def wait_until
+ context.state["WaitUntil"] && Time.parse(context.state["WaitUntil"])
+ end
+
private
def wait_until!(seconds: nil, time: nil)
context.state["WaitUntil"] =
if seconds
@@ -102,13 +110,9 @@
elsif time.kind_of?(String)
time
else
time.iso8601
end
- end
-
- def waiting?
- context.state["WaitUntil"] && Time.now.utc <= Time.parse(context.state["WaitUntil"])
end
end
end
end