Skip to content

Commit f78fb3a

Browse files
committed
perf: reuse inner packforward payload unpacker
1 parent 1a2a6ae commit f78fb3a

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 3.4.2
2+
- Fix: reduce overhead of unpacking packforward-payloads by reusing a single instance
3+
14
## 3.4.1
25
- Fix: handle multiple PackForward-encoded messages in a single payload [#28](https://github.com/logstash-plugins/logstash-codec-fluent/pull/28)
36

lib/logstash/codecs/fluent.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def register
5454
end
5555
@packer = @factory.packer
5656
@decoder = @factory.unpacker
57+
@packforward_decoder = nil
5758
end
5859

5960
def decode(data, &block)
@@ -117,7 +118,7 @@ def decode_event(data, &block)
117118
raise(LogStash::Error, "PackedForward with compression is not supported")
118119
end
119120

120-
entries_decoder = @factory.unpacker
121+
entries_decoder = (@packforward_decoder ||= @factory.unpacker).tap(&:reset)
121122
entries_decoder.feed_each(entries) do |entry|
122123
yield generate_event(entry[1], entry[0], tag)
123124
end

logstash-codec-fluent.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-codec-fluent'
4-
s.version = '3.4.1'
4+
s.version = '3.4.2'
55
s.licenses = ['Apache License (2.0)']
66
s.summary = "Reads the `fluentd` `msgpack` schema"
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"

0 commit comments

Comments
 (0)