Module: Falqon::Pro::Message

Extended by:
T::Helpers, T::Sig
Defined in:
lib/falqon/pro/message.rb

Overview

A message in a queue

This class should typically not be instantiated directly, but rather be created by a queue instance.

Instance Method Summary collapse

Instance Method Details

#schedule_latervoid

This method returns an undefined value.

Schedule a message to be processed later

This method will move the message to the back of the pending queue.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/falqon/pro/message.rb', line 51

def schedule_later
  logger.debug "Scheduling message #{id} later on queue #{queue.name}"

  redis.with do |r|
    # Set message status
    r.hset("#{queue.id}:metadata:#{id}", :status, "pending")

    # Remove identifier from subqueues
    queue.pending.remove(id)
    queue.scheduled.remove(id)
    queue.dead.remove(id)

    # Add identifier to pending queue
    queue.pending.add(id)
  end

  nil
end

#schedule_nowvoid

This method returns an undefined value.

Schedule a message to be processed now

This method will move the message to the front of the pending queue.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/falqon/pro/message.rb', line 25

def schedule_now
  logger.debug "Scheduling message #{id} now on queue #{queue.name}"

  redis.with do |r|
    # Set message status
    r.hset("#{queue.id}:metadata:#{id}", :status, "pending")

    # Remove identifier from subqueues
    queue.pending.remove(id)
    queue.scheduled.remove(id)
    queue.dead.remove(id)

    # Add identifier to pending queue
    queue.pending.add(id, head: true)
  end

  nil
end