Sha256: 3c2757a88120389139070e8808babce4bb1a497ab05ef01b4c0662576ded0aa9

Contents?: true

Size: 1.79 KB

Versions: 27

Compression:

Stored size: 1.79 KB

Contents

require_relative 'helper'
require 'fluent/input'
require 'fluent/output'
require 'fluent/filter'

module FluentTest
  class FluentTestInput < ::Fluent::Input
    ::Fluent::Plugin.register_input('test_in', self)

    attr_reader :started

    def start
      @started = true
    end

    def shutdown
      @started = false
    end
  end

  class FluentTestOutput < ::Fluent::Output
    ::Fluent::Plugin.register_output('test_out', self)

    def initialize
      super
      @events = Hash.new { |h, k| h[k] = [] }
    end

    attr_reader :events
    attr_reader :started

    def start
      @started = true
    end

    def shutdown
      @started = false
    end

    def emit(tag, es, chain)
      es.each { |time, record|
        @events[tag] << record
      }
    end
  end

  class FluentTestErrorOutput < ::Fluent::BufferedOutput
    ::Fluent::Plugin.register_output('test_out_error', self)

    def format(tag, time, record)
      raise "emit error!"
    end

    def write(chunk)
      raise "chunk error!"
    end
  end

  class FluentTestFilter < ::Fluent::Filter
    ::Fluent::Plugin.register_filter('test_filter', self)

    def initialize(field = '__test__')
      super()
      @num = 0
      @field = field
    end

    attr_reader :num
    attr_reader :started

    def start
      @started = true
    end

    def shutdown
      @started = false
    end

    def filter(tag, time, record)
      record[@field] = @num
      @num += 1
      record
    end
  end

  class TestEmitErrorHandler
    def initialize
      @events = Hash.new { |h, k| h[k] = [] }
    end

    attr_reader :events

    def handle_emit_error(tag, time, record, error)
      @events[tag] << record
    end

    def handle_emits_error(tag, es, error)
      es.each { |time,record| handle_emit_error(tag, time, record, error) }
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
fluentd-0.12.43 test/test_plugin_classes.rb
fluentd-0.12.42 test/test_plugin_classes.rb
fluentd-0.12.41 test/test_plugin_classes.rb
fluentd-0.12.40 test/test_plugin_classes.rb
fluentd-0.12.39 test/test_plugin_classes.rb
fluentd-0.12.38 test/test_plugin_classes.rb
fluentd-0.12.37 test/test_plugin_classes.rb
fluentd-0.12.36 test/test_plugin_classes.rb
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/fluentd-0.12.35/test/test_plugin_classes.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/fluentd-0.12.35/test/test_plugin_classes.rb
fluentd-0.12.35 test/test_plugin_classes.rb
fluentd-0.12.34 test/test_plugin_classes.rb
fluentd-0.12.33 test/test_plugin_classes.rb
fluentd-0.12.32 test/test_plugin_classes.rb
fluentd-0.12.31 test/test_plugin_classes.rb
fluentd-0.12.30 test/test_plugin_classes.rb
fluentd-0.12.29 test/test_plugin_classes.rb
fluentd-0.12.28 test/test_plugin_classes.rb
fluentd-0.12.27 test/test_plugin_classes.rb
fluentd-0.14.1 test/test_plugin_classes.rb