Sha256: bb4bc7db0c1cede319a8fea41bb7671d07ae6224e50e702e982bed156d1848bd

Contents?: true

Size: 568 Bytes

Versions: 3

Compression:

Stored size: 568 Bytes

Contents

module ScribeThrift #:nodoc: all
  class SafeClient  
    def initialize(client, transport, reset = false)
      @client = client 
      @transport = transport
      @reset = reset
    end
    
    def reset_transport
      @transport.close rescue nil
      @transport.open
    end
    
    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scribe-0.1.2 lib/scribe/safe_client.rb
scribe-0.1.1 lib/scribe/safe_client.rb
scribe-0.1 lib/scribe/safe_client.rb