Class: Plines::JobBatchList
- Inherits:
-
Struct
- Object
- Struct
- Plines::JobBatchList
- Includes:
- RedisObjectsHelpers
- Defined in:
- lib/plines/job_batch_list.rb
Overview
Represents a list of job batches that are grouped by some common trait (such as a user id).
Instance Attribute Summary collapse
-
#key ⇒ Object
(also: #id)
Returns the value of attribute key.
-
#pipeline ⇒ Object
Returns the value of attribute pipeline.
-
#qless ⇒ Object
readonly
Returns the value of attribute qless.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
- #all_with_external_dependency_timeout(dep_name) ⇒ Object
- #create_new_batch(batch_data, options = {}, &blk) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(pipeline, key) ⇒ JobBatchList
constructor
A new instance of JobBatchList.
- #most_recent_batch ⇒ Object
Methods included from RedisObjectsHelpers
#declared_redis_object_keys, included, #key_prefix, #new_redis_object
Constructor Details
#initialize(pipeline, key) ⇒ JobBatchList
Returns a new instance of JobBatchList.
12 13 14 15 16 |
# File 'lib/plines/job_batch_list.rb', line 12 def initialize(pipeline, key) super(pipeline, key) @qless = pipeline.configuration.qless_client_for(key) @redis = @qless.redis end |
Instance Attribute Details
#key ⇒ Object Also known as: id
Returns the value of attribute key
6 7 8 |
# File 'lib/plines/job_batch_list.rb', line 6 def key @key end |
#pipeline ⇒ Object
Returns the value of attribute pipeline
6 7 8 |
# File 'lib/plines/job_batch_list.rb', line 6 def pipeline @pipeline end |
#qless ⇒ Object (readonly)
Returns the value of attribute qless.
10 11 12 |
# File 'lib/plines/job_batch_list.rb', line 10 def qless @qless end |
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
10 11 12 |
# File 'lib/plines/job_batch_list.rb', line 10 def redis @redis end |
Instance Method Details
#all_with_external_dependency_timeout(dep_name) ⇒ Object
42 43 44 45 46 |
# File 'lib/plines/job_batch_list.rb', line 42 def all_with_external_dependency_timeout(dep_name) each.select do |batch| batch.timed_out_external_deps.include?(dep_name) end end |
#create_new_batch(batch_data, options = {}, &blk) ⇒ Object
24 25 26 27 28 |
# File 'lib/plines/job_batch_list.rb', line 24 def create_new_batch(batch_data, = {}, &blk) JobBatch.create(qless, pipeline, batch_id_for(last_batch_num.increment), batch_data, , &blk) end |
#each(&block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/plines/job_batch_list.rb', line 30 def each(&block) return enum_for(:each) unless block_given? 1.upto(last_batch_num.value) do |num| begin yield JobBatch.find(qless, pipeline, batch_id_for(num)) rescue JobBatch::CannotFindExistingJobBatchError # We can't yield a batch we can't find! end end end |