Class: Jp::AbstractClient

Inherits:
Object
  • Object
show all
Defined in:
lib/rb/jp/client.rb

Direct Known Subclasses

AbstractConsumer, AbstractProducer

Instance Method Summary collapse

Constructor Details

#initialize(queue, options = {}) ⇒ AbstractClient

Returns a new instance of AbstractClient.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rb/jp/client.rb', line 5

def initialize queue, options = {}
  options[:host] ||= 'localhost'
  options[:port] ||= 9090
  options[:poll_interval] ||= 1
  @queue = queue
  @options = options

  if options[:client]
    @client = options[:client]
  else
    socket = Thrift::Socket.new options[:host], options[:port]
    transport = Thrift::BufferedTransport.new socket
    protocol = Thrift::BinaryProtocol.new transport
    @client = JobPool::Client.new protocol
    transport.open
  end
end