Sha256: 892ab9d89aa27f64c87d47320cf5b94d760c6d02a2100e74952cd34a44b3655f
Contents?: true
Size: 1.37 KB
Versions: 4
Compression:
Stored size: 1.37 KB
Contents
module Chillout class Worker attr_reader :dispatcher, :queue, :logger def initialize(dispatcher, queue, logger, container_class=CreationsContainer) @dispatcher = dispatcher @queue = queue @logger = logger @container_class = container_class end def get_all_containers_to_process all_containers = [queue.pop] loop do begin all_containers << queue.pop(true) rescue ThreadError break end end all_containers end def merge_containers(containers_to_merge) creations_container = @container_class.new for container in containers_to_merge creations_container.merge(container) end creations_container end def send_creations(creations_container) dispatcher.send_creations(creations_container) logger.info "Sending metrics" rescue Dispatcher::SendCreationsFailed queue << creations_container logger.error "Sending metrics failed" end def send_startup_message dispatcher.send_startup_message logger.info "Sending startup message" end def run send_startup_message loop do containers_to_merge = get_all_containers_to_process creations_container = merge_containers(containers_to_merge) send_creations(creations_container) sleep 5 end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
chillout-0.5.3 | lib/chillout/worker.rb |
chillout-0.5.2 | lib/chillout/worker.rb |
chillout-0.5.1 | lib/chillout/worker.rb |
chillout-0.5.0 | lib/chillout/worker.rb |