Class: CassandraThrift::Cassandra::SafeClient

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra/safe_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, transport, reset = false) ⇒ SafeClient

Returns a new instance of SafeClient.



6
7
8
9
10
# File 'lib/cassandra/safe_client.rb', line 6

def initialize(client, transport, reset = false)
  @client = client 
  @transport = transport
  @reset = reset
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/cassandra/safe_client.rb', line 17

def method_missing(*args)
  reset_transport if @reset
  @client.send(*args)
rescue IOError, UnavailableException, Thrift::ProtocolException, Thrift::ApplicationException, Thrift::TransportException
  reset_transport
  @client.send(*args)
end

Instance Method Details

#reset_transportObject



12
13
14
15
# File 'lib/cassandra/safe_client.rb', line 12

def reset_transport
  @transport.close rescue nil
  @transport.open
end