Class: Fluent::Plugin::TailInput::WorkerCompatibility

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/in_tail/worker_pool.rb

Overview

Captures the built-in hook implementations once and checks whether a TailInput instance resolves each hook to the same method body. A mismatch means worker execution must fall back to the synchronous compatibility path; this deliberately does not try to infer safety from method owners.

Constant Summary collapse

HOOKS =
%i[
  receive_lines flush_buffer convert_line_to_event parse_singleline
  parse_multilines setup_watcher io_handler build_line_feeder
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(base_class) ⇒ WorkerCompatibility

Returns a new instance of WorkerCompatibility.



222
223
224
# File 'lib/fluent/plugin/in_tail/worker_pool.rb', line 222

def initialize(base_class)
  @hooks = HOOKS.to_h { |name| [name, base_class.instance_method(name)] }.freeze
end

Instance Method Details

#compatible?(plugin) ⇒ Boolean

Returns:

  • (Boolean)


226
227
228
# File 'lib/fluent/plugin/in_tail/worker_pool.rb', line 226

def compatible?(plugin)
  incompatible_hooks(plugin).empty?
end

#incompatible_hooks(plugin) ⇒ Object



230
231
232
233
234
235
236
# File 'lib/fluent/plugin/in_tail/worker_pool.rb', line 230

def incompatible_hooks(plugin)
  @hooks.filter_map do |name, built_in|
    name unless plugin.singleton_class.instance_method(name) == built_in
  rescue NameError
    name
  end
end