Class: Fluent::Test::Driver::Output
Instance Attribute Summary
Attributes inherited from Base
#instance, #logs
Instance Method Summary
collapse
#feed, #feed_to_plugin
Methods inherited from BaseOwner
#configure, #emit_count, #emit_error_event, #emit_event_stream, #error_events, #events, #record_count
Methods inherited from Base
#break_if, #broken?, #configure, #end_if, #instance_shutdown, #instance_start, #stop?
Constructor Details
#initialize(klass, opts: {}, &block) ⇒ Output
Returns a new instance of Output.
28
29
30
31
32
33
34
35
|
# File 'lib/fluent/test/driver/output.rb', line 28
def initialize(klass, opts: {}, &block)
super
raise ArgumentError, "plugin is not an instance of Fluent::Plugin::Output" unless @instance.is_a? Fluent::Plugin::Output
@instance.in_tests = true
@flush_buffer_at_cleanup = nil
@format_hook = nil
@format_results = []
end
|
Instance Method Details
#flush ⇒ Object
53
54
55
|
# File 'lib/fluent/test/driver/output.rb', line 53
def flush
@instance.force_flush
end
|
49
50
51
|
# File 'lib/fluent/test/driver/output.rb', line 49
def formatted
@format_results
end
|
#instance_hook_after_started ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/fluent/test/driver/output.rb', line 57
def instance_hook_after_started
super
if @instance.instance_eval{ @custom_format }
@format_hook = format_hook = ->(result){ @format_results << result }
m = Module.new do
define_method(:format) do |tag, time, record|
result = super(tag, time, record)
format_hook.call(result)
result
end
end
@instance.singleton_class.prepend m
end
end
|
#run(flush: true, **kwargs, &block) ⇒ Object
37
38
39
40
|
# File 'lib/fluent/test/driver/output.rb', line 37
def run(flush: true, **kwargs, &block)
@flush_buffer_at_cleanup = flush
super(**kwargs, &block)
end
|
#run_actual(**kwargs, &block) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/fluent/test/driver/output.rb', line 42
def run_actual(**kwargs, &block)
super(**kwargs, &block)
if @flush_buffer_at_cleanup
@instance.force_flush
end
end
|