Module: Fluent::MessagePackFactory
- Defined in:
- lib/fluent/msgpack_factory.rb
Defined Under Namespace
Modules: Mixin
Constant Summary collapse
- @@engine_factory =
nil
Class Method Summary collapse
- .engine_factory(enable_time_support: false) ⇒ Object
- .factory(enable_time_support: false) ⇒ Object
- .init(enable_time_support: false) ⇒ Object
- .msgpack_packer(*args) ⇒ Object
- .msgpack_unpacker(*args) ⇒ Object
- .packer(*args) ⇒ Object
- .thread_local_msgpack_packer ⇒ Object
- .thread_local_msgpack_unpacker ⇒ Object
- .unpacker(*args) ⇒ Object
Class Method Details
.engine_factory(enable_time_support: false) ⇒ Object
54 55 56 |
# File 'lib/fluent/msgpack_factory.rb', line 54 def self.engine_factory(enable_time_support: false) @@engine_factory || factory(enable_time_support: enable_time_support) end |
.factory(enable_time_support: false) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fluent/msgpack_factory.rb', line 66 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 |
.init(enable_time_support: false) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/fluent/msgpack_factory.rb', line 86 def self.init(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 @@engine_factory = factory end |
.msgpack_packer(*args) ⇒ Object
58 59 60 |
# File 'lib/fluent/msgpack_factory.rb', line 58 def self.msgpack_packer(*args) engine_factory.packer(*args) end |
.msgpack_unpacker(*args) ⇒ Object
62 63 64 |
# File 'lib/fluent/msgpack_factory.rb', line 62 def self.msgpack_unpacker(*args) engine_factory.unpacker(*args) end |
.packer(*args) ⇒ Object
78 79 80 |
# File 'lib/fluent/msgpack_factory.rb', line 78 def self.packer(*args) factory.packer(*args) end |
.thread_local_msgpack_packer ⇒ Object
98 99 100 |
# File 'lib/fluent/msgpack_factory.rb', line 98 def self.thread_local_msgpack_packer Thread.current[:local_msgpack_packer] ||= MessagePackFactory.engine_factory.packer end |
.thread_local_msgpack_unpacker ⇒ Object
102 103 104 |
# File 'lib/fluent/msgpack_factory.rb', line 102 def self.thread_local_msgpack_unpacker Thread.current[:local_msgpack_unpacker] ||= MessagePackFactory.engine_factory.unpacker end |
.unpacker(*args) ⇒ Object
82 83 84 |
# File 'lib/fluent/msgpack_factory.rb', line 82 def self.unpacker(*args) factory.unpacker(*args) end |