class Invoker::CLI::TailWatcher

This class defines sockets which are open for watching log files

Attributes

tail_watchers[RW]

Public Class Methods

new() click to toggle source
# File lib/invoker/cli/tail_watcher.rb, line 6
def initialize
  @tail_mutex = Mutex.new
  @tail_watchers = Hash.new { |h, k| h[k] = [] }
end

Public Instance Methods

[](process_name) click to toggle source
# File lib/invoker/cli/tail_watcher.rb, line 11
def [](process_name)
  @tail_mutex.synchronize { tail_watchers[process_name] }
end
add(names, socket) click to toggle source
# File lib/invoker/cli/tail_watcher.rb, line 15
def add(names, socket)
  @tail_mutex.synchronize do
    names.each { |name| tail_watchers[name] << socket }
  end
end
purge(name, socket) click to toggle source
# File lib/invoker/cli/tail_watcher.rb, line 29
def purge(name, socket)
  tail_watchers.delete(name)
  Invoker.close_socket(socket)
end
remove(name, socket) click to toggle source
# File lib/invoker/cli/tail_watcher.rb, line 21
def remove(name, socket)
  @tail_mutex.synchronize do
    client_list = tail_watchers[name]
    client_list.delete(socket)
    purge(name, socket) if client_list.empty?
  end
end