Sha256: 7ed182714417c580bd32552122821a7022d5b5c18eec330fb7e04dbf0eb0df41

Contents?: true

Size: 741 Bytes

Versions: 1

Compression:

Stored size: 741 Bytes

Contents

module Floom
  class Client

    attr_reader :connection

    def initialize(options = {})
      @host = options[:host]
      @port = options[:port]
      establish_connection!
    end
    
    def to_s
      "#<#{self.class}:#{object_id} host:#{@host} port:#{@port}>"
    end

    def reset_connection!
      @socket = @transport = @protocol = @connection = nil
      establish_connection!
    end

  private
    
    def establish_connection!
      @socket     ||= Thrift::Socket.new(@host, @port)
      @transport  ||= Thrift::BufferedTransport.new(@socket)
      @protocol   ||= Thrift::BinaryProtocol.new(@transport)      
      @connection ||= self.class.thrift_class.new(@protocol)
      @transport.open
      self
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
floom-0.0.1 lib/floom/client.rb