rabbitmq-definition 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/rabbitmq_definition/dump.rb +17 -10
- data/lib/rabbitmq_definition/version.rb +1 -1
- data/spec/rabbitmq_definition/dump_spec.rb +47 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2346e336b95759186f990ce466977d975559d2d0
|
4
|
+
data.tar.gz: da0e4f48f31ba586e9b8b7a234d8fb11c4228c77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 464144aa22549140f8af197b00b3683c26244414581996cb6bccc18fa96e903ec6157e2524b2dab83b9b5441b84f43705b9355058c746d7671a9ffbb68d2fee7
|
7
|
+
data.tar.gz: 282a2f61ebf894b167162a86cacade76317db3a4184c78b81f0e709f8c0c3c2beea879c4831664d0aff5686e2cf05b8f67409522030c84b162a4f49d903f7b97
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rabbitmq-definition (0.1.
|
4
|
+
rabbitmq-definition (0.1.2)
|
5
5
|
colorize (~> 0.7)
|
6
6
|
highline (~> 1.7)
|
7
7
|
json (~> 1.8)
|
8
|
-
rabbitmq_http_api_client (
|
8
|
+
rabbitmq_http_api_client (~> 1.6)
|
9
9
|
rails (~> 4.0)
|
10
|
-
rake (~> 10.
|
10
|
+
rake (~> 10.0)
|
11
11
|
|
12
12
|
GEM
|
13
13
|
remote: http://rubygems.org/
|
@@ -6,7 +6,7 @@ module RabbitMQ::Definition
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def execute
|
9
|
-
FileDefinition.new(
|
9
|
+
FileDefinition.new(filter_and_order_list_definition).tap do |definition|
|
10
10
|
Logger.info definition.to_json if verbose
|
11
11
|
Logger.progress "Saving definition..."
|
12
12
|
definition.save
|
@@ -16,23 +16,30 @@ module RabbitMQ::Definition
|
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
|
-
def
|
19
|
+
def filter_and_order_list_definition
|
20
20
|
client.list_definitions.reduce({}) do |result, (key, value)|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
value = case key
|
22
|
+
when "vhosts"
|
23
|
+
@vhosts.sort.map {|name| {'name' => name} }
|
24
|
+
when "queues", "exchanges"
|
25
|
+
filter_vhosts(value).sort do |a, b|
|
26
|
+
[a["vhost"], a["name"]] <=> [b["vhost"], b["name"]]
|
27
|
+
end
|
28
|
+
when "bindings"
|
29
|
+
filter_vhosts(value).sort do |a, b|
|
30
|
+
[a["vhost"], a["source"], a["destination"], a["routing_key"]] <=> [b["vhost"], b["source"], b["destination"], b["routing_key"]]
|
31
|
+
end
|
32
|
+
else
|
33
|
+
value
|
25
34
|
end
|
26
35
|
result[key] = value
|
27
36
|
result
|
28
37
|
end
|
29
38
|
end
|
30
39
|
|
31
|
-
def
|
40
|
+
def filter_vhosts(items)
|
32
41
|
items.reduce([]) do |array, item|
|
33
|
-
|
34
|
-
array.push(item)
|
35
|
-
end
|
42
|
+
array.push(item) if @vhosts.include?(item["vhost"])
|
36
43
|
array
|
37
44
|
end
|
38
45
|
end
|
@@ -5,7 +5,16 @@ describe RabbitMQ::Definition::Dump do
|
|
5
5
|
'vhosts' => [{'name' => '/'}, 'name' => '/other-vhost'],
|
6
6
|
'queues' => [
|
7
7
|
{
|
8
|
-
"name" => "my-queue",
|
8
|
+
"name" => "my-b-queue",
|
9
|
+
"vhost" => "/",
|
10
|
+
"durable" => true,
|
11
|
+
"auto_delete" => false,
|
12
|
+
"arguments" => {
|
13
|
+
"x-dead-letter-exchange" => "dead"
|
14
|
+
}
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"name" => "my-a-queue",
|
9
18
|
"vhost" => "/",
|
10
19
|
"durable" => true,
|
11
20
|
"auto_delete" => false,
|
@@ -20,7 +29,17 @@ describe RabbitMQ::Definition::Dump do
|
|
20
29
|
],
|
21
30
|
'exchanges' => [
|
22
31
|
{
|
23
|
-
"name" => "my-exchange",
|
32
|
+
"name" => "my-b-exchange",
|
33
|
+
"vhost" => "/",
|
34
|
+
"type" => "topic",
|
35
|
+
"durable" => true,
|
36
|
+
"auto_delete" => false,
|
37
|
+
"internal" => false,
|
38
|
+
"arguments" => {
|
39
|
+
}
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"name" => "my-a-exchange",
|
24
43
|
"vhost" => "/",
|
25
44
|
"type" => "topic",
|
26
45
|
"durable" => true,
|
@@ -42,9 +61,9 @@ describe RabbitMQ::Definition::Dump do
|
|
42
61
|
],
|
43
62
|
'bindings' => [
|
44
63
|
{
|
45
|
-
"source" => "my-exchange",
|
64
|
+
"source" => "my-a-exchange",
|
46
65
|
"vhost" => "/",
|
47
|
-
"destination" => "my-queue",
|
66
|
+
"destination" => "my-a-queue",
|
48
67
|
"destination_type" => "queue",
|
49
68
|
"routing_key" => "my-routing-key.#",
|
50
69
|
"arguments" => {
|
@@ -70,7 +89,16 @@ describe RabbitMQ::Definition::Dump do
|
|
70
89
|
],
|
71
90
|
'queues' => [
|
72
91
|
{
|
73
|
-
"name" => "my-queue",
|
92
|
+
"name" => "my-a-queue",
|
93
|
+
"vhost" => "/",
|
94
|
+
"durable" => true,
|
95
|
+
"auto_delete" => false,
|
96
|
+
"arguments" => {
|
97
|
+
"x-dead-letter-exchange" => "dead"
|
98
|
+
}
|
99
|
+
},
|
100
|
+
{
|
101
|
+
"name" => "my-b-queue",
|
74
102
|
"vhost" => "/",
|
75
103
|
"durable" => true,
|
76
104
|
"auto_delete" => false,
|
@@ -81,7 +109,17 @@ describe RabbitMQ::Definition::Dump do
|
|
81
109
|
],
|
82
110
|
'exchanges' => [
|
83
111
|
{
|
84
|
-
"name" => "my-exchange",
|
112
|
+
"name" => "my-a-exchange",
|
113
|
+
"vhost" => "/",
|
114
|
+
"type" => "topic",
|
115
|
+
"durable" => true,
|
116
|
+
"auto_delete" => false,
|
117
|
+
"internal" => false,
|
118
|
+
"arguments" => {
|
119
|
+
}
|
120
|
+
},
|
121
|
+
{
|
122
|
+
"name" => "my-b-exchange",
|
85
123
|
"vhost" => "/",
|
86
124
|
"type" => "topic",
|
87
125
|
"durable" => true,
|
@@ -93,9 +131,9 @@ describe RabbitMQ::Definition::Dump do
|
|
93
131
|
],
|
94
132
|
'bindings' => [
|
95
133
|
{
|
96
|
-
"source" => "my-exchange",
|
134
|
+
"source" => "my-a-exchange",
|
97
135
|
"vhost" => "/",
|
98
|
-
"destination" => "my-queue",
|
136
|
+
"destination" => "my-a-queue",
|
99
137
|
"destination_type" => "queue",
|
100
138
|
"routing_key" => "my-routing-key.#",
|
101
139
|
"arguments" => {
|
@@ -136,7 +174,7 @@ describe RabbitMQ::Definition::Dump do
|
|
136
174
|
described_class.run(client, false, ['/'])
|
137
175
|
end
|
138
176
|
|
139
|
-
it "generates the file definition with the filtered list definitions taking vhosts from files" do
|
177
|
+
it "generates the file definition with the filtered list definitions taking vhosts from files and sorting arrays by name / source" do
|
140
178
|
original_definition = double(:vhosts => [{'name' => '/'}])
|
141
179
|
expect(RabbitMQ::Definition::FileDefinition).to receive(:read).and_return(original_definition)
|
142
180
|
definition = double("Definition")
|