logstash-codec-multiline 2.0.3 → 2.0.4

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: b89e4a5a454c8bc979aca1a959c06ad2d65e29bc
4
- data.tar.gz: 3eff2f29480107e6212eec95c096c18b3f82b55e
3
+ metadata.gz: cd43c9171bdc01db5f0d381b4c95994e7b6073d4
4
+ data.tar.gz: 07230a73ec9e7cb9ccddb94921d540323e4d0e86
5
5
  SHA512:
6
- metadata.gz: d7eb64acd24053b8ce18bfe111a5ab2917f5a41a3e979879ee1313bc64ffcf744ed85d11ade9843167bfe86579a34b8015d62b5fa0ee85d1356a1ac3360d246e
7
- data.tar.gz: 36580542f95f5b66d042f8a2e6ed69064b49a1e2c1e2400f0aa49bfeb8f54ec510b99646fc1758d3a9887fb41862d1fd7ad44c30cbf3be721bf73323221953af
6
+ metadata.gz: 2aec937d4fdf0bbde23c38dee5544198ee8bb5c89efe146bf96b24d4e77bf0f004ba197508168e37f700bd8ebcd913a4719a766b7ce7c7c50ce526b9f9d83623
7
+ data.tar.gz: 3174e737bc7922cbafec8cda5f1ee85ec9c1691e6918e5e61ab20da35167b6c9969147a4ff869e52057a8385190edd2058699fbc636bf5e69f3b7ccba8a60983
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 2.0.4
2
+ - Add constructional method to allow an eviction specific block to be set.
3
+
1
4
  ## 2.0.3
2
5
  - Add pseudo codec IdentityMapCodec. Support class for identity based multiline processing.
3
6
 
@@ -101,7 +101,8 @@ module LogStash module Codecs class IdentityMapCodec
101
101
  @max_identities = MAX_IDENTITIES
102
102
  @evict_timeout = EVICT_TIMEOUT
103
103
  @cleaner = MapCleaner.new(self, CLEANER_INTERVAL)
104
- @decode_block = lambda {|*| }
104
+ @decode_block = lambda {|*| true }
105
+ @eviction_block = nil
105
106
  end
106
107
 
107
108
  # ==============================================
@@ -126,6 +127,12 @@ module LogStash module Codecs class IdentityMapCodec
126
127
  @cleaner = MapCleaner.new(self, interval.to_i)
127
128
  self
128
129
  end
130
+
131
+ # used to add a non-default eviction block
132
+ def eviction_block(block)
133
+ @eviction_block = block
134
+ self
135
+ end
129
136
  # end Constructional/builder methods
130
137
  # ==============================================
131
138
 
@@ -184,7 +191,7 @@ module LogStash module Codecs class IdentityMapCodec
184
191
  # contents should not mutate during this call
185
192
  identity_map.delete_if do |identity, compo|
186
193
  if (flag = compo.timeout <= cut_off)
187
- compo.codec.flush(&@decode_block)
194
+ compo.codec.flush(&(@eviction_block || @decode_block))
188
195
  end
189
196
  flag
190
197
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-codec-multiline'
4
- s.version = '2.0.3'
4
+ s.version = '2.0.4'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "The multiline codec will collapse multiline messages and merge them into a single event."
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"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "codec" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
23
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
24
24
 
25
25
  s.add_runtime_dependency 'logstash-patterns-core'
26
26
  s.add_runtime_dependency 'jls-grok', '~> 0.11.1'
@@ -18,7 +18,7 @@ class IdentityMapCodecTracer
18
18
  def clone() self.class.new; end
19
19
  def decode(data) @tracer.push [:decode, data]; end
20
20
  def encode(event) @tracer.push [:encode, event]; end
21
- def flush(&block) @tracer.push [:flush, true]; end
21
+ def flush(&block) @tracer.push [:flush, block.call]; end
22
22
  def close() @tracer.push [:close, true]; end
23
23
  def logger() @logger ||= LogTracer.new; end
24
24
 
@@ -175,7 +175,7 @@ describe LogStash::Codecs::IdentityMapCodec do
175
175
  sleep(1.2)
176
176
  demuxer.decode(Object.new, "stream2")
177
177
  expect(demuxer.identity_count).to eq(limit)
178
- expect { demuxer.decode(Object.new, "stream4") }.not_to raise_error
178
+ expect { demuxer.decode(Object.new, "stream4"){|*| 42 } }.not_to raise_error
179
179
  end
180
180
  end
181
181
  end
@@ -195,12 +195,27 @@ describe LogStash::Codecs::IdentityMapCodec do
195
195
  end
196
196
 
197
197
  describe "codec eviction" do
198
- let(:demuxer) { described_class.new(codec).evict_timeout(1).cleaner_interval(1) }
199
198
  context "when an identity has become stale" do
199
+ let(:demuxer) { described_class.new(codec).evict_timeout(1).cleaner_interval(1) }
200
200
  it "the cleaner evicts the codec and flushes it first" do
201
- demuxer.decode(Object.new, "stream1")
201
+ demuxer.decode(Object.new, "stream1"){|*| 42}
202
+ sleep(2.1)
203
+ expect(codec.trace_for(:flush)).to eq(42)
204
+ expect(demuxer.identity_map.keys).not_to include("stream1")
205
+ end
206
+ end
207
+
208
+ context "when an identity has become stale and an evition block is set" do
209
+ let(:demuxer) do
210
+ described_class.new(codec)
211
+ .evict_timeout(1)
212
+ .cleaner_interval(1)
213
+ .eviction_block(lambda {|*| 24} )
214
+ end
215
+ it "the cleaner evicts the codec and flushes it first using the eviction_block" do
216
+ demuxer.decode(Object.new, "stream1"){|*| 42}
202
217
  sleep(2.1)
203
- expect(codec.trace_for(:flush)).to be_truthy
218
+ expect(codec.trace_for(:flush)).to eq(24)
204
219
  expect(demuxer.identity_map.keys).not_to include("stream1")
205
220
  end
206
221
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-codec-multiline
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-11 00:00:00.000000000 Z
11
+ date: 2015-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0.beta2
19
+ version: 2.0.0
20
20
  - - <
21
21
  - !ruby/object:Gem::Version
22
22
  version: 3.0.0
@@ -24,7 +24,7 @@ dependencies:
24
24
  requirements:
25
25
  - - '>='
26
26
  - !ruby/object:Gem::Version
27
- version: 2.0.0.beta2
27
+ version: 2.0.0
28
28
  - - <
29
29
  - !ruby/object:Gem::Version
30
30
  version: 3.0.0
@@ -78,18 +78,18 @@ executables: []
78
78
  extensions: []
79
79
  extra_rdoc_files: []
80
80
  files:
81
- - lib/logstash/codecs/identity_map_codec.rb
82
- - lib/logstash/codecs/multiline.rb
83
- - spec/codecs/multiline_spec.rb
84
- - spec/codecs/identity_map_codec_spec.rb
85
- - spec/supports/helpers.rb
86
- - logstash-codec-multiline.gemspec
87
- - README.md
88
81
  - CHANGELOG.md
89
82
  - CONTRIBUTORS
90
83
  - Gemfile
91
84
  - LICENSE
92
85
  - NOTICE.TXT
86
+ - README.md
87
+ - lib/logstash/codecs/identity_map_codec.rb
88
+ - lib/logstash/codecs/multiline.rb
89
+ - logstash-codec-multiline.gemspec
90
+ - spec/codecs/identity_map_codec_spec.rb
91
+ - spec/codecs/multiline_spec.rb
92
+ - spec/supports/helpers.rb
93
93
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
94
94
  licenses:
95
95
  - Apache License (2.0)
@@ -112,11 +112,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.1.9
115
+ rubygems_version: 2.4.8
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: The multiline codec will collapse multiline messages and merge them into a single event.
119
119
  test_files:
120
- - spec/codecs/multiline_spec.rb
121
120
  - spec/codecs/identity_map_codec_spec.rb
121
+ - spec/codecs/multiline_spec.rb
122
122
  - spec/supports/helpers.rb