Class: MixedGauge::AllShardsInParallel
- Inherits:
-
Object
- Object
- MixedGauge::AllShardsInParallel
- Defined in:
- lib/mixed_gauge/all_shards_in_parallel.rb
Overview
Support parallel execution with each shard and deal with AR connection management in parallel execution.
Instance Method Summary collapse
- #each {|Class| ... } ⇒ MixedGauge::AllShardsInParallel
-
#flat_map {|Class| ... } ⇒ Array
A result.
-
#initialize(shards, service:) ⇒ AllShardsInParallel
constructor
A new instance of AllShardsInParallel.
-
#map {|Class| ... } ⇒ Array
A result.
Constructor Details
#initialize(shards, service:) ⇒ AllShardsInParallel
Returns a new instance of AllShardsInParallel.
7 8 9 10 |
# File 'lib/mixed_gauge/all_shards_in_parallel.rb', line 7 def initialize(shards, service:) @shards = shards @service = service end |
Instance Method Details
#each {|Class| ... } ⇒ MixedGauge::AllShardsInParallel
36 37 38 39 |
# File 'lib/mixed_gauge/all_shards_in_parallel.rb', line 36 def each(&block) map(&block) if block_given? self end |
#flat_map {|Class| ... } ⇒ Array
Returns A result.
28 29 30 |
# File 'lib/mixed_gauge/all_shards_in_parallel.rb', line 28 def flat_map(&block) map(&block).flatten end |
#map {|Class| ... } ⇒ Array
Returns A result.
16 17 18 19 20 21 22 |
# File 'lib/mixed_gauge/all_shards_in_parallel.rb', line 16 def map commands = @shards.map do |m| Expeditor::Command.new(service: @service) { m.connection_pool.with_connection { yield m } } end commands.each(&:start) commands.map(&:get) end |