Sha256: 8efecc8eace6aa4ea305c221454a67fbb05b7f8fa7b041cc1e66eda6da8e0b24
Contents?: true
Size: 653 Bytes
Versions: 2
Compression:
Stored size: 653 Bytes
Contents
require_relative 'logging' class Belated # The worker class that actually gets the jobs from the queue # and calls them. Expects the jobs to be procs or # classes that have a perform method. class Worker include Logging def initialize(number: 1) @number = number start_working end def start_working loop do log "Worker #{@number} fetching jobs!" next unless (job = Belated.fetch_job) break if job.is_a?(Symbol) log "Worker #{@number} got job: #{job.inspect}" log job.perform rescue Errno::ECONNREFUSED, RangeError => e log e end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
belated-0.6.0 | lib/belated/worker.rb |
belated-0.5.7 | lib/belated/worker.rb |