beetle 3.3.7 → 3.3.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.
- checksums.yaml +4 -4
- data/RELEASE_NOTES.rdoc +9 -1
- data/lib/beetle/queue_properties.rb +21 -7
- data/lib/beetle/version.rb +1 -1
- data/test/beetle/queue_properties_test.rb +38 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b64b9ad7d4d36c450c8219f666db52323d1d30e6f741ccb5791469f9f9c7b7a0
|
4
|
+
data.tar.gz: 860d8813af202e5463aa70d2b33466c0cb1d0f0ed8afe7490ae82e106c2cc3f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b97d517694c27bfa3bcbb6d7714374b998a6e1268e0012e59a9d8e0c57e7fac0904cf978a9e5dee7c92c03f183c679ad238102704152e1f1115bedcc9280b70a
|
7
|
+
data.tar.gz: 63875a03bf6cd2c0221ce925d9b14d49aae0fbf547a40177ef4eee77a5913894b64df82967c45a3aecc0eff8a7631a8038e4fae1e5b7618dea3a66be030a472d
|
data/RELEASE_NOTES.rdoc
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
= Release Notes
|
2
2
|
|
3
|
+
== Version 3.3.8
|
4
|
+
* Avoid needless put call when updating queue policies.
|
5
|
+
It seems the additional call to get the current definition of a policy
|
6
|
+
is to be preferred over relying on the idempotency of the PUT call.
|
7
|
+
This helps when adding a new fresh server to a beetle cluster: import
|
8
|
+
the definitions of one of the existing nodes on the fresh node before
|
9
|
+
actually adding it to the list of servers in the client's beetle config..
|
10
|
+
|
3
11
|
== Version 3.3.7
|
4
|
-
*
|
12
|
+
* Increased default http api read timeout to handle large server better.
|
5
13
|
|
6
14
|
== Version 3.3.6
|
7
15
|
* Fixed a redis connection leak in gobeetle.
|
@@ -46,7 +46,8 @@ module Beetle
|
|
46
46
|
|
47
47
|
# no need to worry that the server has the port 5672. Net:HTTP will take care of this. See below.
|
48
48
|
request_url = URI("http://#{server}/api/policies/#{vhost}/#{queue_name}_policy")
|
49
|
-
|
49
|
+
get_request = Net::HTTP::Get.new(request_url)
|
50
|
+
put_request = Net::HTTP::Put.new(request_url)
|
50
51
|
|
51
52
|
# set up queue policy
|
52
53
|
definition = {}
|
@@ -58,19 +59,28 @@ module Beetle
|
|
58
59
|
|
59
60
|
definition["queue-mode"] = "lazy" if options[:lazy]
|
60
61
|
|
61
|
-
|
62
|
+
put_request_body = {
|
62
63
|
"pattern" => "^#{queue_name}$",
|
63
64
|
"priority" => 1,
|
64
65
|
"apply-to" => "queues",
|
65
66
|
"definition" => definition,
|
66
67
|
}
|
67
68
|
|
68
|
-
|
69
|
-
http.request(
|
69
|
+
get_response = run_rabbit_http_request(request_url, get_request) do |http|
|
70
|
+
http.request(get_request, nil)
|
70
71
|
end
|
71
72
|
|
72
|
-
|
73
|
-
|
73
|
+
if get_response.code == "200"
|
74
|
+
response_body = JSON.parse(get_response.body) rescue {}
|
75
|
+
return :ok if put_request_body.all? { |k,v| response_body[k] == v }
|
76
|
+
end
|
77
|
+
|
78
|
+
put_response = run_rabbit_http_request(request_url, put_request) do |http|
|
79
|
+
http.request(put_request, put_request_body.to_json)
|
80
|
+
end
|
81
|
+
|
82
|
+
unless %w(200 201 204).include?(put_response.code)
|
83
|
+
log_error("Failed to create policy for queue #{queue_name}", put_response)
|
74
84
|
raise FailedRabbitRequest.new("Could not create policy")
|
75
85
|
end
|
76
86
|
|
@@ -131,7 +141,11 @@ module Beetle
|
|
131
141
|
|
132
142
|
def run_rabbit_http_request(uri, request, &block)
|
133
143
|
request.basic_auth(config.user, config.password)
|
134
|
-
request
|
144
|
+
if request.class::METHOD == 'GET'
|
145
|
+
request["Accept"] = "application/json"
|
146
|
+
else
|
147
|
+
request["Content-Type"] = "application/json"
|
148
|
+
end
|
135
149
|
http = Net::HTTP.new(uri.hostname, config.api_port)
|
136
150
|
http.read_timeout = config.rabbitmq_api_read_timeout
|
137
151
|
# don't do this in production:
|
data/lib/beetle/version.rb
CHANGED
@@ -41,6 +41,10 @@ module Beetle
|
|
41
41
|
end
|
42
42
|
|
43
43
|
test "creates a policy by posting to the rabbitmq if dead lettering is enabled" do
|
44
|
+
stub_request(:get, "http://localhost:15672/api/policies/%2F/QUEUE_NAME_policy")
|
45
|
+
.with(basic_auth: ['guest', 'guest'])
|
46
|
+
.to_return(:status => 404)
|
47
|
+
|
44
48
|
stub_request(:put, "http://localhost:15672/api/policies/%2F/QUEUE_NAME_policy")
|
45
49
|
.with(basic_auth: ['guest', 'guest'])
|
46
50
|
.with(:body => {
|
@@ -56,7 +60,29 @@ module Beetle
|
|
56
60
|
@queue_properties.set_queue_policy!(@server, @queue_name, :lazy => false, :dead_lettering => true, :routing_key => "QUEUE_NAME_dead_letter")
|
57
61
|
end
|
58
62
|
|
63
|
+
test "skips the PUT call to rabbitmq if the policy is already defined as desired" do
|
64
|
+
stub_request(:get, "http://localhost:15672/api/policies/%2F/QUEUE_NAME_policy")
|
65
|
+
.with(basic_auth: ['guest', 'guest'])
|
66
|
+
.to_return(:status => 200,
|
67
|
+
:body => {
|
68
|
+
"vhost" => "/",
|
69
|
+
"name" => "QUEUE_NAME_policy",
|
70
|
+
"pattern" => "^QUEUE_NAME$",
|
71
|
+
"priority" => 1,
|
72
|
+
"apply-to" => "queues",
|
73
|
+
"definition" => {
|
74
|
+
"dead-letter-routing-key" => "QUEUE_NAME_dead_letter",
|
75
|
+
"dead-letter-exchange" => ""
|
76
|
+
}}.to_json)
|
77
|
+
|
78
|
+
@queue_properties.set_queue_policy!(@server, @queue_name, :lazy => false, :dead_lettering => true, :routing_key => "QUEUE_NAME_dead_letter")
|
79
|
+
end
|
80
|
+
|
59
81
|
test "creates a policy by posting to the rabbitmq if lazy queues are enabled" do
|
82
|
+
stub_request(:get, "http://localhost:15672/api/policies/%2F/QUEUE_NAME_policy")
|
83
|
+
.with(basic_auth: ['guest', 'guest'])
|
84
|
+
.to_return(:status => 404)
|
85
|
+
|
60
86
|
stub_request(:put, "http://localhost:15672/api/policies/%2F/QUEUE_NAME_policy")
|
61
87
|
.with(basic_auth: ['guest', 'guest'])
|
62
88
|
.with(:body => {
|
@@ -72,6 +98,10 @@ module Beetle
|
|
72
98
|
end
|
73
99
|
|
74
100
|
test "raises exception when policy couldn't successfully be created" do
|
101
|
+
stub_request(:get, "http://localhost:15672/api/policies/%2F/QUEUE_NAME_policy")
|
102
|
+
.with(basic_auth: ['guest', 'guest'])
|
103
|
+
.to_return(:status => 404)
|
104
|
+
|
75
105
|
stub_request(:put, "http://localhost:15672/api/policies/%2F/QUEUE_NAME_policy")
|
76
106
|
.with(basic_auth: ['guest', 'guest'])
|
77
107
|
.to_return(:status => [405])
|
@@ -82,6 +112,10 @@ module Beetle
|
|
82
112
|
end
|
83
113
|
|
84
114
|
test "can optionally specify a message ttl" do
|
115
|
+
stub_request(:get, "http://localhost:15672/api/policies/%2F/QUEUE_NAME_policy")
|
116
|
+
.with(basic_auth: ['guest', 'guest'])
|
117
|
+
.to_return(:status => 404)
|
118
|
+
|
85
119
|
stub_request(:put, "http://localhost:15672/api/policies/%2F/QUEUE_NAME_policy")
|
86
120
|
.with(basic_auth: ['guest', 'guest'])
|
87
121
|
.with(:body => {
|
@@ -99,6 +133,10 @@ module Beetle
|
|
99
133
|
end
|
100
134
|
|
101
135
|
test "properly encodes the vhost from the configuration" do
|
136
|
+
stub_request(:get, "http://localhost:15672/api/policies/foo%2F/QUEUE_NAME_policy")
|
137
|
+
.with(basic_auth: ['guest', 'guest'])
|
138
|
+
.to_return(:status => 404)
|
139
|
+
|
102
140
|
stub_request(:put, "http://localhost:15672/api/policies/foo%2F/QUEUE_NAME_policy")
|
103
141
|
.with(basic_auth: ['guest', 'guest'])
|
104
142
|
.with(:body => {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beetle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kaes
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2020-05-
|
15
|
+
date: 2020-05-18 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bunny
|