Class: Fluent::Plugin::SrvServiceDiscovery

Inherits:
ServiceDiscovery show all
Includes:
Fluent::PluginHelper::Mixin
Defined in:
lib/fluent/plugin/sd_srv.rb

Constant Summary

Constants inherited from ServiceDiscovery

Fluent::Plugin::ServiceDiscovery::SERVICE_IN, Fluent::Plugin::ServiceDiscovery::SERVICE_OUT

Constants included from Configurable

Configurable::CONFIG_TYPE_REGISTRY

Instance Attribute Summary

Attributes inherited from ServiceDiscovery

#services

Attributes included from Fluent::PluginLoggerMixin

#log

Attributes inherited from Base

#under_plugin_development

Instance Method Summary collapse

Methods included from Fluent::PluginHelper::Mixin

included

Methods inherited from ServiceDiscovery

service_in_msg, service_out_msg

Methods included from UniqueId::Mixin

#dump_unique_id_hex, #generate_unique_id

Methods included from Fluent::PluginLoggerMixin

included, #terminate

Methods included from Fluent::PluginId

#plugin_id, #plugin_id_configured?, #plugin_id_for_test?, #plugin_root_dir, #stop

Methods inherited from Base

#acquire_worker_lock, #after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #called_in_test?, #close, #closed?, #configured?, #context_router, #context_router=, #fluentd_worker_id, #get_lock_path, #has_router?, #inspect, #multi_workers_ready?, #plugin_root_dir, #reloadable_plugin?, #shutdown, #shutdown?, #started?, #stop, #stopped?, #string_safe_encoding, #terminate, #terminated?

Methods included from SystemConfig::Mixin

#system_config, #system_config_override

Methods included from Configurable

#config, #configure_proxy_generate, #configured_section_create, included, lookup_type, register_type

Constructor Details

#initializeSrvServiceDiscovery

Returns a new instance of SrvServiceDiscovery.



50
51
52
53
# File 'lib/fluent/plugin/sd_srv.rb', line 50

def initialize
  super
  @target = nil
end

Instance Method Details

#configure(conf) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fluent/plugin/sd_srv.rb', line 55

def configure(conf)
  super

  @target = "_#{@service}._#{@proto}.#{@hostname}"
  @dns_resolve =
    if @dns_server_host.nil?
      Resolv::DNS.new
    elsif @dns_server_host.include?(':') # e.g. 127.0.0.1:8600
      host, port = @dns_server_host.split(':', 2)
      Resolv::DNS.new(nameserver_port: [[host, port.to_i]])
    else
      Resolv::DNS.new(nameserver: @dns_server_host)
    end

  @services = fetch_srv_record
end

#start(queue) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/fluent/plugin/sd_srv.rb', line 72

def start(queue)
  timer_execute(:"sd_srv_record_#{@target}", @interval) do
    refresh_srv_records(queue)
  end

  super()
end