forked from logstash-plugins/logstash-input-file
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Isolate test helper classes in their own namespace
Fixes logstash-plugins#92
- Loading branch information
1 parent
4a59f3b
commit baed94e
Showing
4 changed files
with
124 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
## 2.1.2 | ||
- Isolate test helper class in their own namespace | ||
|
||
## 2.1.1 | ||
- Correct LS core dependency version | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# encoding: utf-8 | ||
require "logstash/inputs/component" | ||
require "logstash/codecs/identity_map_codec" | ||
|
||
module LogStash module Inputs class IdentityMapCodecComponent | ||
include Component | ||
|
||
attr_reader :codec | ||
|
||
def add_codec(codec) | ||
@codec = LogStash::Codecs::IdentityMapCodec.new(codec) | ||
self | ||
end | ||
|
||
def stop | ||
@codec.close | ||
end | ||
|
||
def do_work(context, data) | ||
do_line(context, data) || do_eviction(context, data) | ||
end | ||
|
||
def process(context, data) | ||
# data should be an event | ||
deliver(context, data) | ||
end | ||
|
||
private | ||
|
||
def do_line(context, data) | ||
return false unless line?(context) | ||
@codec.decode_accept(context, data, self) | ||
# above should call back on #process | ||
true | ||
end | ||
|
||
def do_eviction(context, data) | ||
return false unless evicting?(context) | ||
path = context[:path] | ||
@codec.evict(path) if path | ||
true | ||
end | ||
|
||
def line?(ctx) | ||
action(ctx) == "line" | ||
end | ||
|
||
def evicting?(ctx) | ||
_action = action(ctx) | ||
_action == "timed_out" || _action == "deleted" | ||
end | ||
|
||
def action(ctx) | ||
ctx[:action] | ||
end | ||
end end end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters