Module: IProto

Defined in:
lib/iproto.rb,
lib/iproto/em.rb,
lib/iproto/tcp_socket.rb,
lib/iproto/connection_api.rb

Defined Under Namespace

Modules: ConnectionAPI Classes: ConnectionError, CouldNotConnect, Disconnected, EMCallbackConnection, EMConnection, EMFiberedConnection, IProtoError, TCPSocket, UnexpectedResponse

Constant Summary collapse

VERSION =
'0.3.13'

Class Method Summary collapse

Class Method Details

.get_connection(host, port, type = :block, reconnect = true) ⇒ Object

types: :em :block



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/iproto.rb', line 14

def self.get_connection(host, port, type = :block, reconnect = true)
  case type
  when :em
    require 'iproto/em'
    ::EM.connect host, port, IProto::EMFiberedConnection, host, port, reconnect
  when :em_callback
    require 'iproto/em'
    ::EM.connect host, port, IProto::EMCallbackConnection, host, port, reconnect
  when :block
    require 'iproto/tcp_socket'
    IProto::TCPSocket.new(host, port, reconnect)
  else
    raise "Undefined type #{type}"
  end    
end