Skip to content

Commit

Permalink
Apply same changes to MessagePackFactory.factory
Browse files Browse the repository at this point in the history
Signed-off-by: Masahiro Nakagawa <[email protected]>
  • Loading branch information
repeatedly committed Jan 14, 2020
1 parent b8625f0 commit 8045e5f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/fluent/msgpack_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 8045e5f

Please sign in to comment.