Class: Thrift::EventMachineTransport

### Home Classes Methods

### In Files

- lib/thrift_client/event_machine.rb

### Parent

BaseTransport

### Methods

- ::new
- #close
- #open
- #open?
- #read
- #write

### Files

- CHANGELOG
- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- ThriftClient
- ThriftClient::NoServersAvailable
- ThriftClient::Simple
- ThriftClient::Simple::ComplexType
- ThriftClient::Simple::ComplexType::Extends
- ThriftClient::Simple::ComplexType::Includes
- ThriftClient::Simple::Field
- ThriftClient::Simple::ThriftException
- ThriftClient::Simple::ThriftService
- ThriftClient::Simple::ThriftStruct
- ThriftClient::Simple::ThriftStruct::Extend
- ThriftClient::Simple::ThriftStruct::Include
- Thrift
- Thrift::BaseTransport
- Thrift::BufferedTransport
- Thrift::Client
- Thrift::EventMachineConnection
- Thrift::EventMachineTransport
- Thrift::FramedTransport
- Connection
- Connection::Base
- Connection::Factory
- Connection::HTTP
- Connection::Socket
- AbstractThriftClient
- AbstractThriftClient::Server

No matching classes.

# Thrift::EventMachineTransport

### Public Class Methods

new(host, port=9090, timeout=5) click to toggle source

    # File lib/thrift_client/event_machine.rb, line 10
    def initialize(host, port=9090, timeout=5)
      @host, @port, @timeout = host, port, timeout
      @connection = nil
    end

### Public Instance Methods

close() click to toggle source

    # File lib/thrift_client/event_machine.rb, line 34
    def close
      @connection.close
    end

open() click to toggle source

    # File lib/thrift_client/event_machine.rb, line 19
    def open
      fiber = Fiber.current
      @connection = EventMachineConnection.connect(@host, @port, @timeout)
      @connection.callback do
        fiber.resume
      end
      @connection.errback do
        fiber.resume
      end
      Fiber.yield

      raise Thrift::TransportException, "Unable to connect to #{@host}:#{@port}" unless @connection.connected?
      @connection
    end

open?() click to toggle source

    # File lib/thrift_client/event_machine.rb, line 15
    def open?
      @connection && @connection.connected?
    end

read(sz) click to toggle source

    # File lib/thrift_client/event_machine.rb, line 38
    def read(sz)
      @connection.blocking_read(sz)
    end

write(buf) click to toggle source

    # File lib/thrift_client/event_machine.rb, line 42
    def write(buf)
      @connection.send_data(buf)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.