Sha256: 79cd1f31f8f40a29e75c1cdfbcaa23587e8b75dbbd194181924370139941beaa

Contents?: true

Size: 1.75 KB

Versions: 16

Compression:

Stored size: 1.75 KB

Contents

#
# Fluentd
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#

require 'msgpack'
require 'fluent/time'

module Fluent
  module MessagePackFactory
    @@engine_factory = nil

    module Mixin
      def msgpack_factory
        MessagePackFactory.engine_factory
      end

      def msgpack_packer(*args)
        msgpack_factory.packer(*args)
      end

      def msgpack_unpacker(*args)
        msgpack_factory.unpacker(*args)
      end
    end

    def self.engine_factory
      @@engine_factory || factory
    end

    def self.factory
      factory = MessagePack::Factory.new
      factory.register_type(Fluent::EventTime::TYPE, Fluent::EventTime)
      factory
    end

    def self.packer(*args)
      factory.packer(*args)
    end

    def self.unpacker(*args)
      factory.unpacker(*args)
    end

    def self.init
      factory = MessagePack::Factory.new
      factory.register_type(Fluent::EventTime::TYPE, Fluent::EventTime)
      @@engine_factory = factory
    end

    def self.thread_local_msgpack_packer
      Thread.current[:local_msgpack_packer] ||= MessagePackFactory.engine_factory.packer
    end

    def self.thread_local_msgpack_unpacker
      Thread.current[:local_msgpack_unpacker] ||= MessagePackFactory.engine_factory.unpacker
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fluentd-1.7.4-x64-mingw32 lib/fluent/msgpack_factory.rb
fluentd-1.7.4-x86-mingw32 lib/fluent/msgpack_factory.rb
fluentd-1.7.4 lib/fluent/msgpack_factory.rb
fluentd-1.7.3-x64-mingw32 lib/fluent/msgpack_factory.rb
fluentd-1.7.3-x86-mingw32 lib/fluent/msgpack_factory.rb
fluentd-1.7.3 lib/fluent/msgpack_factory.rb
fluentd-1.7.2-x86-mingw32 lib/fluent/msgpack_factory.rb
fluentd-1.7.2-x64-mingw32 lib/fluent/msgpack_factory.rb
fluentd-1.7.2 lib/fluent/msgpack_factory.rb
fluentd-1.7.1-x64-mingw32 lib/fluent/msgpack_factory.rb
fluentd-1.7.1-x86-mingw32 lib/fluent/msgpack_factory.rb
fluentd-1.7.1 lib/fluent/msgpack_factory.rb
fluentd-1.7.0-x64-mingw32 lib/fluent/msgpack_factory.rb
fluentd-1.7.0-x86-mingw32 lib/fluent/msgpack_factory.rb
fluentd-1.7.0 lib/fluent/msgpack_factory.rb
fluentd-1.7.0.rc1 lib/fluent/msgpack_factory.rb