Method: Fluent::Counter::Server#initialize

Defined in:
lib/fluent/counter/server.rb

#initialize(name, opt = {}) ⇒ Server

Returns a new instance of Server.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fluent/counter/server.rb', line 29

def initialize(name, opt = {})
  raise 'Counter server name is invalid' unless Validator::VALID_NAME.match?(name)
  @name = name
  @opt = opt
  @addr = @opt[:addr] || DEFAULT_ADDR
  @port = @opt[:port] || DEFAULT_PORT
  @loop = @opt[:loop] || Coolio::Loop.new
  @log =  @opt[:log] || $log

  @store = Fluent::Counter::Store.new(opt)
  @mutex_hash = MutexHash.new(@store)

  @server = Coolio::TCPServer.new(@addr, @port, Handler, method(:on_message))
  @thread = nil
  @running = false
end