Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add purge command #344

Merged
merged 1 commit into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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