Skip to content

Commit 28ec2ce

Browse files
andrewvcsuyograo
authored andcommitted
Take advantage of new LS 2.4/5.x features
- Use new 'concurrency :single' for concurrency - Use pipeline encoded codec for greater parallelism - Require Logstash 2.4+ (Plugin API 1.60.1+) Fixes #9
1 parent 70a758c commit 28ec2ce

File tree

4 files changed

+15
-23
lines changed

4 files changed

+15
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## 3.0.2
2-
- Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
3-
1+
## 3.1.0
2+
- Use new 'concurrency :single' for concurrency
3+
- Use pipeline encoded codec for greater parallelism
4+
- Require Logstash 2.4+ (Plugin API 1.60.1+)
45
## 3.0.1
56
- Republish all the gems under jruby.
67
## 3.0.0

lib/logstash/outputs/stdout.rb

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,16 @@
3333
#
3434
class LogStash::Outputs::Stdout < LogStash::Outputs::Base
3535
config_name "stdout"
36+
concurrency :single
3637

3738
default :codec, "line"
3839

39-
if self.respond_to?(:workers_not_supported!) # Check for v2.2+ API
40-
declare_workers_not_supported!("Stdout only supports one worker to prevent text overlap!")
41-
end
42-
43-
public
44-
def register
45-
workers_not_supported # < v2.2 API
40+
def register; end # must be overriden
4641

47-
@codec.on_event do |event, data|
42+
def multi_receive_encoded(encoded)
43+
encoded.each do |event,data|
4844
$stdout.write(data)
4945
end
5046
end
5147

52-
def receive(event)
53-
54-
return if event == LogStash::SHUTDOWN
55-
@codec.encode(event)
56-
end
57-
5848
end # class LogStash::Outputs::Stdout

logstash-output-stdout.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-output-stdout'
4-
s.version = '3.0.2'
4+
s.version = '3.1.0'
55
s.licenses = ['Apache License (2.0)']
66
s.summary = "A simple output which prints to the STDOUT of the shell running Logstash."
77
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"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
2020
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
2121

2222
# Gem dependencies
23-
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
23+
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60.1", "< 2.99"
2424
s.add_runtime_dependency 'logstash-codec-line'
2525

2626
s.add_development_dependency 'logstash-devutils'

spec/outputs/stdout_spec.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@
1313
subject { LogStash::Outputs::Stdout.new({}) }
1414

1515
let(:properties) { { "message" => "This is a message!"} }
16-
let(:event) { LogStash::Event.new(properties) }
16+
let(:event) { double("event") }
17+
let(:encoded) { double("encoded") }
1718

1819
before(:each) do
1920
subject.register
2021
end
2122

2223
it "sends the generated event out" do
23-
expect(subject.codec).to receive(:encode).with(event)
24-
subject.receive(event)
24+
expect($stdout).to receive(:write).with(encoded)
25+
subject.multi_receive_encoded([[event, encoded]])
2526
end
26-
27+
2728
end
2829

2930
end

0 commit comments

Comments
 (0)