Sha256: b4f615c9e3445fdcb31830f8c5ca03bdb533959dc28dd8b53cb4d04c66053aa7
Contents?: true
Size: 912 Bytes
Versions: 6
Compression:
Stored size: 912 Bytes
Contents
module Larva class WorkerPool def self.start(processors) new(processors).start end attr_reader :processors, :workers def initialize(processors) @processors = processors end def start start_workers keep_workers_alive if workers.count > 0 end private def start_workers logger.info "Starting threads." @workers = processors.map do |topic, processor| Thread.new { start_worker(topic, processor) } end logger.info "Threads Started." end def start_worker(topic, processor) Larva::Listener.listen(topic, processor) rescue => e logger.error "Unexpected listener termination: #{e} #{e.backtrace}" end def keep_workers_alive sleep(5) while workers.all? { |t| t.alive? } logger.error "Some threads have died" end def logger Propono.config.logger end end end
Version data entries
6 entries across 6 versions & 1 rubygems