Class: Legion::CLI::Broker
- Inherits:
-
Thor
- Object
- Thor
- Legion::CLI::Broker
- Defined in:
- lib/legion/cli/broker_command.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
12 13 14 |
# File 'lib/legion/cli/broker_command.rb', line 12 def self.exit_on_failure? true end |
Instance Method Details
#cleanup ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/legion/cli/broker_command.rb', line 82 def cleanup out = formatter orphans = find_orphans if orphans.empty? out.success('No orphaned queues found') return end if [:json] out.json({ orphaned_queues: orphans, deleted: [:execute] }) delete_orphans(orphans) if [:execute] return end out.header("Orphaned Queues (#{orphans.size})") orphans.each { |q| out.warn(q) } out.spacer if [:execute] delete_orphans(orphans) out.success("Deleted #{orphans.size} orphaned queue(s)") else out.warn('Dry-run mode — pass --execute to delete') end rescue Legion::CLI::Error => e formatter.error(e.) exit(1) end |
#purge_topology ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/legion/cli/broker_command.rb', line 48 def purge_topology require 'legion/cli/admin_command' out = formatter exchanges = management_api("/exchanges/#{vhost_encoded}").map { |e| { name: e[:name], type: e[:type] } } candidates = Legion::CLI::AdminCommand.detect_old_exchanges(exchanges) if candidates.empty? out.success('No old v2.0 topology exchanges found.') return end if [:json] out.json({ candidates: candidates, deleted: [:execute] }) candidates.each { |e| management_delete("/exchanges/#{vhost_encoded}/#{ERB::Util.url_encode(e[:name])}") } if [:execute] return end out.header("Old v2.0 Exchanges (#{candidates.size})") candidates.each { |e| out.warn("#{e[:name]} (#{e[:type]})") } out.spacer if [:execute] candidates.each { |e| management_delete("/exchanges/#{vhost_encoded}/#{ERB::Util.url_encode(e[:name])}") } out.success("Purged #{candidates.size} exchange(s).") else out.warn('Dry-run mode — pass --execute to delete') end rescue Legion::CLI::Error => e formatter.error(e.) exit(1) end |
#stats ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/legion/cli/broker_command.rb', line 25 def stats out = formatter data = fetch_stats if [:json] out.json(data) else out.header('RabbitMQ Broker Stats') out.spacer out.detail({ queues: data[:queues], exchanges: data[:exchanges], consumers: data[:consumers], dlx: data[:dlx] }) end rescue Legion::CLI::Error => e formatter.error(e.) exit(1) end |