Sha256: e0c0393a6c2a2dc4163ba8289c3f831cf8f5b5c6a5ddef0731fe9187f7ada624

Contents?: true

Size: 720 Bytes

Versions: 1

Compression:

Stored size: 720 Bytes

Contents

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

        def call
          load_type
          delay_job
        end

        private

        def delay_job
          QPush.redis.with do |conn|
            conn.hincrby(QPush.keys.stats, @stat, 1)
            conn.zadd(QPush.keys.delay, @time, @job.to_json)
          end
        end

        def load_type
          case @type
          when :delay
            @stat = 'delayed'
            @time = @job.delay_until
          when :retry
            @stat = 'retries'
            @time = @job.retry_at
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qpush-0.1.4 lib/qpush/server/apis/delay.rb