Class: Fluent::Plugin::ProxysqlQueryLogInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_proxysql_query_log.rb,
lib/fluent/plugin/in_proxysql_query_log/watcher.rb

Defined Under Namespace

Classes: Watcher

Constant Summary collapse

DEFAULT_STORAGE_TYPE =
'local'

Instance Method Summary collapse

Constructor Details

#initializeProxysqlQueryLogInput

Returns a new instance of ProxysqlQueryLogInput.



46
47
48
49
50
# File 'lib/fluent/plugin/in_proxysql_query_log.rb', line 46

def initialize
  super
  @paths = []
  @watchers = {}
end

Instance Method Details

#configure(conf) ⇒ Object



52
53
54
55
56
# File 'lib/fluent/plugin/in_proxysql_query_log.rb', line 52

def configure(conf)
  super
  @pos_storage = storage_create(usage: 'positions', type: DEFAULT_STORAGE_TYPE, conf: conf)
  @paths = @path.split(',').map{|path|path.strip}
end

#refresh_watchersObject



65
66
67
68
69
# File 'lib/fluent/plugin/in_proxysql_query_log.rb', line 65

def refresh_watchers
  target_paths = expand_paths
  remove_detached_watcher
  start_watchers(target_paths)
end

#remove_detached_watcherObject



82
83
84
# File 'lib/fluent/plugin/in_proxysql_query_log.rb', line 82

def remove_detached_watcher
  @watchers = @watchers.select { |k, v| v.attached? }
end

#startObject



58
59
60
61
62
63
# File 'lib/fluent/plugin/in_proxysql_query_log.rb', line 58

def start
  super

  refresh_watchers
  timer_execute(:in_proxysql_query_log_refresh_watchers, @refresh_interval, &method(:refresh_watchers))
end

#start_watchers(paths) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/fluent/plugin/in_proxysql_query_log.rb', line 71

def start_watchers(paths)

  paths.each do |path|
    unless @watchers.has_key?(path)
      log.debug("start watch: #{path}")
      @watchers[path] = Watcher.new(path, 0, @pos_storage, router, @tag, log)
      event_loop_attach(@watchers[path])
    end
  end
end