Class: PackAPI::ValuesInBackgroundBatches

Inherits:
ValuesInBatches show all
Includes:
Enumerable
Defined in:
lib/pack_api/values_in_background_batches.rb

Instance Attribute Summary collapse

Attributes inherited from ValuesInBatches

#batch_size, #kwargs, #method, #optional_attributes

Instance Method Summary collapse

Methods inherited from ValuesInBatches

#batch

Constructor Details

#initialize(method:, batch_size:, optional_attributes: nil, **kwargs, &block) ⇒ ValuesInBackgroundBatches

Returns a new instance of ValuesInBackgroundBatches.



9
10
11
12
# File 'lib/pack_api/values_in_background_batches.rb', line 9

def initialize(method:, batch_size:, optional_attributes: nil, **kwargs, &block)
  super
  @low_watermark = 1
end

Instance Attribute Details

#background_workerObject (readonly)

Returns the value of attribute background_worker.



7
8
9
# File 'lib/pack_api/values_in_background_batches.rb', line 7

def background_worker
  @background_worker
end

#low_watermarkObject (readonly)

Returns the value of attribute low_watermark.



7
8
9
# File 'lib/pack_api/values_in_background_batches.rb', line 7

def low_watermark
  @low_watermark
end

Instance Method Details

#eachObject



14
15
16
17
18
19
20
21
# File 'lib/pack_api/values_in_background_batches.rb', line 14

def each
  @background_worker = Rails.env.test? ?
     Concurrent::ImmediateExecutor.new :
     Concurrent::SingleThreadExecutor.new
  super
  background_worker.shutdown
  @background_worker = nil
end