logstash-input-redis 1.0.3 → 2.0.0

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
  SHA1:
3
- metadata.gz: 68987e0aa7d18a5e26559e24b54f8e96a786925a
4
- data.tar.gz: 72ce8f6a4031705347a35dacc4b5ec159c376465
3
+ metadata.gz: 9e5f594df8d7088bee997d66a0e95d7127cbcb0d
4
+ data.tar.gz: d7351c9c24266e975fe1e39480fb6d9e7f4799f8
5
5
  SHA512:
6
- metadata.gz: 180e9f98e97607f38f505b95b4939106795ae8c9280ef7a6cb5b6eaf0e958612609de629141fc9553fdaedfae4111b13488478f6dfe14170f6fcf525cc832ce2
7
- data.tar.gz: d2b0ae3f31e7e51eda007b62df6032ff015ffcc850cead2d65d78ea3beebb59b895ec7b060c967d7cd0a3f9badb42cde91a9cf8838fe2a19ba424d3f427b2038
6
+ metadata.gz: e4456f8d6cc3fce7ff155bc7356f97b7f0217a2a3f8a4ea0d0d801f0ffc680f39011b449bc2fcfe7e93cf374409bc7f0b55b0ac0077c823fbdc7538d24281813
7
+ data.tar.gz: 0dea51a35971a3db1127cf39ba1b9fcc8e8b82fbaaf6ca8615935ded25ae8a07501d80dc1d500daab8b0d2992d61e96f90d5c782566417e18e81122bdf708f96
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Logstash Plugin
2
2
 
3
- This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
4
 
5
5
  It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
6
 
7
7
  ## Documentation
8
8
 
9
- Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
9
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
10
10
 
11
11
  - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
- - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
13
13
 
14
14
  ## Need Help?
15
15
 
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
83
83
 
84
84
  It is more important to the community that you are able to contribute.
85
85
 
86
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -103,13 +103,13 @@ module LogStash module Inputs class Redis < LogStash::Inputs::Threadable
103
103
  # just switch on data_type once
104
104
  if @data_type == 'list' || @data_type == 'dummy'
105
105
  @run_method = method(:list_runner)
106
- @teardown_method = method(:list_teardown)
106
+ @stop_method = method(:list_stop)
107
107
  elsif @data_type == 'channel'
108
108
  @run_method = method(:channel_runner)
109
- @teardown_method = method(:subscribe_teardown)
109
+ @stop_method = method(:subscribe_stop)
110
110
  elsif @data_type == 'pattern_channel'
111
111
  @run_method = method(:pattern_channel_runner)
112
- @teardown_method = method(:subscribe_teardown)
112
+ @stop_method = method(:subscribe_stop)
113
113
  end
114
114
 
115
115
  # TODO(sissel, boertje): set @identity directly when @name config option is removed.
@@ -123,9 +123,8 @@ module LogStash module Inputs class Redis < LogStash::Inputs::Threadable
123
123
  # ignore and quit
124
124
  end # def run
125
125
 
126
- def teardown
127
- @shutdown_requested = true
128
- @teardown_method.call
126
+ def stop
127
+ @stop_method.call
129
128
  end
130
129
 
131
130
  # private methods -----------------------------
@@ -192,26 +191,13 @@ EOF
192
191
  decorate(event)
193
192
  output_queue << event
194
193
  end
195
- rescue LogStash::ShutdownSignal => e
196
- # propagate up
197
- raise(e)
198
194
  rescue => e # parse or event creation error
199
195
  @logger.error("Failed to create event", :message => msg, :exception => e, :backtrace => e.backtrace);
200
196
  end
201
197
  end
202
198
 
203
199
  # private
204
- def shutting_down?
205
- @shutdown_requested
206
- end
207
-
208
- # private
209
- def running?
210
- !@shutdown_requested
211
- end
212
-
213
- # private
214
- def list_teardown
200
+ def list_stop
215
201
  return if @redis.nil? || !@redis.connected?
216
202
 
217
203
  @redis.quit rescue nil
@@ -220,7 +206,7 @@ EOF
220
206
 
221
207
  # private
222
208
  def list_runner(output_queue)
223
- while running?
209
+ while !stop?
224
210
  begin
225
211
  @redis ||= connect
226
212
  list_listener(@redis, output_queue)
@@ -228,6 +214,8 @@ EOF
228
214
  @logger.warn("Redis connection problem", :exception => e)
229
215
  # Reset the redis variable to trigger reconnect
230
216
  @redis = nil
217
+ # this sleep does not need to be stoppable as its
218
+ # in a while !stop? loop
231
219
  sleep 1
232
220
  end
233
221
  end
@@ -277,7 +265,7 @@ EOF
277
265
  end
278
266
 
279
267
  # private
280
- def subscribe_teardown
268
+ def subscribe_stop
281
269
  return if @redis.nil? || !@redis.connected?
282
270
  # if its a SubscribedClient then:
283
271
  # it does not have a disconnect method (yet)
@@ -298,8 +286,8 @@ EOF
298
286
  @logger.warn("Redis connection problem", :exception => e)
299
287
  # Reset the redis variable to trigger reconnect
300
288
  @redis = nil
301
- sleep 1
302
- retry
289
+ Stud.stoppable_sleep(1) { stop? }
290
+ retry if !stop?
303
291
  end
304
292
  end
305
293
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-redis'
4
- s.version = '1.0.3'
4
+ s.version = '2.0.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This input will read events from a Redis instance"
7
7
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.require_paths = ["lib"]
12
12
 
13
13
  # Files
14
- s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
14
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
15
15
 
16
16
  # Tests
17
17
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
23
+ s.add_runtime_dependency "logstash-core", "~> 2.0.0.snapshot"
24
24
 
25
25
  s.add_runtime_dependency 'logstash-codec-json'
26
26
  s.add_runtime_dependency 'redis'
@@ -78,7 +78,8 @@ describe LogStash::Inputs::Redis do
78
78
  let(:accumulator) { [] }
79
79
 
80
80
  subject do
81
- described_class.new(cfg).add_external_redis_builder(builder)
81
+ LogStash::Plugin.lookup("input", "redis")
82
+ .new(cfg).add_external_redis_builder(builder)
82
83
  end
83
84
 
84
85
  context 'construction' do
@@ -92,7 +93,7 @@ describe LogStash::Inputs::Redis do
92
93
  subject.register
93
94
  end
94
95
 
95
- context 'teardown when redis is unset' do
96
+ context 'close when redis is unset' do
96
97
  let(:quit_calls) { [:quit, :unsubscribe, :punsubscribe, :connection, :disconnect!] }
97
98
 
98
99
  it 'does not attempt to quit' do
@@ -100,7 +101,7 @@ describe LogStash::Inputs::Redis do
100
101
  quit_calls.each do |call|
101
102
  expect(redis).not_to receive(call)
102
103
  end
103
- expect {subject.teardown}.not_to raise_error
104
+ expect {subject.do_stop}.not_to raise_error
104
105
  end
105
106
  end
106
107
 
@@ -112,7 +113,7 @@ describe LogStash::Inputs::Redis do
112
113
 
113
114
  tt = Thread.new do
114
115
  sleep 0.01
115
- subject.teardown
116
+ subject.do_stop
116
117
  end
117
118
 
118
119
  subject.run(accumulator)
@@ -122,7 +123,7 @@ describe LogStash::Inputs::Redis do
122
123
  expect(accumulator.size).to be > 0
123
124
  end
124
125
 
125
- it 'multiple teardown calls, calls to redis once' do
126
+ it 'multiple close calls, calls to redis once' do
126
127
  subject.use_redis(redis)
127
128
  allow(redis).to receive(:blpop).and_return(['foo', 'l1'])
128
129
  expect(redis).to receive(:connected?).and_return(connected.last)
@@ -130,10 +131,10 @@ describe LogStash::Inputs::Redis do
130
131
  expect(redis).to receive(call).at_most(:once)
131
132
  end
132
133
 
133
- subject.teardown
134
+ subject.do_stop
134
135
  connected.push(false) #can't use let block here so push to array
135
- expect {subject.teardown}.not_to raise_error
136
- subject.teardown
136
+ expect {subject.do_stop}.not_to raise_error
137
+ subject.do_stop
137
138
  end
138
139
  end
139
140
 
@@ -153,11 +154,11 @@ describe LogStash::Inputs::Redis do
153
154
  end
154
155
  end
155
156
 
156
- def teardown_thread(inst, rt)
157
+ def close_thread(inst, rt)
157
158
  Thread.new(inst, rt) do |subj, runner|
158
159
  sleep 0.4 # allow the messages through
159
160
  runner.raise(LogStash::ShutdownSignal)
160
- subj.teardown
161
+ subj.close
161
162
  end
162
163
  end
163
164
 
@@ -188,11 +189,11 @@ describe LogStash::Inputs::Redis do
188
189
  let(:quit_calls) { [:unsubscribe, :connection] }
189
190
 
190
191
  context 'mocked redis' do
191
- it 'multiple teardown calls, calls to redis once', type: :mocked do
192
- subject.teardown
192
+ it 'multiple stop calls, calls to redis once', type: :mocked do
193
+ subject.do_stop
193
194
  connected.push(false) #can't use let block here so push to array
194
- expect {subject.teardown}.not_to raise_error
195
- subject.teardown
195
+ expect {subject.do_stop}.not_to raise_error
196
+ subject.do_stop
196
197
  end
197
198
  end
198
199
 
@@ -203,7 +204,7 @@ describe LogStash::Inputs::Redis do
203
204
  #simulate the other system thread
204
205
  publish_thread(instance.new_redis_instance, 'c').join
205
206
  #simulate the pipeline thread
206
- teardown_thread(instance, rt).join
207
+ close_thread(instance, rt).join
207
208
 
208
209
  expect(accumulator.size).to eq(2)
209
210
  end
@@ -215,11 +216,11 @@ describe LogStash::Inputs::Redis do
215
216
  let(:quit_calls) { [:punsubscribe, :connection] }
216
217
 
217
218
  context 'mocked redis' do
218
- it 'multiple teardown calls, calls to redis once', type: :mocked do
219
- subject.teardown
219
+ it 'multiple stop calls, calls to redis once', type: :mocked do
220
+ subject.do_stop
220
221
  connected.push(false) #can't use let block here so push to array
221
- expect {subject.teardown}.not_to raise_error
222
- subject.teardown
222
+ expect {subject.do_stop}.not_to raise_error
223
+ subject.do_stop
223
224
  end
224
225
  end
225
226
 
@@ -230,7 +231,7 @@ describe LogStash::Inputs::Redis do
230
231
  #simulate the other system thread
231
232
  publish_thread(instance.new_redis_instance, 'pc').join
232
233
  #simulate the pipeline thread
233
- teardown_thread(instance, rt).join
234
+ close_thread(instance, rt).join
234
235
 
235
236
  expect(accumulator.size).to eq(2)
236
237
  end
@@ -238,4 +239,9 @@ describe LogStash::Inputs::Redis do
238
239
  end
239
240
  end
240
241
 
242
+ describe LogStash::Inputs::Redis do
243
+ it_behaves_like "an interruptible input plugin" do
244
+ let(:config) { {'key' => 'foo', 'data_type' => 'list'} }
245
+ end
246
+ end
241
247
  end
metadata CHANGED
@@ -1,91 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-03 00:00:00.000000000 Z
11
+ date: 2015-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: logstash-core
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: 1.4.0
20
- - - <
21
- - !ruby/object:Gem::Version
22
- version: 2.0.0
23
14
  requirement: !ruby/object:Gem::Requirement
24
15
  requirements:
25
- - - '>='
16
+ - - ~>
26
17
  - !ruby/object:Gem::Version
27
- version: 1.4.0
28
- - - <
29
- - !ruby/object:Gem::Version
30
- version: 2.0.0
18
+ version: 2.0.0.snapshot
19
+ name: logstash-core
31
20
  prerelease: false
32
21
  type: :runtime
33
- - !ruby/object:Gem::Dependency
34
- name: logstash-codec-json
35
22
  version_requirements: !ruby/object:Gem::Requirement
36
23
  requirements:
37
- - - '>='
24
+ - - ~>
38
25
  - !ruby/object:Gem::Version
39
- version: '0'
26
+ version: 2.0.0.snapshot
27
+ - !ruby/object:Gem::Dependency
40
28
  requirement: !ruby/object:Gem::Requirement
41
29
  requirements:
42
30
  - - '>='
43
31
  - !ruby/object:Gem::Version
44
32
  version: '0'
33
+ name: logstash-codec-json
45
34
  prerelease: false
46
35
  type: :runtime
47
- - !ruby/object:Gem::Dependency
48
- name: redis
49
36
  version_requirements: !ruby/object:Gem::Requirement
50
37
  requirements:
51
38
  - - '>='
52
39
  - !ruby/object:Gem::Version
53
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
54
42
  requirement: !ruby/object:Gem::Requirement
55
43
  requirements:
56
44
  - - '>='
57
45
  - !ruby/object:Gem::Version
58
46
  version: '0'
47
+ name: redis
59
48
  prerelease: false
60
49
  type: :runtime
61
- - !ruby/object:Gem::Dependency
62
- name: logstash-devutils
63
50
  version_requirements: !ruby/object:Gem::Requirement
64
51
  requirements:
65
52
  - - '>='
66
53
  - !ruby/object:Gem::Version
67
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
68
56
  requirement: !ruby/object:Gem::Requirement
69
57
  requirements:
70
58
  - - '>='
71
59
  - !ruby/object:Gem::Version
72
60
  version: '0'
61
+ name: logstash-devutils
73
62
  prerelease: false
74
63
  type: :development
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
75
69
  description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
76
70
  email: info@elastic.co
77
71
  executables: []
78
72
  extensions: []
79
73
  extra_rdoc_files: []
80
74
  files:
81
- - .gitignore
82
75
  - CHANGELOG.md
83
76
  - CONTRIBUTORS
84
77
  - Gemfile
85
78
  - LICENSE
86
79
  - NOTICE.TXT
87
80
  - README.md
88
- - Rakefile
89
81
  - lib/logstash/inputs/redis.rb
90
82
  - logstash-input-redis.gemspec
91
83
  - spec/inputs/redis_spec.rb
@@ -111,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
103
  version: '0'
112
104
  requirements: []
113
105
  rubyforge_project:
114
- rubygems_version: 2.1.9
106
+ rubygems_version: 2.4.8
115
107
  signing_key:
116
108
  specification_version: 4
117
109
  summary: This input will read events from a Redis instance
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- Gemfile.lock
3
- .bundle
4
- vendor
data/Rakefile DELETED
@@ -1,7 +0,0 @@
1
- @files=[]
2
-
3
- task :default do
4
- system("rake -T")
5
- end
6
-
7
- require "logstash/devutils/rake"