Class: Fluent::Test::Driver::MultiOutput

Inherits:
BaseOwner show all
Includes:
EventFeeder
Defined in:
lib/fluent/test/driver/multi_output.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_TIMEOUT

Instance Attribute Summary

Attributes inherited from Base

#instance, #logs

Instance Method Summary collapse

Methods included from EventFeeder

#feed, #feed_to_plugin

Methods inherited from BaseOwner

#configure, #emit_count, #emit_error_event, #emit_event_stream, #error_events, #event_streams, #events, #record_count

Methods inherited from Base

#break_if, #broken?, #configure, #end_if, #instance_hook_after_started, #instance_hook_before_stopped, #instance_shutdown, #instance_start, #stop?

Constructor Details

#initialize(klass, opts: {}, &block) ⇒ MultiOutput

Returns a new instance of MultiOutput.

Raises:

  • (ArgumentError)


28
29
30
31
32
# File 'lib/fluent/test/driver/multi_output.rb', line 28

def initialize(klass, opts: {}, &block)
  super
  raise ArgumentError, "plugin is not an instance of Fluent::Plugin::MultiOutput" unless @instance.is_a? Fluent::Plugin::MultiOutput
  @flush_buffer_at_cleanup = nil
end

Instance Method Details

#flushObject



47
48
49
# File 'lib/fluent/test/driver/multi_output.rb', line 47

def flush
  @instance.outputs.each{|o| o.force_flush }
end

#run(flush: true, **kwargs, &block) ⇒ Object



34
35
36
37
# File 'lib/fluent/test/driver/multi_output.rb', line 34

def run(flush: true, **kwargs, &block)
  @flush_buffer_at_cleanup = flush
  super(**kwargs, &block)
end

#run_actual(**kwargs, &block) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/fluent/test/driver/multi_output.rb', line 39

def run_actual(**kwargs, &block)
  val = super(**kwargs, &block)
  if @flush_buffer_at_cleanup
    @instance.outputs.each{|o| o.force_flush }
  end
  val
end