Module: Messagebus::Swarm::Controller::DroneFactoryConcerns

Included in:
Messagebus::Swarm::Controller
Defined in:
lib/messagebus/swarm/controller.rb

Overview

:nodoc: all

Instance Method Summary collapse

Instance Method Details

#build_drones(worker_configs, default_cluster_config, cluster_configs, swarm_control_logger, drone_logger) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/messagebus/swarm/controller.rb', line 235

def build_drones(worker_configs, default_cluster_config, cluster_configs, swarm_control_logger, drone_logger)
  drones = worker_configs.map do |worker_config|
    destination_name = worker_config.destination
    relevant_clusters = cluster_configs.select do |cluster_config|
      destinations = cluster_config.destinations
      destinations.include?(destination_name)
    end

    if relevant_clusters.empty?
      swarm_control_logger.warn "couldn't find any clusters to process #{destination_name}"
    end

    consumers = build_consumers(worker_config, relevant_clusters, destination_name, default_cluster_config, swarm_control_logger)
    drones = build_drone_instances(worker_config, consumers, destination_name, drone_logger)
  end.flatten

  drones
end