Class: Riak::Client::ExconBackend

Inherits:
HTTPBackend show all
Defined in:
lib/riak/client/excon_backend.rb

Overview

An HTTP backend for Riak::Client that uses Wesley Beary's Excon HTTP library. Conforms to the Riak::Client::HTTPBackend interface.

Instance Attribute Summary

Attributes inherited from HTTPBackend

#client, #node

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from HTTPBackend

#delete_file, #delete_object, #fetch_object, #file_exists?, #get_bucket_props, #get_file, #get_index, #initialize, #link_walk, #list_buckets, #list_keys, #mapred, #ping, #reload_object, #search, #set_bucket_props, #stats, #store_file, #store_object, #update_search_index

Methods included from HTTPBackend::Configuration

#bucket_list_path, #bucket_properties_path, #index_eq_path, #index_range_path, #key_list_path, #link_walk_path, #luwak_path, #mapred_path, #object_path, #ping_path, #solr_select_path, #solr_update_path, #stats_path

Methods included from HTTPBackend::ObjectMethods

#load_object, #reload_headers, #store_headers

Methods included from HTTPBackend::TransportMethods

#basic_auth_header, #client_id, #default_headers, #delete, #get, #head, #path, #post, #put, #return_body?, #root_uri, #valid_response?, #verify_body!

Methods included from Util::Translation

#i18n_scope, #t

Methods included from Util::Escape

#escape, #maybe_escape, #maybe_unescape, #unescape

Constructor Details

This class inherits a constructor from Riak::Client::HTTPBackend

Class Method Details

+ (Boolean) configured?

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
# File 'lib/riak/client/excon_backend.rb', line 11

def self.configured?
  begin
    require 'excon'
    Client::NETWORK_ERRORS << Excon::Errors::SocketError
    Client::NETWORK_ERRORS.uniq!
    Excon::VERSION >= "0.5.7" && patch_excon
  rescue LoadError
    false
  end
end

+ (Object) patch_excon

Note:

This can be changed when Excon has a proper pool of its own.

Adjusts Excon's connection collection to allow multiple connections to the same host from the same Thread. Instead we use the Riak::Client::Pool to segregate connections.



26
27
28
29
30
31
32
33
34
35
# File 'lib/riak/client/excon_backend.rb', line 26

def self.patch_excon
  unless defined? @@patched
    ::Excon::Connection.class_eval do
      def sockets
        @sockets ||= {}
      end
    end
  end
  @@patched = true
end

Instance Method Details

- (Object) teardown



37
38
39
# File 'lib/riak/client/excon_backend.rb', line 37

def teardown
  connection.reset
end