Class: Falqon::Strategies::None

Inherits:
Falqon::Strategy
  • Object
show all
Defined in:
lib/falqon/strategies/none.rb

Overview

Retry strategy that does not retry

When a message fails to process, it is immediately marked as dead and moved to the dead subqueue.

Examples:

queue = Falqon::Queue.new("my_queue", retry_strategy: :none)
queue.push("Hello, World!")
queue.pop { raise Falqon::Error }
queue.inspect # => #<Falqon::Queue name="my_queue" pending=0 processing=0 scheduled=0 dead=1>

Instance Method Summary collapse

Instance Method Details

#retry(message, error) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/falqon/strategies/none.rb', line 21

def retry(message, error)
  queue.redis.with do |r|
    r.multi do |t|
      # Set error metadata
      t.hset(
        "#{queue.id}:metadata:#{message.id}",
        :retried_at, Time.now.to_i,
        :retry_error, error.message,
      )

      # Kill message immediately
      message.kill

      # Remove identifier from processing queue
      queue.processing.remove(message.id)

      # Set message status
      t.hset("#{queue.id}:metadata:#{message.id}", :status, "dead")
    end
  end
end