Sha256: 538f5b275969d609a23da47b3ac4d4797ddba9e6b2f088ccb04e95f7fcb65632

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 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.7 lib/qpush/server/apis/fail.rb
qpush-0.1.6 lib/qpush/server/apis/fail.rb