activemessaging 0.14.1 → 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/activemessaging.rb +1 -1
- data/lib/activemessaging/adapters/sqs.rb +21 -9
- data/lib/activemessaging/version.rb +1 -1
- metadata +4 -4
data/lib/activemessaging.rb
CHANGED
@@ -68,7 +68,7 @@ module ActiveMessaging
|
|
68
68
|
# is likely running since application_processor.rb and another processor
|
69
69
|
# should exist when running rails.
|
70
70
|
if Dir["#{app_root}/app/processors/*.rb"].size() <= 1
|
71
|
-
|
71
|
+
return
|
72
72
|
end
|
73
73
|
path = File.expand_path("#{app_root}/config/messaging.rb")
|
74
74
|
begin
|
@@ -7,7 +7,6 @@ require 'cgi'
|
|
7
7
|
require 'time'
|
8
8
|
require 'uri'
|
9
9
|
require 'rexml/document'
|
10
|
-
require 'erb'
|
11
10
|
|
12
11
|
require 'activemessaging/adapters/base'
|
13
12
|
require 'activemessaging/adapters/aws4_signer'
|
@@ -22,8 +21,9 @@ module ActiveMessaging
|
|
22
21
|
QUEUE_NAME_LENGTH = 1..80
|
23
22
|
VISIBILITY_TIMEOUT = 0..(24 * 60 * 60)
|
24
23
|
NUMBER_OF_MESSAGES = 1..255
|
25
|
-
GET_QUEUE_ATTRIBUTES = ['All', 'ApproximateNumberOfMessages', 'ApproximateNumberOfMessagesDelayed', 'ApproximateNumberOfMessagesNotVisible', 'CreatedTimestamp', 'DelaySeconds', 'LastModifiedTimestamp', 'MaximumMessageSize', 'MessageRetentionPeriod', 'Policy', 'QueueArn', 'ReceiveMessageWaitTimeSeconds', 'RedrivePolicy', 'VisibilityTimeout', 'KmsMasterKeyId', 'KmsDataKeyReusePeriodSeconds', 'FifoQueue', 'ContentBasedDeduplication']
|
26
|
-
SET_QUEUE_ATTRIBUTES = ['DelaySeconds', 'MaximumMessageSize', 'MessageRetentionPeriod', 'Policy', 'ReceiveMessageWaitTimeSeconds', 'RedrivePolicy', 'VisibilityTimeout', 'KmsMasterKeyId', 'KmsDataKeyReusePeriodSeconds', 'ContentBasedDeduplication']
|
24
|
+
GET_QUEUE_ATTRIBUTES = ['All', 'ApproximateNumberOfMessages', 'ApproximateNumberOfMessagesDelayed', 'ApproximateNumberOfMessagesNotVisible', 'CreatedTimestamp', 'DelaySeconds', 'LastModifiedTimestamp', 'MaximumMessageSize', 'MessageRetentionPeriod', 'Policy', 'QueueArn', 'ReceiveMessageWaitTimeSeconds', 'RedrivePolicy', 'VisibilityTimeout', 'KmsMasterKeyId', 'KmsDataKeyReusePeriodSeconds', 'FifoQueue', 'ContentBasedDeduplication'].freeze
|
25
|
+
SET_QUEUE_ATTRIBUTES = ['DelaySeconds', 'MaximumMessageSize', 'MessageRetentionPeriod', 'Policy', 'ReceiveMessageWaitTimeSeconds', 'RedrivePolicy', 'VisibilityTimeout', 'KmsMasterKeyId', 'KmsDataKeyReusePeriodSeconds', 'ContentBasedDeduplication'].freeze
|
26
|
+
URI_ENCODING_REPLACEMENTS = { '%7E' => '~', '+' => '%20' }.freeze
|
27
27
|
|
28
28
|
#configurable params
|
29
29
|
attr_accessor :reconnect_delay, :access_key_id, :secret_access_key, :aws_version, :content_type, :host, :port, :poll_interval, :cache_queue_list, :max_message_size
|
@@ -236,7 +236,7 @@ module ActiveMessaging
|
|
236
236
|
|
237
237
|
# Sort and encode query params
|
238
238
|
query_params = params.keys.sort.map do |key|
|
239
|
-
key + "=" +
|
239
|
+
key + "=" + url_encode(params[key])
|
240
240
|
end
|
241
241
|
|
242
242
|
# Put these together with the uri to get the request query string
|
@@ -244,8 +244,8 @@ module ActiveMessaging
|
|
244
244
|
|
245
245
|
# Create the request
|
246
246
|
init_headers = {
|
247
|
-
|
248
|
-
|
247
|
+
'Date' => Time.now.utc.iso8601,
|
248
|
+
'Host' => @host
|
249
249
|
}
|
250
250
|
request = Net::HTTP::Get.new(request_url, init_headers)
|
251
251
|
|
@@ -259,7 +259,7 @@ module ActiveMessaging
|
|
259
259
|
headers = {}
|
260
260
|
request.canonical_each { |k, v| headers[k] = v }
|
261
261
|
|
262
|
-
signature = signer.sign('GET', URI.parse(request_url), headers)
|
262
|
+
signature = signer.sign('GET', URI.parse(request_url), headers, nil, false)
|
263
263
|
signature.each { |k, v| request[k] = v }
|
264
264
|
|
265
265
|
# Make the request
|
@@ -278,11 +278,23 @@ module ActiveMessaging
|
|
278
278
|
end
|
279
279
|
end
|
280
280
|
|
281
|
+
def url_encode(param)
|
282
|
+
param = param.to_s
|
283
|
+
|
284
|
+
if param.respond_to?(:encode)
|
285
|
+
param = param.encode('UTF-8')
|
286
|
+
end
|
287
|
+
|
288
|
+
param = CGI::escape(param)
|
289
|
+
URI_ENCODING_REPLACEMENTS.each { |k, v| param = param.gsub(k, v) }
|
290
|
+
param
|
291
|
+
end
|
292
|
+
|
281
293
|
def http_request h, p, r
|
282
294
|
http = Net::HTTP.new(h, p)
|
283
295
|
# http.set_debug_output(STDOUT)
|
284
296
|
|
285
|
-
http.use_ssl =
|
297
|
+
http.use_ssl = 'https' == @protocol
|
286
298
|
|
287
299
|
# Don't carp about SSL cert verification
|
288
300
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
@@ -290,7 +302,7 @@ module ActiveMessaging
|
|
290
302
|
end
|
291
303
|
|
292
304
|
def check_errors(response)
|
293
|
-
raise
|
305
|
+
raise 'http response was nil' if (response.nil?)
|
294
306
|
raise response.errors if (response && response.errors?)
|
295
307
|
response
|
296
308
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemessaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 35
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 14
|
9
|
-
-
|
10
|
-
version: 0.14.
|
9
|
+
- 2
|
10
|
+
version: 0.14.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jon Tirsen
|
@@ -22,7 +22,7 @@ autorequire:
|
|
22
22
|
bindir: exe
|
23
23
|
cert_chain: []
|
24
24
|
|
25
|
-
date: 2018-06-
|
25
|
+
date: 2018-06-18 00:00:00 Z
|
26
26
|
dependencies:
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|