Skip to content

Commit

Permalink
Add purge command
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Cantero committed Mar 23, 2017
1 parent 2666bc9 commit c02d708
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions bin/cli/sqs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def dump_file(path, queue_name)
end
end

desc 'ls [QUEUE-NAME-PREFIX]', 'List queues'
desc 'ls [QUEUE-NAME-PREFIX]', 'Lists queues'
method_option :watch, aliases: '-w', type: :boolean, desc: 'watch queues'
method_option :watch_interval, type: :numeric, default: 10, desc: 'watch interval'
def ls(queue_name_prefix = '')
Expand All @@ -110,7 +110,7 @@ def ls(queue_name_prefix = '')
end
end

desc 'dump QUEUE-NAME', 'Dump messages from a queue into a JSON lines file'
desc 'dump QUEUE-NAME', 'Dumps messages from a queue into a JSON lines file'
method_option :number, aliases: '-n', type: :numeric, default: Float::INFINITY, desc: 'number of messages to dump'
method_option :path, aliases: '-p', type: :string, default: './', desc: 'path to save the dump file'
method_option :delete, aliases: '-d', type: :boolean, default: true, desc: 'delete from the queue'
Expand Down Expand Up @@ -144,7 +144,7 @@ def dump(queue_name)
file.close if file
end

desc 'requeue QUEUE-NAME PATH', 'Requeue messages from a dump file'
desc 'requeue QUEUE-NAME PATH', 'Requeues messages from a dump file'
def requeue(queue_name, path)
fail_task "Path #{path} not found" unless File.exist?(path)

Expand All @@ -155,7 +155,7 @@ def requeue(queue_name, path)
say "Requeued #{messages.size} messages from #{path} to #{queue_name}", :green
end

desc 'mv QUEUE-NAME-SOURCE QUEUE-NAME-TARGET', 'Move messages from one queue (source) to another (target)'
desc 'mv QUEUE-NAME-SOURCE QUEUE-NAME-TARGET', 'Moves messages from one queue (source) to another (target)'
method_option :number, aliases: '-n', type: :numeric, default: Float::INFINITY, desc: 'number of messages to move'
method_option :delete, aliases: '-d', type: :boolean, default: true, desc: 'delete from the queue'
def mv(queue_name_source, queue_name_target)
Expand All @@ -175,6 +175,13 @@ def mv(queue_name_source, queue_name_target)
say "Moved #{count} messages from #{queue_name_source} to #{queue_name_target}", :green
end
end

desc 'purge [QUEUE-NAME]', 'Deletes the messages in a queue'
def purge(queue_name)
sqs.purge_queue(queue_url: find_queue_url(queue_name))

say "Purge request sent for #{queue_name}. The message deletion process takes up to 60 seconds", :yellow
end
end
end
end
4 changes: 2 additions & 2 deletions bin/shoryuken
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Shoryuken

register(Shoryuken::CLI::SQS, 'sqs', 'sqs COMMAND', 'SQS commands')

desc 'start', 'Start shoryuken'
desc 'start', 'Starts shoryuken'
method_option :concurrency, aliases: '-c', type: :numeric, desc: 'Processor threads to use'
method_option :daemon, aliases: '-d', type: :boolean, desc: 'Daemonize process'
method_option :queues, aliases: '-q', type: :array, desc: 'Queues to process with optional weights'
Expand All @@ -39,7 +39,7 @@ module Shoryuken
Shoryuken::Runner.instance.run(opts.freeze)
end

desc 'version', 'Print version'
desc 'version', 'Prints version'
def version
say "Shoryuken #{Shoryuken::VERSION}"
end
Expand Down

0 comments on commit c02d708

Please sign in to comment.