Class: Fluent::Plugin::FileServiceDiscovery
- Inherits:
-
ServiceDiscovery
- Object
- Base
- ServiceDiscovery
- Fluent::Plugin::FileServiceDiscovery
- Includes:
- Fluent::PluginHelper::Mixin
- Defined in:
- lib/fluent/plugin/sd_file.rb
Defined Under Namespace
Classes: StatWatcher
Constant Summary collapse
- DEFAULT_FILE_TYPE =
:yaml
- DEFAUT_WEIGHT =
60
- DEFAULT_SD_FILE_PATH =
ENV['DEFAULT_SD_FILE_PATH'] || '/etc/fluent/sd.yaml'
Constants inherited from ServiceDiscovery
ServiceDiscovery::SERVICE_IN, ServiceDiscovery::SERVICE_OUT
Constants included from Configurable
Configurable::CONFIG_TYPE_REGISTRY
Instance Attribute Summary
Attributes inherited from ServiceDiscovery
Attributes included from Fluent::PluginLoggerMixin
Attributes inherited from Base
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ FileServiceDiscovery
constructor
A new instance of FileServiceDiscovery.
- #start(queue) ⇒ Object
Methods included from Fluent::PluginHelper::Mixin
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
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
#initialize ⇒ FileServiceDiscovery
Returns a new instance of FileServiceDiscovery.
38 39 40 41 42 |
# File 'lib/fluent/plugin/sd_file.rb', line 38 def initialize super @file_type = nil end |
Instance Method Details
#configure(conf) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fluent/plugin/sd_file.rb', line 44 def configure(conf) super unless File.exist?(@path) raise Fluent::ConfigError, "sd_file: path=#{@path} not found" end @file_type = File.basename(@path).split('.', 2).last.to_sym unless %i[yaml yml json].include?(@file_type) @file_type = DEFAULT_FILE_TYPE end @services = fetch_server_info end |
#start(queue) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/fluent/plugin/sd_file.rb', line 59 def start(queue) watcher = StatWatcher.new(@path, @log) do |_prev, _cur| refresh_file(queue) end event_loop_attach(watcher) super() end |