Sha256: 42de6b4ef9f427ec45c1d96cbd696c8b3cec646f55cea3f088da9c222b79a996

Contents?: true

Size: 811 Bytes

Versions: 20

Compression:

Stored size: 811 Bytes

Contents

module Invoker
  # This class defines sockets which are open for watching log files
  class CLI::TailWatcher
    attr_accessor :tail_watchers

    def initialize
      @tail_mutex = Mutex.new
      @tail_watchers = Hash.new { |h, k| h[k] = [] }
    end

    def [](process_name)
      @tail_mutex.synchronize { tail_watchers[process_name] }
    end

    def add(names, socket)
      @tail_mutex.synchronize do
        names.each { |name| tail_watchers[name] << socket }
      end
    end

    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

    def purge(name, socket)
      tail_watchers.delete(name)
      Invoker.close_socket(socket)
    end
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
itrg-invoker-1.6.1 lib/invoker/cli/tail_watcher.rb
itrg-invoker-1.6.0 lib/invoker/cli/tail_watcher.rb
invoker-1.5.8 lib/invoker/cli/tail_watcher.rb
invoker-1.5.7 lib/invoker/cli/tail_watcher.rb
invoker-1.5.6 lib/invoker/cli/tail_watcher.rb
invoker-1.5.5 lib/invoker/cli/tail_watcher.rb
invoker-1.5.4 lib/invoker/cli/tail_watcher.rb
invoker-1.5.3 lib/invoker/cli/tail_watcher.rb
meepo-1.5.2 lib/invoker/cli/tail_watcher.rb
invoker-1.5.1 lib/invoker/cli/tail_watcher.rb
invoker-1.4.1 lib/invoker/cli/tail_watcher.rb
invoker-1.4.0 lib/invoker/cli/tail_watcher.rb
invoker-1.3.2 lib/invoker/cli/tail_watcher.rb
invoker-1.3.1 lib/invoker/cli/tail_watcher.rb
invoker-1.3.0 lib/invoker/cli/tail_watcher.rb
invoker-1.2.0 lib/invoker/cli/tail_watcher.rb
invoker-1.2.0.pre2 lib/invoker/cli/tail_watcher.rb
invoker-1.2.0.pre1 lib/invoker/cli/tail_watcher.rb
invoker-1.2.0.pre lib/invoker/cli/tail_watcher.rb
invoker-1.1.0 lib/invoker/cli/tail_watcher.rb