Sha256: 78340fc81eb037108436cdf922b60ccfa07e4659361a5097640b1e74a7bab5e5

Contents?: true

Size: 543 Bytes

Versions: 1

Compression:

Stored size: 543 Bytes

Contents

class Belated
  # The worker class that actually gets the jobs from the queue
  # and calls them. Expects the jobs to be procs.
  class Worker
    def initialize
      start_working
    end

    def start_working
      loop do
        job = Belated.fetch_job
        next unless job

        call_job(job)
        puts 'fetching jobs...'
      end
    end

    def call_job(job)
      if job.respond_to?(:call)
        pp job.call
      else
        pp job&.perform
      end
    rescue StandardError => e
      pp e.inspect
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
belated-0.2.0 lib/belated/worker.rb