Class: Fluent::Helper::PluginSpec::Driver
- Inherits:
-
Object
- Object
- Fluent::Helper::PluginSpec::Driver
- Defined in:
- lib/fluent/helper/plugin_spec.rb
Defined Under Namespace
Classes: BatchPitcher
Instance Attribute Summary collapse
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
Instance Method Summary collapse
- #events ⇒ Object
-
#initialize(plugin_klass, conf) ⇒ Driver
constructor
A new instance of Driver.
- #pitch(tag, time, record) ⇒ Object
- #pitches(tag, es) ⇒ Object
- #run {|_self| ... } ⇒ Object
- #with(tag, time = Time.now.to_i) {|BatchPitcher.new(self, tag, time)| ... } ⇒ Object
Constructor Details
#initialize(plugin_klass, conf) ⇒ Driver
Returns a new instance of Driver.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fluent/helper/plugin_spec.rb', line 48 def initialize(plugin_klass, conf) @plugin_klass = plugin_klass Fluent::Helper::PluginEmitStub.register_target(plugin_klass) plugin = plugin_klass.new unless plugin.is_a?(Fluent::Input) || plugin.is_a?(Fluent::Output) raise ArgumentError, "unknown class as plugin #{plugin.class}" end logger = TestLogger.new conf = Fluent::Config.parse(conf, '[test config]') plugin.configure(conf) plugin_loglevel = plugin.instance_variable_get(:@log_level) if plugin_loglevel logger.log_level = plugin_loglevel end plugin.log = logger @instance = plugin end |
Instance Attribute Details
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
46 47 48 |
# File 'lib/fluent/helper/plugin_spec.rb', line 46 def instance @instance end |
Instance Method Details
#events ⇒ Object
106 107 108 |
# File 'lib/fluent/helper/plugin_spec.rb', line 106 def events Fluent::Helper::PluginEmitStub.stored(@plugin_klass) end |
#pitch(tag, time, record) ⇒ Object
71 72 73 |
# File 'lib/fluent/helper/plugin_spec.rb', line 71 def pitch(tag, time, record) @instance.emit(tag, time, record) end |
#pitches(tag, es) ⇒ Object
75 76 77 |
# File 'lib/fluent/helper/plugin_spec.rb', line 75 def pitches(tag, es) @instance.emits(tag, es) end |
#run {|_self| ... } ⇒ Object
99 100 101 102 103 104 |
# File 'lib/fluent/helper/plugin_spec.rb', line 99 def run raise ArgumentError unless block_given? @instance.start yield self @instance.shutdown end |
#with(tag, time = Time.now.to_i) {|BatchPitcher.new(self, tag, time)| ... } ⇒ Object
94 95 96 97 |
# File 'lib/fluent/helper/plugin_spec.rb', line 94 def with(tag, time=Time.now.to_i) raise ArgumentError unless block_given? yield BatchPitcher.new(self, tag, time) end |