Class | AWS::SimpleWorkflow::DecisionTaskCollection |
In: |
lib/aws/simple_workflow/decision_task_collection.rb
|
Parent: | Object |
Provides an interface to count, and receive decision tasks ({DecisionTask} objects) from the service.
To get a count of decision tasks needing attention, call {count} with a task list name:
domain.decision_tasks.count('my-task-list').to_i #=> 7
To process a single task use {poll_for_single_task}:
domain.decision_tasks.poll_for_single_task('my-task-list') do |task| # this block is yielded to only if a task is found # within 60 seconds. end
At the end of the block, the decision task is auto-completed. If you prefer you can omit the block and nil or a {DecisionTask} will be returned.
if task = domain.decision_tasks.poll_for_single_task('my-task-list') # you need to call complete! or the decision task will time out task.complete! end
You can poll indefinetly for tasks in a loop with {poll}:
domain.decision_tasks.poll('my-task-list') do |task| # yields once for every decision task found end
Just like the block form above, the decision task is auto completed at the end of the block. Please note, if you call break or return from inside the block, you MUST call {DecisionTask#complete!} or the task will timeout.
Each decision task provides an enumerable collection of both new events ({DecisionTask#new_events}) and all events ({DecisionTask#events}).
Based on the events in the workflow execution history, you should call methods on the decision task. See {DecisionTask} for a complete list of decision methods.
domain | [R] | @return [Domain] |
Returns the number of decision tasks in the specified task_list.
count = decision_tasks.count('task-list-name') count.truncated? #=> false count.to_i #=> 7
@note This operation is eventually consistent. The results are best
effort and may not exactly reflect recent updates and changes.
@param [String] task_list Name of the task list to count
decision tasks for.
@return [Count] Returns a {Count} object that specifies the number
of decision tasks for the given task list. This count will also indiciate if the count was truncated.
Polls indefinetly for decision tasks. Each deicsion task found is yielded to the block. At the end of the block the decision task is auto-completed ({DecisionTask#complete!} is called).
# yields once for each decision task found, indefinetly domain.decision_tasks.poll do |decision_task| # make decisions here end
@note If you to terminate the block (by calling break or return)
then it is your responsibility to call #complete! on the decision task.
@param (see poll_for_single_task)
@option (see poll_for_single_task)
@yieldparam [DecisionTask] decision_task
@return [nil]
Polls the service for a single decision task. The service may hold the request for up to 60 seconds before responding.
# try to get a single task, may return nil when no tasks available task = domain.decision_tasks.poll_for_single_task('task-list') if task # make decisions ... task.complete! end
You can optionally pass a block and that will only be yielded to when a decision task is available within the 60 seconds.
domain.decision_tasks.poll_for_single_task('task-list') do |task| # make decisions # task.complete! is called for you at the end of the block end
With the block form you do not need to call complete! on the decision task. It will be called when the block exists.
@note If you are not using the block form you must call
{DecisionTask#complete!} yourself or your decision task will timeout.
@param [String] task_list Specifies the task list to poll for
decision tasks.
@param [Hash] options
@option options [String] :identity The identity of the decider
requesting a decision task. This will be recorded in the DecisionTaskStarted event in the workflow history. If +:identity+ is not passed then the hostname and process id will be sent (e.g. "hostname:pid").
@option options [Boolean] :reverse_event_order (false) When true,
the history events on the decision task will enumerate in reverse chronological order (newest events first). By default the events are enumerated in chronological order (oldest first).
@option options [Integer] :event_batch_size (1000) When enumerating
events on the decision task, multiple requests may be required to fetch all of the events. You can specify the maximum number of events to request each time (must not be greater than 1000).
@yieldparam [DecisionTask] decision_task
@return [DecisionTask,nil] Returns a decision task or nil. If
a block was passed then +nil+ is always returned. If a block is not passed, then +nil+ or a {DecisionTask} will be returned.