Sha256: 9ec4eda77dc8c29be006e87ab001454ae3001addd528abe17b60ae51c9b7f9db
Contents?: true
Size: 917 Bytes
Versions: 18
Compression:
Stored size: 917 Bytes
Contents
module ProconBypassMan module Background class JobRunner MAX_QUEUE_SIZE = 100 def self.start! new.start! end # for test def stop! return unless defined?(@thread) @thread.kill end def start! return if defined?(@thread) @thread = Thread.new do while(item = self.class.queue.pop) begin JobPerformer.new(klass: item[:reporter_class], args: item[:args]).perform sleep(1) rescue => e ProconBypassMan.logger.error(e) end end end self end def self.queue @@queue ||= Queue.new end def self.push(hash) if queue.size > MAX_QUEUE_SIZE ProconBypassMan.logger.error('Over queue size cap!!') return end queue.push(hash) end end end end
Version data entries
18 entries across 18 versions & 1 rubygems