Sha256: b4c132baa2bd5d2be558d1c721e3771c07ecf827067184fa93eae63568e7412f

Contents?: true

Size: 584 Bytes

Versions: 1

Compression:

Stored size: 584 Bytes

Contents

require 'logger'

module Quebert
  class Worker
    attr_accessor :exception_handler, :log_file, :backend
    
    include Quebert::Daemonizable
    
    def initialize
      yield self if block_given?
    end
    
    # Start the worker backend and intercept exceptions if a handler is provided
    def start
      while job = backend.reserve do
        begin
          job.perform
        rescue Exception => e
          exception_handler ? exception_handler.call(e) : raise(e)
        end
      end
    end
    
  protected
    def log(message)
      puts message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quebert-0.0.0 lib/quebert/worker.rb