logstash-input-file 2.1.1 → 2.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
  SHA1:
3
- metadata.gz: 417605ca7bc53cf7e4a03fc248c4573b9b2fa919
4
- data.tar.gz: b7e9074f7b0d5cd570a4c7b175001cd91e992abf
3
+ metadata.gz: a518dc6300f2a903753525dcf94fc0f584c7e649
4
+ data.tar.gz: da489dd9356805859dca510bb43b22a8d87a619d
5
5
  SHA512:
6
- metadata.gz: 4b4443562d76d72939e0c2102e514af299dd07e5ec6250caefb8d9e31470b89cba31c19b8d3cb8157a0fd2d902c5e817e772072264128bf7078efa7810a82af5
7
- data.tar.gz: f09929bf7d6f240ac7db866083845933d04cb4215b6709c5ad753c7807a266c17c3532d1505472bd69320dfaacf99c6977eec30503db1563125ebdffbacc0a8b
6
+ metadata.gz: c8f9f23d212d58b1a8fa491ee66d988352877dc9726cd728dc3ac520849985001b3f916c636142fa8a9dd7e5301bb34c95d27a61201e8df0858626995abb5f2a
7
+ data.tar.gz: 094901654c14d47f5216b9d4382b1006f1f94150c67e3a83ddacfd1f6e086b0d84692c186937c6c57515c455a597cb1f11c3e47cfc4200b25953dc63793773ff
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 2.1.2
2
+ - Isolate test helper class in their own namespace
3
+
1
4
  ## 2.1.1
2
5
  - Correct LS core dependency version
3
6
 
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/component"
3
+ require "logstash/codecs/identity_map_codec"
4
+
5
+ module LogStash module Inputs class IdentityMapCodecComponent
6
+ include Component
7
+
8
+ attr_reader :codec
9
+
10
+ def add_codec(codec)
11
+ @codec = LogStash::Codecs::IdentityMapCodec.new(codec)
12
+ self
13
+ end
14
+
15
+ def stop
16
+ @codec.close
17
+ end
18
+
19
+ def do_work(context, data)
20
+ do_line(context, data) || do_eviction(context, data)
21
+ end
22
+
23
+ def process(context, data)
24
+ # data should be an event
25
+ deliver(context, data)
26
+ end
27
+
28
+ private
29
+
30
+ def do_line(context, data)
31
+ return false unless line?(context)
32
+ @codec.decode_accept(context, data, self)
33
+ # above should call back on #process
34
+ true
35
+ end
36
+
37
+ def do_eviction(context, data)
38
+ return false unless evicting?(context)
39
+ path = context[:path]
40
+ @codec.evict(path) if path
41
+ true
42
+ end
43
+
44
+ def line?(ctx)
45
+ action(ctx) == "line"
46
+ end
47
+
48
+ def evicting?(ctx)
49
+ _action = action(ctx)
50
+ _action == "timed_out" || _action == "deleted"
51
+ end
52
+
53
+ def action(ctx)
54
+ ctx[:action]
55
+ end
56
+ end end end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-file'
4
- s.version = '2.1.1'
4
+ s.version = '2.1.2'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Stream events from files."
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"
@@ -147,7 +147,7 @@ describe LogStash::Inputs::File do
147
147
  let(:mlconf) { Hash.new }
148
148
  let(:events) { Array.new }
149
149
  let(:mlcodec) { LogStash::Codecs::Multiline.new(mlconf) }
150
- let(:codec) { CodecTracer.new }
150
+ let(:codec) { FileInput::CodecTracer.new }
151
151
  let(:tmpfile_path) { Stud::Temporary.pathname }
152
152
  let(:sincedb_path) { Stud::Temporary.pathname }
153
153
  let(:tmpdir_path) { Stud::Temporary.directory }
data/spec/spec_helper.rb CHANGED
@@ -2,78 +2,85 @@
2
2
 
3
3
  require "logstash/devutils/rspec/spec_helper"
4
4
 
5
- class TracerBase
6
- def initialize() @tracer = []; end
5
+ module FileInput
6
+ class TracerBase
7
+ def initialize() @tracer = []; end
7
8
 
8
- def trace_for(symbol)
9
- params = @tracer.map {|k,v| k == symbol ? v : nil}.compact
10
- params.empty? ? false : params
11
- end
9
+ def trace_for(symbol)
10
+ params = @tracer.map {|k,v| k == symbol ? v : nil}.compact
11
+ params.empty? ? false : params
12
+ end
12
13
 
13
- def clear()
14
- @tracer.clear()
14
+ def clear()
15
+ @tracer.clear()
16
+ end
15
17
  end
16
- end
17
-
18
- class FileLogTracer < TracerBase
19
- def warn(*args) @tracer.push [:warn, args]; end
20
- def error(*args) @tracer.push [:error, args]; end
21
- def debug(*args) @tracer.push [:debug, args]; end
22
- def info(*args) @tracer.push [:info, args]; end
23
18
 
24
- def info?() true; end
25
- def debug?() true; end
26
- def warn?() true; end
27
- def error?() true; end
28
- end
29
-
30
- class ComponentTracer < TracerBase
31
- def accept(*args) @tracer.push [:accept, args]; end
32
- def deliver(*args) @tracer.push [:deliver, args]; end
33
- end
19
+ class FileLogTracer < TracerBase
20
+ def warn(*args) @tracer.push [:warn, args]; end
21
+ def error(*args) @tracer.push [:error, args]; end
22
+ def debug(*args) @tracer.push [:debug, args]; end
23
+ def info(*args) @tracer.push [:info, args]; end
34
24
 
35
- class CodecTracer < TracerBase
36
- def decode_accept(ctx, data, listener)
37
- @tracer.push [:decode_accept, [ctx, data]]
38
- listener.process(ctx, {"message" => data})
39
- end
40
- def accept(listener)
41
- @tracer.push [:accept, true]
42
- end
43
- def auto_flush()
44
- @tracer.push [:auto_flush, true]
25
+ def info?() true; end
26
+ def debug?() true; end
27
+ def warn?() true; end
28
+ def error?() true; end
45
29
  end
46
- def close
47
- @tracer.push [:close, true]
30
+
31
+ class ComponentTracer < TracerBase
32
+ def accept(*args) @tracer.push [:accept, args]; end
33
+ def deliver(*args) @tracer.push [:deliver, args]; end
48
34
  end
49
- def clone
50
- self.class.new
35
+
36
+ class CodecTracer < TracerBase
37
+ def decode_accept(ctx, data, listener)
38
+ @tracer.push [:decode_accept, [ctx, data]]
39
+ listener.process(ctx, {"message" => data})
40
+ end
41
+ def accept(listener)
42
+ @tracer.push [:accept, true]
43
+ end
44
+ def auto_flush()
45
+ @tracer.push [:auto_flush, true]
46
+ end
47
+ def close
48
+ @tracer.push [:close, true]
49
+ end
50
+ def clone
51
+ self.class.new
52
+ end
51
53
  end
52
54
  end
53
55
 
54
- module Kernel
55
- def pause_until(nap = 5, &block)
56
- sq = SizedQueue.new(1)
57
- th1 = Thread.new(sq) {|q| sleep nap; q.push(false) }
58
- th2 = Thread.new(sq) do |q|
59
- success = false
60
- iters = nap * 5 + 1
61
- iters.times do
62
- break if !!(success = block.call)
63
- sleep(0.2)
56
+ unless Kernel.method_defined?(:pause_until)
57
+ module Kernel
58
+ def pause_until(nap = 5, &block)
59
+ sq = SizedQueue.new(1)
60
+ th1 = Thread.new(sq) {|q| sleep nap; q.push(false) }
61
+ th2 = Thread.new(sq) do |q|
62
+ success = false
63
+ iters = nap * 5 + 1
64
+ iters.times do
65
+ break if !!(success = block.call)
66
+ sleep(0.2)
67
+ end
68
+ q.push(success)
64
69
  end
65
- q.push(success)
70
+ sq.pop
66
71
  end
67
- sq.pop
68
72
  end
69
73
  end
70
74
 
71
- RSpec::Matchers.define(:receive_call_and_args) do |m, args|
72
- match do |actual|
73
- actual.trace_for(m) == args
74
- end
75
+ unless RSpec::Matchers.method_defined?(:receive_call_and_args)
76
+ RSpec::Matchers.define(:receive_call_and_args) do |m, args|
77
+ match do |actual|
78
+ actual.trace_for(m) == args
79
+ end
75
80
 
76
- failure_message do
77
- "Expecting method #{m} to receive: #{args} but got: #{actual.trace_for(m)}"
81
+ failure_message do
82
+ "Expecting method #{m} to receive: #{args} but got: #{actual.trace_for(m)}"
83
+ end
78
84
  end
79
85
  end
86
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-file
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
@@ -11,8 +11,7 @@ cert_chain: []
11
11
  date: 2015-12-30 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
14
+ requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - '>='
18
17
  - !ruby/object:Gem::Version
@@ -20,7 +19,10 @@ dependencies:
20
19
  - - <
21
20
  - !ruby/object:Gem::Version
22
21
  version: 3.0.0
23
- requirement: !ruby/object:Gem::Requirement
22
+ name: logstash-core
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
24
26
  requirements:
25
27
  - - '>='
26
28
  - !ruby/object:Gem::Version
@@ -28,46 +30,35 @@ dependencies:
28
30
  - - <
29
31
  - !ruby/object:Gem::Version
30
32
  version: 3.0.0
31
- prerelease: false
32
- type: :runtime
33
33
  - !ruby/object:Gem::Dependency
34
- name: logstash-codec-plain
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - '>='
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
34
  requirement: !ruby/object:Gem::Requirement
41
35
  requirements:
42
36
  - - '>='
43
37
  - !ruby/object:Gem::Version
44
38
  version: '0'
39
+ name: logstash-codec-plain
45
40
  prerelease: false
46
41
  type: :runtime
47
- - !ruby/object:Gem::Dependency
48
- name: addressable
49
42
  version_requirements: !ruby/object:Gem::Requirement
50
43
  requirements:
51
44
  - - '>='
52
45
  - !ruby/object:Gem::Version
53
46
  version: '0'
47
+ - !ruby/object:Gem::Dependency
54
48
  requirement: !ruby/object:Gem::Requirement
55
49
  requirements:
56
50
  - - '>='
57
51
  - !ruby/object:Gem::Version
58
52
  version: '0'
53
+ name: addressable
59
54
  prerelease: false
60
55
  type: :runtime
61
- - !ruby/object:Gem::Dependency
62
- name: filewatch
63
56
  version_requirements: !ruby/object:Gem::Requirement
64
57
  requirements:
65
58
  - - '>='
66
59
  - !ruby/object:Gem::Version
67
- version: 0.7.0
68
- - - ~>
69
- - !ruby/object:Gem::Version
70
- version: '0.7'
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
71
62
  requirement: !ruby/object:Gem::Requirement
72
63
  requirements:
73
64
  - - '>='
@@ -76,64 +67,73 @@ dependencies:
76
67
  - - ~>
77
68
  - !ruby/object:Gem::Version
78
69
  version: '0.7'
70
+ name: filewatch
79
71
  prerelease: false
80
72
  type: :runtime
81
- - !ruby/object:Gem::Dependency
82
- name: logstash-codec-multiline
83
73
  version_requirements: !ruby/object:Gem::Requirement
84
74
  requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.7.0
85
78
  - - ~>
86
79
  - !ruby/object:Gem::Version
87
- version: 2.0.5
80
+ version: '0.7'
81
+ - !ruby/object:Gem::Dependency
88
82
  requirement: !ruby/object:Gem::Requirement
89
83
  requirements:
90
84
  - - ~>
91
85
  - !ruby/object:Gem::Version
92
86
  version: 2.0.5
87
+ name: logstash-codec-multiline
93
88
  prerelease: false
94
89
  type: :runtime
95
- - !ruby/object:Gem::Dependency
96
- name: stud
97
90
  version_requirements: !ruby/object:Gem::Requirement
98
91
  requirements:
99
92
  - - ~>
100
93
  - !ruby/object:Gem::Version
101
- version: 0.0.19
94
+ version: 2.0.5
95
+ - !ruby/object:Gem::Dependency
102
96
  requirement: !ruby/object:Gem::Requirement
103
97
  requirements:
104
98
  - - ~>
105
99
  - !ruby/object:Gem::Version
106
100
  version: 0.0.19
101
+ name: stud
107
102
  prerelease: false
108
103
  type: :development
109
- - !ruby/object:Gem::Dependency
110
- name: logstash-devutils
111
104
  version_requirements: !ruby/object:Gem::Requirement
112
105
  requirements:
113
- - - '>='
106
+ - - ~>
114
107
  - !ruby/object:Gem::Version
115
- version: '0'
108
+ version: 0.0.19
109
+ - !ruby/object:Gem::Dependency
116
110
  requirement: !ruby/object:Gem::Requirement
117
111
  requirements:
118
112
  - - '>='
119
113
  - !ruby/object:Gem::Version
120
114
  version: '0'
115
+ name: logstash-devutils
121
116
  prerelease: false
122
117
  type: :development
123
- - !ruby/object:Gem::Dependency
124
- name: logstash-codec-json
125
118
  version_requirements: !ruby/object:Gem::Requirement
126
119
  requirements:
127
120
  - - '>='
128
121
  - !ruby/object:Gem::Version
129
122
  version: '0'
123
+ - !ruby/object:Gem::Dependency
130
124
  requirement: !ruby/object:Gem::Requirement
131
125
  requirements:
132
126
  - - '>='
133
127
  - !ruby/object:Gem::Version
134
128
  version: '0'
129
+ name: logstash-codec-json
135
130
  prerelease: false
136
131
  type: :development
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
137
  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
138
138
  email: info@elastic.co
139
139
  executables: []
@@ -147,6 +147,7 @@ files:
147
147
  - NOTICE.TXT
148
148
  - README.md
149
149
  - lib/logstash/inputs/file.rb
150
+ - lib/logstash/inputs/identity_map_codec_component.rb
150
151
  - logstash-input-file.gemspec
151
152
  - spec/inputs/file_spec.rb
152
153
  - spec/spec_helper.rb
@@ -172,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
173
  version: '0'
173
174
  requirements: []
174
175
  rubyforge_project:
175
- rubygems_version: 2.4.8
176
+ rubygems_version: 2.4.5
176
177
  signing_key:
177
178
  specification_version: 4
178
179
  summary: Stream events from files.