sensu-transport-snssqs-ng 2.0.4 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/sensu/transport/snssqs.rb +34 -3
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27e2deb012e3d5cb4dd49a1877e847a895adf688
|
4
|
+
data.tar.gz: 219f46c7147f5fa6599833dfb9b06bd181a11097
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b701d5a370992d39986cb9042d1de281707e60dcefff2441b5c675450d5706c18e63a09bcaf370bd6f511f4dc9a1d191ab03cced2e8cbc2e3b89bc0be848705
|
7
|
+
data.tar.gz: dfc9800a01dd284780f467de14cf39ed436ad6f84467e1502366bdf0a7b53fc80ea2484994b82ca932cf93aa542efe44ac7543176f55a9b319c3d4ea2bca00c1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -36,8 +36,13 @@ module Sensu
|
|
36
36
|
@keepalives_callback = proc {}
|
37
37
|
# Sensu Windows install does not include a valid cert bundle for AWS
|
38
38
|
Aws.use_bundled_cert! if Gem.win_platform?
|
39
|
-
|
40
|
-
|
39
|
+
aws_client_settings = {region: @settings[:region]}
|
40
|
+
unless @settings[:access_key_id].nil?
|
41
|
+
aws_client_settings[:access_key_id] = @settings[:access_key_id]
|
42
|
+
aws_client_settings[:secret_access_key] = @settings[:secret_access_key]
|
43
|
+
end
|
44
|
+
@sqs = Aws::SQS::Client.new aws_client_settings
|
45
|
+
@sns = Aws::SNS::Client.new aws_client_settings
|
41
46
|
|
42
47
|
# connect to statsd, if necessary
|
43
48
|
@statsd = nil
|
@@ -175,7 +180,33 @@ module Sensu
|
|
175
180
|
wait_time_seconds: @settings[:wait_time_seconds],
|
176
181
|
max_number_of_messages: @settings[:max_number_of_messages],
|
177
182
|
)
|
178
|
-
resp.messages
|
183
|
+
resp.messages.select do |msg|
|
184
|
+
# switching whether to transform the message based on the existance of message_attributes
|
185
|
+
# if this is a raw SNS message, it exists in the root of the message and no conversion is needed
|
186
|
+
# if it doesn't, it is an encapsulated messsage (meaning the SNS message is a stringified JSON in the body of the SQS message)
|
187
|
+
begin
|
188
|
+
if !msg.key? 'message_attributes'
|
189
|
+
# extracting original SNS message
|
190
|
+
tmp_body = JSON.parse msg.body
|
191
|
+
# if there is no Message, this isn't a SNS message and something has gone terribly wrong
|
192
|
+
next if tmp_body.key? 'Message'
|
193
|
+
# replacing the body with the SNS message (as it would be in a raw delivered SNS-SQS message)
|
194
|
+
msg.body = tmp_body['Message']
|
195
|
+
msg.message_attributes = {}
|
196
|
+
# discarding messages without attributes, since this would lead to an exception in subscribe
|
197
|
+
next if tmp_body.key? 'MessageAttributes'
|
198
|
+
# parsing the message_attributes
|
199
|
+
tmp_body['MessageAttributes'].each do |name, value|
|
200
|
+
msg.message_attributes[name] = Aws::SQS::Types::MessageAttributeValue.new
|
201
|
+
msg.message_attributes[name].string_value = value['Value']
|
202
|
+
msg.message_attributes[name].data_type = 'String'
|
203
|
+
end
|
204
|
+
end
|
205
|
+
msg
|
206
|
+
rescue JSON::JSONError => e
|
207
|
+
self.logger.info(e)
|
208
|
+
end
|
209
|
+
end
|
179
210
|
rescue Aws::SQS::Errors::ServiceError => e
|
180
211
|
self.logger.info(e)
|
181
212
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-transport-snssqs-ng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Troy Ready
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
SDfvq2xI1v+iTmBkyYqft23MKnTcc5jJ5Gh0a11a2zUstWaH1XHelXYCx44ZLCtC
|
32
32
|
Q6k=
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
34
|
+
date: 2017-04-28 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: aws-sdk
|
metadata.gz.sig
CHANGED
Binary file
|