Class: Falqon::Pro::CLI::Schedule

Inherits:
CLI::Schedule
  • Object
show all
Defined in:
lib/falqon/pro/cli/schedule.rb

Overview

Schedule a message for retry

This command moves a messages from the scheduled queue to the head or tail of the pending queue.

Usage:

falqon schedule -q, --queue=QUEUE

Options:

-q, --queue=QUEUE  # Queue name
   [--id=N]   # Message ID
   [--now]    # Move message to head of pending queue (default)
   [--later]  # Move message to tail of pending queue

Examples:

Move message with ID 1 to the head of the pending queue

$ falqon schedule --queue jobs --id 1 --now
Scheduled message with ID 1 for now

Move message with ID 1 to the tail of the pending queue

$ falqon schedule --queue jobs --id 1 --later
Scheduled message with ID 1 for later

Instance Method Summary collapse

Instance Method Details

#executeObject



37
38
39
40
41
42
43
44
# File 'lib/falqon/pro/cli/schedule.rb', line 37

def execute
  return super unless options[:id]

  # Schedule message
  options[:later] ? message.schedule_later : message.schedule_now

  puts "Scheduled message with ID #{options[:id]} for #{options[:later] ? 'later' : 'now'}"
end

#validateObject



28
29
30
31
32
33
34
35
# File 'lib/falqon/pro/cli/schedule.rb', line 28

def validate
  super

  raise "--now, and --later require --id" if [options[:now], options[:later]].any? && !options[:id]
  raise "No message with ID #{options[:id]}" if options[:id] && !message.exists?

  raise "--now, and --later are mutually exclusive" if [options[:now], options[:later]].count(true) > 1
end