From 8045e5f5137348513f07308395370181e38ad343 Mon Sep 17 00:00:00 2001 From: Masahiro Nakagawa Date: Tue, 14 Jan 2020 17:38:28 +0900 Subject: [PATCH] Apply same changes to MessagePackFactory.factory Signed-off-by: Masahiro Nakagawa --- lib/fluent/msgpack_factory.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/fluent/msgpack_factory.rb b/lib/fluent/msgpack_factory.rb index 044cdf77b1..c5e06ed49e 100644 --- a/lib/fluent/msgpack_factory.rb +++ b/lib/fluent/msgpack_factory.rb @@ -44,8 +44,8 @@ def msgpack_unpacker(*args) end end - def self.engine_factory - @@engine_factory || factory + def self.engine_factory(enable_time_support: false) + @@engine_factory || factory(enable_time_support: enable_time_support) end def self.msgpack_packer(*args) @@ -56,9 +56,15 @@ def self.msgpack_unpacker(*args) engine_factory.unpacker(*args) end - def self.factory + def self.factory(enable_time_support: false) factory = MessagePack::Factory.new factory.register_type(Fluent::EventTime::TYPE, Fluent::EventTime) + if enable_time_support + factory.register_type( + MessagePack::Timestamp::TYPE, Time, + packer: MessagePack::Time::Packer, + unpacker: MessagePack::Time::Unpacker) + end factory end