logstash-input-sqs 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 015c2627d3dc9ef31ed1f584d0a5c93f8be4ad6e109f459685d1f7fde9f7232d
4
- data.tar.gz: 72e1686588f790fd3465d18d2c09a0912f6fa7bbe1f92601e4967192a3c4083f
3
+ metadata.gz: b3db0942f9be76324ff9694a6e419e810775b0ce1eacf1ba29e933250dcfd87f
4
+ data.tar.gz: 326cb0268d8ab36b790b8fe72a757dfd1da4d9fdb593b96c61de775279b7e8c6
5
5
  SHA512:
6
- metadata.gz: 79556cf77d93fea45b38a95f690c18f1ed46a3fa975bcad97fbb564e09c31fedb619ea013af5d497f037481881fc2865317fec242f778f0787d7f79e372f0aaa
7
- data.tar.gz: b147aab99d3d73e2119f8c56646f641470e95b3bb66d0571343dc0bbe99105df3ad71b293e032d6b39152b2bd6421ab39bee8ed4d63cca0aabb2cdfd3b89a884
6
+ metadata.gz: 6a789dfbaa97c0642fa6d692ed3c5dc5430e25156635e9daa1817b5e3e4e1731add22148ab7ff6290d6bb0dfedf31d441f331bd09d4f24ec71bec52fd6e56494
7
+ data.tar.gz: 4f6ac286a62edd84f54a15d301f2096f701f461ad2a3ab2dfdac8d9e359c07345f7714fe103a168e42f1af6fd11b31b55c84a7b600bd6332945c8ed571abaf75
@@ -1,3 +1,6 @@
1
+ ## 3.1.2
2
+ - Added support for multiple events inside same message from SQS [#48](https://github.com/logstash-plugins/logstash-input-sqs/pull/48/files)
3
+
1
4
  ## 3.1.1
2
5
  - Docs: Set the default_codec doc attribute.
3
6
 
data/Gemfile CHANGED
@@ -9,3 +9,7 @@ if Dir.exist?(logstash_path) && use_logstash_source
9
9
  gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
10
  gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
11
  end
12
+
13
+ if RUBY_VERSION == "1.9.3"
14
+ gem 'rake', '12.2.1'
15
+ end
@@ -36,7 +36,7 @@ To use this plugin, you *must*:
36
36
 
37
37
  * Have an AWS account
38
38
  * Setup an SQS queue
39
- * Create an identify that has access to consume messages from the queue.
39
+ * Create an identity that has access to consume messages from the queue.
40
40
 
41
41
  The "consumer" identity must have the following permissions on the queue:
42
42
 
@@ -251,4 +251,4 @@ The AWS Session token for temporary credential
251
251
  [id="plugins-{type}s-{plugin}-common-options"]
252
252
  include::{include_path}/{type}.asciidoc[]
253
253
 
254
- :default_codec!:
254
+ :default_codec!:
@@ -121,25 +121,19 @@ class LogStash::Inputs::SQS < LogStash::Inputs::Threadable
121
121
  }
122
122
  end
123
123
 
124
- def decode_event(message)
125
- @codec.decode(message.body) do |event|
126
- return event
127
- end
128
- end
129
-
130
124
  def add_sqs_data(event, message)
131
125
  event.set(@id_field, message.message_id) if @id_field
132
126
  event.set(@md5_field, message.md5_of_body) if @md5_field
133
127
  event.set(@sent_timestamp_field, convert_epoch_to_timestamp(message.attributes[SENT_TIMESTAMP])) if @sent_timestamp_field
134
-
135
- return event
128
+ event
136
129
  end
137
130
 
138
- def handle_message(message)
139
- event = decode_event(message)
140
- add_sqs_data(event, message)
141
- decorate(event)
142
- return event
131
+ def handle_message(message, output_queue)
132
+ @codec.decode(message.body) do |event|
133
+ add_sqs_data(event, message)
134
+ decorate(event)
135
+ output_queue << event
136
+ end
143
137
  end
144
138
 
145
139
  def run(output_queue)
@@ -148,11 +142,7 @@ class LogStash::Inputs::SQS < LogStash::Inputs::Threadable
148
142
  run_with_backoff do
149
143
  poller.poll(polling_options) do |messages, stats|
150
144
  break if stop?
151
-
152
- messages.each do |message|
153
- output_queue << handle_message(message)
154
- end
155
-
145
+ messages.each {|message| handle_message(message, output_queue) }
156
146
  @logger.debug("SQS Stats:", :request_count => stats.request_count,
157
147
  :received_message_count => stats.received_message_count,
158
148
  :last_message_received_at => stats.last_message_received_at) if @logger.debug?
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-sqs'
3
- s.version = '3.1.1'
3
+ s.version = '3.1.2'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Pulls events from an Amazon Web Services Simple Queue Service queue"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -25,5 +25,6 @@ Gem::Specification.new do |s|
25
25
  s.add_runtime_dependency 'logstash-mixin-aws', '>= 4.3.0'
26
26
 
27
27
  s.add_development_dependency 'logstash-devutils'
28
+ s.add_development_dependency "logstash-codec-json_lines"
28
29
  end
29
30
 
@@ -138,7 +138,8 @@ describe LogStash::Inputs::SQS do
138
138
  subject { LogStash::Inputs::SQS::new(config.merge({ "codec" => "json" })) }
139
139
 
140
140
  it "uses the specified codec" do
141
- expect(subject.decode_event(encoded_message).get("bonjour")).to eq(decoded_message["bonjour"])
141
+ subject.handle_message(encoded_message, queue)
142
+ expect(queue.pop.get("bonjour")).to eq(decoded_message["bonjour"])
142
143
  end
143
144
  end
144
145
 
@@ -152,6 +153,21 @@ describe LogStash::Inputs::SQS do
152
153
  subject.run(queue)
153
154
  expect(queue.pop.get("bonjour")).to eq(decoded_message["bonjour"])
154
155
  end
156
+
157
+ context 'can create multiple events' do
158
+ require "logstash/codecs/json_lines"
159
+ let(:config) { super.merge({ "codec" => "json_lines" }) }
160
+ let(:first_message) { { "sequence" => "first" } }
161
+ let(:second_message) { { "sequence" => "second" } }
162
+ let(:encoded_message) { double("sqs_message", :body => "#{LogStash::Json::dump(first_message)}\n#{LogStash::Json::dump(second_message)}\n") }
163
+
164
+ it 'creates multiple events' do
165
+ expect(mock_sqs).to receive(:poll).with(anything()).and_yield([encoded_message], double("stats"))
166
+ subject.run(queue)
167
+ events = queue.map{ |e|e.get('sequence')}
168
+ expect(events).to match_array([first_message['sequence'], second_message['sequence']])
169
+ end
170
+ end
155
171
  end
156
172
 
157
173
  context "on errors" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-sqs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-06 00:00:00.000000000 Z
11
+ date: 2018-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ name: logstash-codec-json_lines
82
+ prerelease: false
83
+ type: :development
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
75
89
  description: This gem is a Logstash plugin required to be installed on top of the
76
90
  Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
77
91
  gem is not a stand-alone program
@@ -116,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
130
  version: '0'
117
131
  requirements: []
118
132
  rubyforge_project:
119
- rubygems_version: 2.6.11
133
+ rubygems_version: 2.6.13
120
134
  signing_key:
121
135
  specification_version: 4
122
136
  summary: Pulls events from an Amazon Web Services Simple Queue Service queue