Class: Carbon::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/carbon/reader.rb

Defined Under Namespace

Modules: ServerProtocol Classes: FetchQueue

Instance Method Summary collapse

Constructor Details

#initialize(hostname, port, logger) ⇒ Reader

Returns a new instance of Reader.



5
6
7
8
9
# File 'lib/carbon/reader.rb', line 5

def initialize(hostname, port, logger)
  @queue = FetchQueue.new
  @logger = logger
  @connection = EM::connect(hostname, port, ServerProtocol, @queue, @logger)
end

Instance Method Details

#closeObject



11
12
13
# File 'lib/carbon/reader.rb', line 11

def close
  @connection.close_connection
end

#fetch(query, &callback) ⇒ Object



15
16
17
# File 'lib/carbon/reader.rb', line 15

def fetch(query, &callback)
  @queue.push([query, callback])
end