module Fluent::PluginHelper::ServiceDiscovery
Attributes
For the compatibility with older versions without ‘param_name: :service_discovery_configs`
Public Class Methods
# File lib/fluent/plugin_helper/service_discovery.rb, line 28 def self.included(mod) mod.include ServiceDiscoveryParams end
Public Instance Methods
# File lib/fluent/plugin_helper/service_discovery.rb, line 32 def configure(conf) super # For the compatibility with older versions without `param_name: :service_discovery_configs` @service_discovery = @service_discovery_configs end
Fluent::PluginHelper::Timer#start
# File lib/fluent/plugin_helper/service_discovery.rb, line 38 def start unless @discovery_manager log.warn('There is no discovery_manager. skip start them') super return end @discovery_manager.start unless @discovery_manager.static_config? timer_execute(@_plugin_helper_service_discovery_title, @_plugin_helper_service_discovery_interval) do @discovery_manager.run_once end end super end
Private Instance Methods
# File lib/fluent/plugin_helper/service_discovery.rb, line 112 def discovery_manager @discovery_manager end
@param title [Symbol] the thread name. this value should be unique. @param static_default_service_directive [String] the directive name of each service when “static” service discovery is enabled in default @param load_balancer [Object] object which has two methods rebalance and select_service @param custom_build_method [Proc]
# File lib/fluent/plugin_helper/service_discovery.rb, line 68 def service_discovery_configure(title, static_default_service_directive: nil, load_balancer: nil, custom_build_method: nil, interval: 3) configs = @service_discovery_configs.map(&:corresponding_config_element) if static_default_service_directive configs.prepend Fluent::Config::Element.new( 'service_discovery', '', {'@type' => 'static'}, @config.elements(name: static_default_service_directive.to_s).map{|e| Fluent::Config::Element.new('service', e.arg, e.dup, e.elements, e.unused) } ) end service_discovery_create_manager(title, configurations: configs, load_balancer: load_balancer, custom_build_method: custom_build_method, interval: interval) end
@param title [Symbol] the thread name. this value should be unique. @param configurations [Hash] hash which must has discivery_service type and its configuration like ‘{ type: :static, conf: <Fluent::Config::Element> }` @param load_balancer [Object] object which has two methods rebalance and select_service @param custom_build_method [Proc]
# File lib/fluent/plugin_helper/service_discovery.rb, line 97 def service_discovery_create_manager(title, configurations:, load_balancer: nil, custom_build_method: nil, interval: 3) @_plugin_helper_service_discovery_title = title @_plugin_helper_service_discovery_interval = interval @discovery_manager = Fluent::PluginHelper::ServiceDiscovery::Manager.new( log: log, load_balancer: load_balancer, custom_build_method: custom_build_method, ) @discovery_manager.configure(configurations, parent: self) @discovery_manager end
# File lib/fluent/plugin_helper/service_discovery.rb, line 89 def service_discovery_rebalance @discovery_manager.rebalance end
# File lib/fluent/plugin_helper/service_discovery.rb, line 81 def service_discovery_select_service(&block) @discovery_manager.select_service(&block) end
# File lib/fluent/plugin_helper/service_discovery.rb, line 85 def service_discovery_services @discovery_manager.services end