bugs_bunny 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +23 -5
- data/VERSION +1 -1
- data/bugs_bunny.gemspec +3 -1
- data/features/exchanges.feature +15 -0
- data/features/queues.feature +1 -1
- data/lib/bugs_bunny.rb +1 -0
- data/lib/bugs_bunny/cli.rb +9 -3
- data/lib/bugs_bunny/exchange.rb +29 -0
- data/lib/bugs_bunny/helper.rb +1 -1
- data/lib/bugs_bunny/queue.rb +14 -7
- data/lib/bugs_bunny/rabbit.rb +21 -3
- metadata +4 -2
data/README.rdoc
CHANGED
@@ -7,13 +7,16 @@ RabbitMQ Playground
|
|
7
7
|
|
8
8
|
Run 'bbunny config' to create a rabbitmq.yml conf file, edit it, play.
|
9
9
|
|
10
|
-
|
11
10
|
=== bbunny queues
|
12
11
|
|
13
12
|
Lists all queues in the vhost.
|
14
13
|
|
15
|
-
|
16
|
-
|
14
|
+
+------+--------------+-------+-------+-------+--------+------+--------+
|
15
|
+
| Msgs | Name | Users | Ready | Noack | Commit | Acts | Memory |
|
16
|
+
+------+--------- ----+-------+-------+-------+--------+------+--------+
|
17
|
+
| 5 | (D) works | 1 | 5 | 0 | 0 | 0 | 4768 |
|
18
|
+
| 20 | (V) mapper | 10 | 0 | 20 | 0 | 0 | 14544 |
|
19
|
+
...
|
17
20
|
|
18
21
|
|
19
22
|
=== bbunny queues new works
|
@@ -40,19 +43,34 @@ Live inspection of the queue.
|
|
40
43
|
|
41
44
|
-------
|
42
45
|
QUEUE 1 (application/octet-stream): Mode 1
|
43
|
-
Consumer: todo-908051891800
|
46
|
+
Consumer: todo-908051891800
|
44
47
|
|
45
48
|
Body:
|
46
49
|
Improve Bugs Bunny
|
47
50
|
|
48
51
|
-------
|
49
52
|
QUEUE 2 (application/octet-stream): Mode 1
|
50
|
-
Consumer: todo-908051891800
|
53
|
+
Consumer: todo-908051891800
|
51
54
|
|
52
55
|
Body:
|
53
56
|
{:ruby => "object"}
|
54
57
|
|
55
58
|
|
59
|
+
=== bbunny exchanges
|
60
|
+
|
61
|
+
Exchanges
|
62
|
+
+---------------------------------------+---------+-----------+----------+
|
63
|
+
| Name | Kind | Durable | Delete |
|
64
|
+
+---------------------------------------+---------+-----------+----------+
|
65
|
+
| amq.direct | Direct | X | |
|
66
|
+
| amq.fanout | Fanout | X | |
|
67
|
+
| amq.headers | Headers | X | |
|
68
|
+
| amq.match | Headers | X | |
|
69
|
+
| amq.topic | Topic | X | |
|
70
|
+
| some.fanout | Fanout | | X |
|
71
|
+
...
|
72
|
+
|
73
|
+
|
56
74
|
=== Check out -h for all commands
|
57
75
|
|
58
76
|
Purge, delete, full CRUD ;)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/bugs_bunny.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bugs_bunny}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marcos Piccinini"]
|
@@ -29,12 +29,14 @@ Gem::Specification.new do |s|
|
|
29
29
|
"bugs_bunny.gemspec",
|
30
30
|
"cucumber.yml",
|
31
31
|
"features/bugs_bunny.feature",
|
32
|
+
"features/exchanges.feature",
|
32
33
|
"features/queues.feature",
|
33
34
|
"features/step_definitions/bugs_bunny_steps.rb",
|
34
35
|
"features/step_definitions/queue_steps.rb",
|
35
36
|
"features/support/env.rb",
|
36
37
|
"lib/bugs_bunny.rb",
|
37
38
|
"lib/bugs_bunny/cli.rb",
|
39
|
+
"lib/bugs_bunny/exchange.rb",
|
38
40
|
"lib/bugs_bunny/helper.rb",
|
39
41
|
"lib/bugs_bunny/queue.rb",
|
40
42
|
"lib/bugs_bunny/rabbit.rb",
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: Managing exchanges
|
2
|
+
In order to manage exchanges
|
3
|
+
A user should have a nice command to do it
|
4
|
+
|
5
|
+
Scenario: List exchanges
|
6
|
+
Given I run "exchanges"
|
7
|
+
Then I should see "Exchanges"
|
8
|
+
And I should see "Name"
|
9
|
+
And I should see "Kind"
|
10
|
+
And I should see "Durable"
|
11
|
+
And I should see "Delete"
|
12
|
+
And I should see "amq.fanout"
|
13
|
+
And I should see "Fanout"
|
14
|
+
And I should see "Direct"
|
15
|
+
And I should see "Topic"
|
data/features/queues.feature
CHANGED
data/lib/bugs_bunny.rb
CHANGED
data/lib/bugs_bunny/cli.rb
CHANGED
@@ -19,9 +19,7 @@ module BugsBunny
|
|
19
19
|
puts "Can`t do that."; exit
|
20
20
|
end
|
21
21
|
log "Connecting to rabbitmq #{Opt[:rabbit][:vhost]}"
|
22
|
-
AMQP.start(Opt[:rabbit])
|
23
|
-
rb.start!(argv)
|
24
|
-
end
|
22
|
+
AMQP.start(Opt[:rabbit]) { rb.start!(argv) }
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
@@ -39,6 +37,14 @@ module BugsBunny
|
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
40
|
+
def seed
|
41
|
+
parse_config
|
42
|
+
puts "Creating user and vhost"
|
43
|
+
puts `rabbitmqctl add_user #{Opt[:rabbit][:user]} #{Opt[:rabbit][:pass]}`
|
44
|
+
puts `rabbitmqctl add_vhost #{Opt[:rabbit][:vhost]}`
|
45
|
+
puts `rabbitmqctl set_permissions -p #{Opt[:rabbit][:vhost]} #{Opt[:rabbit][:user]} ".*" ".*" ".*"`
|
46
|
+
end
|
47
|
+
|
42
48
|
private
|
43
49
|
|
44
50
|
def log(*args)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module BugsBunny
|
2
|
+
class Exchange
|
3
|
+
attr_reader :name, :durable, :delete
|
4
|
+
|
5
|
+
def self.parse(txt)
|
6
|
+
return nil if txt =~ /Listing|\.\.\./
|
7
|
+
new(txt)
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(txt)
|
11
|
+
@name, @kind, @durable, @delete, @args = txt.split("\t")
|
12
|
+
end
|
13
|
+
|
14
|
+
def <=>(other)
|
15
|
+
@name <=> other.name
|
16
|
+
end
|
17
|
+
|
18
|
+
def kind
|
19
|
+
@kind.capitalize
|
20
|
+
end
|
21
|
+
|
22
|
+
def x(x)
|
23
|
+
eval(x) ? " X" : ""
|
24
|
+
end
|
25
|
+
|
26
|
+
def durable_x; x(@durable); end
|
27
|
+
def delete_x; x(@delete); end
|
28
|
+
end
|
29
|
+
end
|
data/lib/bugs_bunny/helper.rb
CHANGED
data/lib/bugs_bunny/queue.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module BugsBunny
|
2
2
|
class Queue
|
3
3
|
include Helper
|
4
|
-
attr_reader :name, :msgs, :users, :ready, :noack, :commit, :acts
|
4
|
+
attr_reader :name, :msgs, :users, :ready, :noack, :commit, :acts
|
5
5
|
@queues = []
|
6
6
|
|
7
7
|
def self.all
|
8
8
|
# possible with amqp?
|
9
|
-
`rabbitmqctl list_queues -p #{Opt[:rabbit][:vhost]} name durable auto_delete arguments
|
9
|
+
`rabbitmqctl list_queues -p #{Opt[:rabbit][:vhost]} name durable auto_delete arguments messages_ready messages_unacknowledged messages_uncommitted messages consumers transactions memory`.split("\n").each do |l|
|
10
10
|
next if l =~ /Listing|\.\./
|
11
11
|
@queues << BugsBunny::Queue.new(*l.split("\t"))
|
12
12
|
end
|
@@ -14,13 +14,13 @@ module BugsBunny
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.create(name)
|
17
|
-
MQ.queue(name).status do |msg, users|
|
17
|
+
MQ.queue(name, :durable => true).status do |msg, users|
|
18
18
|
puts "#{msg} messages, #{users} consumers."
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def initialize(*params)
|
23
|
-
@name, d, a, args, @
|
23
|
+
@name, d, a, args, @ready, @noack, @commit, @msgs,
|
24
24
|
@users, @acts, @memory = *params
|
25
25
|
@durable = eval(d) if d #ugly
|
26
26
|
@auto_delete = eval(a) if a #more ugly
|
@@ -40,13 +40,20 @@ module BugsBunny
|
|
40
40
|
EM.add_timer(1) { halt }
|
41
41
|
end
|
42
42
|
|
43
|
+
def memory
|
44
|
+
@memory #"%2.f"
|
45
|
+
end
|
46
|
+
|
43
47
|
def inspect
|
44
|
-
|
45
|
-
|
48
|
+
# xchange = MQ.fanout(@name)
|
49
|
+
#, :durable => false, :auto_delete => true)#, :internal => true)
|
50
|
+
#mq = MQ.queue(@name+"_bb", :exclusive => true)
|
51
|
+
@mq.subscribe(:ack => true) do |h, body| #, :nowait => false
|
46
52
|
print_queue(h, body)
|
47
53
|
end
|
48
54
|
end
|
49
|
-
alias :live
|
55
|
+
alias :live :inspect
|
56
|
+
alias :watch :inspect
|
50
57
|
|
51
58
|
def add(txt)
|
52
59
|
@mq.publish(txt)
|
data/lib/bugs_bunny/rabbit.rb
CHANGED
@@ -24,13 +24,14 @@ module BugsBunny
|
|
24
24
|
end
|
25
25
|
qs = BugsBunny::Queue.all
|
26
26
|
unless param
|
27
|
-
print_table "Queues", qs.
|
28
|
-
|
27
|
+
print_table "Queues", qs.sort, :msgs, :name_kind,
|
28
|
+
:users, :ready, :noack, :commit, :acts, :memory
|
29
29
|
else
|
30
30
|
qs.each(&:"#{param}")
|
31
31
|
end
|
32
32
|
halt
|
33
33
|
end
|
34
|
+
alias :qu :queues
|
34
35
|
|
35
36
|
def queue(q, action="info", *params)
|
36
37
|
rec = BugsBunny::Queue.new(q)
|
@@ -41,11 +42,28 @@ module BugsBunny
|
|
41
42
|
halt
|
42
43
|
end
|
43
44
|
end
|
45
|
+
alias :q :queue
|
44
46
|
|
45
47
|
def exchanges
|
46
|
-
|
48
|
+
arr = `rabbitmqctl list_exchanges -p #{Opt[:rabbit][:vhost]} name type durable auto_delete arguments`.split("\n").map do |e|
|
49
|
+
BugsBunny::Exchange.parse(e)
|
50
|
+
end.reject(&:nil?).sort
|
51
|
+
|
52
|
+
print_table "Exchanges", arr, :name, :kind, :durable_x, :delete_x
|
53
|
+
halt
|
47
54
|
end
|
55
|
+
alias :ex :exchanges
|
48
56
|
|
57
|
+
def bindings
|
58
|
+
arr = `rabbitmqctl list_bindings -p #{Opt[:rabbit][:vhost]}`.split("\n")
|
59
|
+
arr.map { |l|l.gsub(/^\t/, "") }.sort.each do |l|
|
60
|
+
next if l =~ /Listing|\.\.\./
|
61
|
+
from, to, args = l.split("\t")
|
62
|
+
puts "#{from} <=> #{to}"
|
63
|
+
end
|
64
|
+
halt
|
65
|
+
end
|
66
|
+
alias :binds :bindings
|
49
67
|
|
50
68
|
def halt(msg=nil)
|
51
69
|
BugsBunny::Rabbit.halt(msg)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Marcos Piccinini
|
@@ -77,12 +77,14 @@ files:
|
|
77
77
|
- bugs_bunny.gemspec
|
78
78
|
- cucumber.yml
|
79
79
|
- features/bugs_bunny.feature
|
80
|
+
- features/exchanges.feature
|
80
81
|
- features/queues.feature
|
81
82
|
- features/step_definitions/bugs_bunny_steps.rb
|
82
83
|
- features/step_definitions/queue_steps.rb
|
83
84
|
- features/support/env.rb
|
84
85
|
- lib/bugs_bunny.rb
|
85
86
|
- lib/bugs_bunny/cli.rb
|
87
|
+
- lib/bugs_bunny/exchange.rb
|
86
88
|
- lib/bugs_bunny/helper.rb
|
87
89
|
- lib/bugs_bunny/queue.rb
|
88
90
|
- lib/bugs_bunny/rabbit.rb
|