bunnish 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +7 -7
- data/VERSION +1 -1
- data/bunnish.gemspec +2 -2
- data/lib/bunnish/core/common.rb +121 -0
- data/lib/bunnish.rb +2 -108
- data/spec/bin/bunnish_spec.rb +7 -7
- metadata +4 -4
data/README.rdoc
CHANGED
|
@@ -21,7 +21,7 @@ Publish messages:
|
|
|
21
21
|
foo
|
|
22
22
|
bar
|
|
23
23
|
baz
|
|
24
|
-
$ cat messages.txt | bunnish publish -h mq-server -p 5672 test-queue
|
|
24
|
+
$ cat messages.txt | bunnish publish -h mq-server -p 5672 test-queue --verbose
|
|
25
25
|
[2012-12-08 20:33:33](INFO) create direct exchange 'test-queue'
|
|
26
26
|
[2012-12-08 20:33:33](INFO) create queue 'test-queue'
|
|
27
27
|
[2012-12-08 20:33:33](INFO) bind queue 'test-queue' to direct exchange 'test-queue'
|
|
@@ -29,7 +29,7 @@ Publish messages:
|
|
|
29
29
|
[2012-12-08 20:33:33](INFO) published 3 messages into test-queue(3 messages, 0 consumers)
|
|
30
30
|
|
|
31
31
|
Publish messages to multiple queues:
|
|
32
|
-
$ cat messages.txt | bunnish publish -h mq-server -p 5672 test-queue-1,test-queue-2
|
|
32
|
+
$ cat messages.txt | bunnish publish -h mq-server -p 5672 test-queue-1,test-queue-2 --verbose
|
|
33
33
|
[2012-12-09 21:10:21](INFO) create direct exchange 'test-queue-1'
|
|
34
34
|
[2012-12-09 21:10:21](INFO) create queue 'test-queue-1'
|
|
35
35
|
[2012-12-09 21:10:21](INFO) bind queue 'test-queue-1' to direct exchange 'test-queue-1'
|
|
@@ -42,11 +42,11 @@ Publish messages to multiple queues:
|
|
|
42
42
|
[2012-12-09 21:10:21](INFO) published 3 messages into test-queue-2(3 messages, 0 consumers)
|
|
43
43
|
|
|
44
44
|
Check queue status:
|
|
45
|
-
$ bunnish status -h mq-server -p 5672 test-queue
|
|
45
|
+
$ bunnish status -h mq-server -p 5672 test-queue --verbose
|
|
46
46
|
test-queue : 3 messages, 0 consumers
|
|
47
47
|
|
|
48
48
|
Check multiple queue status:
|
|
49
|
-
$ bunnish status -h mq-server -p 5672 test-queue-1,test-queue-2
|
|
49
|
+
$ bunnish status -h mq-server -p 5672 test-queue-1,test-queue-2 --verbose
|
|
50
50
|
test-queue-1 : 3 messages, 0 consumers
|
|
51
51
|
test-queue-2 : 3 messages, 0 consumers
|
|
52
52
|
|
|
@@ -55,7 +55,7 @@ Get queue count:
|
|
|
55
55
|
3
|
|
56
56
|
|
|
57
57
|
Subscribe from queue:
|
|
58
|
-
$ bunnish subscribe -h mq-server -p 5672 test-queue
|
|
58
|
+
$ bunnish subscribe -h mq-server -p 5672 test-queue --verbose
|
|
59
59
|
[2012-12-08 20:35:57](INFO) subscribe from test-queue(3 messages, 0 consumers)
|
|
60
60
|
foo
|
|
61
61
|
bar
|
|
@@ -66,11 +66,11 @@ Subscribe from queue:
|
|
|
66
66
|
test-queue
|
|
67
67
|
|
|
68
68
|
Delete queue:
|
|
69
|
-
$ bunnish delete -h mq-server -p 5672 test-queue
|
|
69
|
+
$ bunnish delete -h mq-server -p 5672 test-queue --verbose
|
|
70
70
|
[2012-12-09 21:13:10](INFO) deleted test-queue
|
|
71
71
|
|
|
72
72
|
Delete multiple queues:
|
|
73
|
-
$ bunnish delete -h mq-server -p 5672 test-queue-1,test-queue-2
|
|
73
|
+
$ bunnish delete -h mq-server -p 5672 test-queue-1,test-queue-2 --verbose
|
|
74
74
|
[2012-12-09 21:12:34](INFO) deleted test-queue-1
|
|
75
75
|
[2012-12-09 21:12:34](INFO) deleted test-queue-2
|
|
76
76
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.8
|
data/bunnish.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "bunnish"
|
|
8
|
-
s.version = "0.0.
|
|
8
|
+
s.version = "0.0.8"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Kenji Hara"]
|
|
12
|
-
s.date = "2012-12-
|
|
12
|
+
s.date = "2012-12-12"
|
|
13
13
|
s.description = "Command for AMQP access to Message Queue."
|
|
14
14
|
s.email = "haracane@gmail.com"
|
|
15
15
|
s.executables = ["bunnish"]
|
data/lib/bunnish/core/common.rb
CHANGED
|
@@ -1,5 +1,126 @@
|
|
|
1
1
|
module Bunnish::Core
|
|
2
2
|
module Common
|
|
3
|
+
def self.parse_opts(argv)
|
|
4
|
+
host = 'localhost'
|
|
5
|
+
port = 5672
|
|
6
|
+
user = 'guest'
|
|
7
|
+
password = 'guest'
|
|
8
|
+
durable = false
|
|
9
|
+
ack = true
|
|
10
|
+
raise_exception_flag = false
|
|
11
|
+
|
|
12
|
+
exchange_name = nil
|
|
13
|
+
delimiter = nil
|
|
14
|
+
|
|
15
|
+
consumer_tag = nil
|
|
16
|
+
exclusive = false
|
|
17
|
+
message_max = nil
|
|
18
|
+
timeout = 1
|
|
19
|
+
unit_size = nil
|
|
20
|
+
min_size = nil
|
|
21
|
+
current_all_flag = false
|
|
22
|
+
|
|
23
|
+
warn_size = nil
|
|
24
|
+
error_size = nil
|
|
25
|
+
|
|
26
|
+
log_label = nil
|
|
27
|
+
log_dir = nil
|
|
28
|
+
log_path = nil
|
|
29
|
+
|
|
30
|
+
verbose_flag = false
|
|
31
|
+
|
|
32
|
+
next_argv = []
|
|
33
|
+
|
|
34
|
+
while 0 < argv.size do
|
|
35
|
+
val = argv.shift
|
|
36
|
+
case val
|
|
37
|
+
when '-h'
|
|
38
|
+
host = argv.shift
|
|
39
|
+
when '-p'
|
|
40
|
+
port = argv.shift.to_i
|
|
41
|
+
when '-u'
|
|
42
|
+
user = argv.shift
|
|
43
|
+
when '-P'
|
|
44
|
+
password = argv.shift
|
|
45
|
+
when '--ack'
|
|
46
|
+
ack = (argv.shift == 't')
|
|
47
|
+
when '--delimiter'
|
|
48
|
+
delimiter = argv.shift
|
|
49
|
+
when '--durable'
|
|
50
|
+
durable = (argv.shift == 't')
|
|
51
|
+
when '--exchange-name'
|
|
52
|
+
exchange_name = argv.shift
|
|
53
|
+
when '--unit-size'
|
|
54
|
+
unit_size = argv.shift.to_i
|
|
55
|
+
when '--log-label'
|
|
56
|
+
log_label = argv.shift
|
|
57
|
+
log_label = "[#{log_label}]"
|
|
58
|
+
when '--log-dir'
|
|
59
|
+
log_dir = argv.shift
|
|
60
|
+
when '--log-file'
|
|
61
|
+
log_path = argv.shift
|
|
62
|
+
when '--raise-exception'
|
|
63
|
+
raise_exception_flag = true
|
|
64
|
+
when '--consumer-tag'
|
|
65
|
+
consumer_tag = argv.shift
|
|
66
|
+
when '--timeout'
|
|
67
|
+
timeout = argv.shift.to_i
|
|
68
|
+
when '--exclusive'
|
|
69
|
+
exclusive = (argv.shift == 't')
|
|
70
|
+
when '--message-max'
|
|
71
|
+
message_max = argv.shift
|
|
72
|
+
when '--current-all'
|
|
73
|
+
current_all_flag = true
|
|
74
|
+
when '--min-size'
|
|
75
|
+
min_size = argv.shift.to_i
|
|
76
|
+
when '--empty-list-max'
|
|
77
|
+
empty_list_max = argv.shift.to_i
|
|
78
|
+
when '--warn'
|
|
79
|
+
warn_size = argv.shift.to_i
|
|
80
|
+
when '--error'
|
|
81
|
+
error_size = argv.shift.to_i
|
|
82
|
+
when '--verbose'
|
|
83
|
+
verbose_flag = true
|
|
84
|
+
else
|
|
85
|
+
next_argv.push val
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
argv.push(*next_argv)
|
|
89
|
+
|
|
90
|
+
if verbose_flag then
|
|
91
|
+
Bunnish.logger.level = Logger::INFO
|
|
92
|
+
else
|
|
93
|
+
Bunnish.logger.level = Logger::WARN
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
:host=>host,
|
|
98
|
+
:port=>port,
|
|
99
|
+
:user=>user,
|
|
100
|
+
:password=>password,
|
|
101
|
+
:durable=>durable,
|
|
102
|
+
:ack=>ack,
|
|
103
|
+
:exchange_name=>exchange_name,
|
|
104
|
+
:unit_size=>unit_size,
|
|
105
|
+
:raise_exception_flag=>raise_exception_flag,
|
|
106
|
+
:delimiter=>delimiter,
|
|
107
|
+
:log_label=>log_label,
|
|
108
|
+
:log_dir=>log_dir,
|
|
109
|
+
:log_path=>log_path,
|
|
110
|
+
:consumer_tag=>consumer_tag,
|
|
111
|
+
:timeout=>timeout,
|
|
112
|
+
:exclusive=>exclusive,
|
|
113
|
+
:message_max=>message_max,
|
|
114
|
+
:current_all_flag=>current_all_flag,
|
|
115
|
+
:min_size=>min_size,
|
|
116
|
+
:empty_list_max=>empty_list_max,
|
|
117
|
+
:warn_size=>warn_size,
|
|
118
|
+
:error_size=>error_size,
|
|
119
|
+
:verbose_flag=>verbose_flag
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
|
3
124
|
def self.output_log(streams, log_level, message)
|
|
4
125
|
case log_level
|
|
5
126
|
when "INFO"
|
data/lib/bunnish.rb
CHANGED
|
@@ -3,115 +3,9 @@ require "bunny"
|
|
|
3
3
|
|
|
4
4
|
module Bunnish
|
|
5
5
|
def self.parse_opts(argv)
|
|
6
|
-
|
|
7
|
-
port = 5672
|
|
8
|
-
user = 'guest'
|
|
9
|
-
password = 'guest'
|
|
10
|
-
durable = false
|
|
11
|
-
ack = true
|
|
12
|
-
raise_exception_flag = false
|
|
13
|
-
|
|
14
|
-
exchange_name = nil
|
|
15
|
-
delimiter = nil
|
|
16
|
-
|
|
17
|
-
consumer_tag = nil
|
|
18
|
-
exclusive = false
|
|
19
|
-
message_max = nil
|
|
20
|
-
timeout = 1
|
|
21
|
-
unit_size = nil
|
|
22
|
-
min_size = nil
|
|
23
|
-
current_all_flag = false
|
|
24
|
-
|
|
25
|
-
warn_size = nil
|
|
26
|
-
error_size = nil
|
|
27
|
-
|
|
28
|
-
log_label = nil
|
|
29
|
-
log_dir = nil
|
|
30
|
-
log_path = nil
|
|
31
|
-
|
|
32
|
-
next_argv = []
|
|
33
|
-
|
|
34
|
-
while 0 < argv.size do
|
|
35
|
-
val = argv.shift
|
|
36
|
-
case val
|
|
37
|
-
when '-h'
|
|
38
|
-
host = argv.shift
|
|
39
|
-
when '-p'
|
|
40
|
-
port = argv.shift.to_i
|
|
41
|
-
when '-u'
|
|
42
|
-
user = argv.shift
|
|
43
|
-
when '-P'
|
|
44
|
-
password = argv.shift
|
|
45
|
-
when '--ack'
|
|
46
|
-
ack = (argv.shift == 't')
|
|
47
|
-
when '--delimiter'
|
|
48
|
-
delimiter = argv.shift
|
|
49
|
-
when '--durable'
|
|
50
|
-
durable = (argv.shift == 't')
|
|
51
|
-
when '--exchange-name'
|
|
52
|
-
exchange_name = argv.shift
|
|
53
|
-
when '--unit-size'
|
|
54
|
-
unit_size = argv.shift.to_i
|
|
55
|
-
when '--log-label'
|
|
56
|
-
log_label = argv.shift
|
|
57
|
-
log_label = "[#{log_label}]"
|
|
58
|
-
when '--log-dir'
|
|
59
|
-
log_dir = argv.shift
|
|
60
|
-
when '--log-file'
|
|
61
|
-
log_path = argv.shift
|
|
62
|
-
when '--raise-exception'
|
|
63
|
-
raise_exception_flag = true
|
|
64
|
-
when '--consumer-tag'
|
|
65
|
-
consumer_tag = argv.shift
|
|
66
|
-
when '--timeout'
|
|
67
|
-
timeout = argv.shift.to_i
|
|
68
|
-
when '--exclusive'
|
|
69
|
-
exclusive = (argv.shift == 't')
|
|
70
|
-
when '--message-max'
|
|
71
|
-
message_max = argv.shift
|
|
72
|
-
when '--current-all'
|
|
73
|
-
current_all_flag = true
|
|
74
|
-
when '--min-size'
|
|
75
|
-
min_size = argv.shift.to_i
|
|
76
|
-
when '--empty-list-max'
|
|
77
|
-
empty_list_max = argv.shift.to_i
|
|
78
|
-
when '--warn'
|
|
79
|
-
warn_size = argv.shift.to_i
|
|
80
|
-
when '--error'
|
|
81
|
-
error_size = argv.shift.to_i
|
|
82
|
-
else
|
|
83
|
-
next_argv.push val
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
argv.push(*next_argv)
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
:host=>host,
|
|
90
|
-
:port=>port,
|
|
91
|
-
:user=>user,
|
|
92
|
-
:password=>password,
|
|
93
|
-
:durable=>durable,
|
|
94
|
-
:ack=>ack,
|
|
95
|
-
:exchange_name=>exchange_name,
|
|
96
|
-
:unit_size=>unit_size,
|
|
97
|
-
:raise_exception_flag=>raise_exception_flag,
|
|
98
|
-
:delimiter=>delimiter,
|
|
99
|
-
:log_label=>log_label,
|
|
100
|
-
:log_dir=>log_dir,
|
|
101
|
-
:log_path=>log_path,
|
|
102
|
-
:consumer_tag=>consumer_tag,
|
|
103
|
-
:timeout=>timeout,
|
|
104
|
-
:exclusive=>exclusive,
|
|
105
|
-
:message_max=>message_max,
|
|
106
|
-
:current_all_flag=>current_all_flag,
|
|
107
|
-
:min_size=>min_size,
|
|
108
|
-
:empty_list_max=>empty_list_max,
|
|
109
|
-
:warn_size=>warn_size,
|
|
110
|
-
:error_size=>error_size
|
|
111
|
-
}
|
|
112
|
-
|
|
6
|
+
return Bunnish::Core::Common::parse_opts(argv)
|
|
113
7
|
end
|
|
114
|
-
|
|
8
|
+
|
|
115
9
|
def self.logger
|
|
116
10
|
if @logger.nil?
|
|
117
11
|
@logger = (rails_logger || default_logger)
|
data/spec/bin/bunnish_spec.rb
CHANGED
|
@@ -21,14 +21,14 @@ describe "bin/bunnish" do
|
|
|
21
21
|
end
|
|
22
22
|
describe "count" do
|
|
23
23
|
it "should output valid queue count" do
|
|
24
|
-
result = `#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish count bunnish-test-queue #{@stderr_dst}`
|
|
24
|
+
result = `#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish count bunnish-test-queue --verbose #{@stderr_dst}`
|
|
25
25
|
result.chomp!
|
|
26
26
|
result.should == "3"
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
describe "delete" do
|
|
30
30
|
it "should delete queue" do
|
|
31
|
-
`#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish delete bunnish-test-queue #{@stderr_dst}`
|
|
31
|
+
`#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish delete bunnish-test-queue --verbose #{@stderr_dst}`
|
|
32
32
|
result = `#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish count bunnish-test-queue 2> /dev/null`
|
|
33
33
|
result = result.chomp!
|
|
34
34
|
result.should == "0"
|
|
@@ -36,7 +36,7 @@ describe "bin/bunnish" do
|
|
|
36
36
|
end
|
|
37
37
|
describe "help" do
|
|
38
38
|
it "should delete queue" do
|
|
39
|
-
result = `#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish help bunnish-test-queue #{@stderr_dst}`
|
|
39
|
+
result = `#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish help bunnish-test-queue --verbose #{@stderr_dst}`
|
|
40
40
|
result.split().size.should > 0
|
|
41
41
|
$?.should == 0
|
|
42
42
|
end
|
|
@@ -44,7 +44,7 @@ describe "bin/bunnish" do
|
|
|
44
44
|
describe "publish" do
|
|
45
45
|
context "when exchange-name is not set" do
|
|
46
46
|
it "should publish valid messages with direct exchange" do
|
|
47
|
-
`cat #{@input_file.path} | #{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish publish bunnish-test-queue,bunnish-test-queue-2 #{@stderr_dst}`
|
|
47
|
+
`cat #{@input_file.path} | #{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish publish bunnish-test-queue,bunnish-test-queue-2 --verbose #{@stderr_dst}`
|
|
48
48
|
result = `#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish subscribe bunnish-test-queue 2> /dev/null`
|
|
49
49
|
result = result.split()
|
|
50
50
|
# result.each do |line| STDERR.puts line end
|
|
@@ -67,7 +67,7 @@ describe "bin/bunnish" do
|
|
|
67
67
|
|
|
68
68
|
context "when exchange-name is set" do
|
|
69
69
|
it "should publish valid messages with fanout exchange" do
|
|
70
|
-
`cat #{@input_file.path} | #{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish publish --exchange-name bunnish-test-exchange bunnish-test-queue,bunnish-test-queue-2 #{@stderr_dst}`
|
|
70
|
+
`cat #{@input_file.path} | #{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish publish --exchange-name bunnish-test-exchange bunnish-test-queue,bunnish-test-queue-2 --verbose #{@stderr_dst}`
|
|
71
71
|
result = `#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish subscribe bunnish-test-queue 2> /dev/null`
|
|
72
72
|
result = result.split()
|
|
73
73
|
# result.each do |line| STDERR.puts line end
|
|
@@ -90,7 +90,7 @@ describe "bin/bunnish" do
|
|
|
90
90
|
end
|
|
91
91
|
describe "status" do
|
|
92
92
|
it "should print valid status of message queue" do
|
|
93
|
-
result = `#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish status bunnish-test-queue #{@stderr_dst}`
|
|
93
|
+
result = `#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish status bunnish-test-queue --verbose #{@stderr_dst}`
|
|
94
94
|
result = result.split(/\n/)
|
|
95
95
|
# STDERR.puts result.inspect
|
|
96
96
|
result.include?("bunnish-test-queue : 3 messages, 0 consumers").should be_true
|
|
@@ -98,7 +98,7 @@ describe "bin/bunnish" do
|
|
|
98
98
|
end
|
|
99
99
|
describe "subscribe" do
|
|
100
100
|
it "should subscribe valid messages" do
|
|
101
|
-
result = `#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish subscribe bunnish-test-queue #{@stderr_dst}`
|
|
101
|
+
result = `#{Bunnish::RUBY_CMD} #{Bunnish::BIN_DIR}/bunnish subscribe bunnish-test-queue --verbose #{@stderr_dst}`
|
|
102
102
|
result = result.split()
|
|
103
103
|
# result.each do |line| STDERR.puts line end
|
|
104
104
|
result.shift.should == "foo"
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bunnish
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 15
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 8
|
|
10
|
+
version: 0.0.8
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Kenji Hara
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2012-12-
|
|
18
|
+
date: 2012-12-12 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
type: :runtime
|