You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
Class: AWS::SimpleWorkflow::ActivityTaskCollection
- Inherits:
-
Object
- Object
- AWS::SimpleWorkflow::ActivityTaskCollection
- Defined in:
- lib/aws/simple_workflow/activity_task_collection.rb
Instance Attribute Summary collapse
-
#domain ⇒ Domain
readonly
Instance Method Summary collapse
-
#count(task_list) ⇒ Count
Returns the number of tasks in the specified
task_list
. -
#poll(task_list, options = {}, &block) ⇒ Object
-
#poll_for_single_task(task_list, options = {}) {|activity_task| ... } ⇒ ActivityTask?
Returns an activity task when one is available,
nil
otherwise.
Instance Attribute Details
#domain ⇒ Domain (readonly)
31 32 33 |
# File 'lib/aws/simple_workflow/activity_task_collection.rb', line 31 def domain @domain end |
Instance Method Details
#count(task_list) ⇒ Count
Note:
This operation is eventually consistent. The results are best effort and may not exactly reflect recent updates and changes.
Returns the number of tasks in the specified task_list
.
count = activity_tasks.count('task-list-name')
count.truncated? #=> false
count.to_i #=> 7
47 48 49 50 51 52 53 |
# File 'lib/aws/simple_workflow/activity_task_collection.rb', line 47 def count task_list = {} [:domain] = domain.name [:task_list] = { :name => task_list } response = client.count_pending_activity_tasks() Count.new(response.data['count'], response.data['truncated']) end |
#poll(task_list, options = {}, &block) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/aws/simple_workflow/activity_task_collection.rb', line 108 def poll task_list, = {}, &block loop do begin poll_for_single_task(task_list, ) do |activity_task| yield(activity_task) end rescue Timeout::Error retry end end nil end |
#poll_for_single_task(task_list, options = {}) {|activity_task| ... } ⇒ ActivityTask?
Returns an activity task when one is
available, nil
otherwise. If you call this function with
a block, nil
is always returned.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/aws/simple_workflow/activity_task_collection.rb', line 73 def poll_for_single_task task_list, = {}, &block client_opts = {} client_opts[:domain] = domain.name client_opts[:task_list] = { :name => task_list } client_opts[:identity] = identity_opt() response = client.poll_for_activity_task(client_opts) if response.data['taskToken'] activity_task = ActivityTask.new(domain, response.data) if block_given? begin yield(activity_task) activity_task.complete! unless activity_task.responded? rescue ActivityTask::CancelRequestedError activity_task.cancel! unless activity_task.responded? rescue StandardError => e unless activity_task.responded? reason = "UNTRAPPED ERROR: #{e.}" details = e.backtrace.join("\n") activity_task.fail!(:reason => reason, :details => details) end raise e end nil else activity_task end else nil end end |