Sha256: a3aa2e781de0de581c2fc3e3a14cc2aff74e97126610ce8a792348a89e020d40

Contents?: true

Size: 822 Bytes

Versions: 2

Compression:

Stored size: 822 Bytes

Contents

module QPush
  module Server
    module Apis
      class Fail < Base
        def initialize(job, error)
          @job = job
          @error = error
        end

        def call
          update_job
          stat_increment
          log_error
          update_history
        end

        private

        def update_job
          @job.mark_failed
          @job.retry if @job.retry_job?
          @job.morgue if @job.dead_job?
        end

        def stat_increment
          Server.redis { |c| c.hincrby(Server.keys[:stats], 'failed', 1) }
        end

        def log_error
          Server.log.err("Worker #{Server.worker.id} | Job FAILED | #{@job.klass} | #{@job.id} | #{@error.message}")
        end

        def update_history
          History.call(@job, false, @error)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qpush-0.1.10 lib/qpush/server/apis/fail.rb
qpush-0.1.8 lib/qpush/server/apis/fail.rb