Class: Riak::Client::Node
- Includes:
- Util::Escape, Util::Translation
- Defined in:
- lib/riak/client/node.rb
Constant Summary collapse
- VALID_OPTIONS =
[:host, :http_port, :pb_port, :http_paths, :prefix, :mapred, :luwak, :solr, :port, :basic_auth, :ssl_options, :ssl]
- ERRORS_DECAY_RATE =
For a score which halves in 10 seconds, choose ln(1/2)/10
Math.log(0.5)/10
Instance Attribute Summary collapse
-
#basic_auth ⇒ Object
A “user:password” string.
-
#error_rate ⇒ Object
readonly
A Decaying rate of errors.
-
#host ⇒ Object
What IP address or hostname does this node listen on?.
-
#http_paths ⇒ Object
A hash of HTTP paths used on this node.
-
#http_port ⇒ Object
Which port does the HTTP interface listen on?.
-
#pb_port ⇒ Object
Which port does the protocol buffers interface listen on?.
-
#ssl_options ⇒ Object
Returns the value of attribute ssl_options.
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#http? ⇒ Boolean
Can this node be used for HTTP requests?.
-
#initialize(client, opts = {}) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
-
#protobuffs? ⇒ Boolean
Can this node be used for protocol buffers requests?.
-
#ssl=(value) ⇒ Object
Enables or disables SSL on this node to be utilized by the HTTP Backends.
-
#ssl_enabled? ⇒ Boolean
Checks if SSL is enabled for HTTP.
Methods included from Util::Escape
#escape, #maybe_escape, #maybe_unescape, #unescape
Methods included from Util::Translation
Constructor Details
#initialize(client, opts = {}) ⇒ Node
Returns a new instance of Node.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/riak/client/node.rb', line 30 def initialize(client, opts = {}) @client = client @ssl = opts[:ssl] @ssl_options = opts[:ssl_options] @host = opts[:host] || "127.0.0.1" @http_port = opts[:http_port] || opts[:port] || 8098 @pb_port = opts[:pb_port] || 8087 @http_paths = { :prefix => opts[:prefix] || "/riak/", :mapred => opts[:mapred] || "/mapred", :luwak => opts[:luwak] || "/luwak", :solr => opts[:solr] || "/solr" # Unused? }.merge(opts[:http_paths] || {}) self.basic_auth = opts[:basic_auth] @error_rate = Decaying.new end |
Instance Attribute Details
#basic_auth ⇒ Object
A “user:password” string.
25 26 27 |
# File 'lib/riak/client/node.rb', line 25 def basic_auth @basic_auth end |
#error_rate ⇒ Object (readonly)
A Decaying rate of errors.
28 29 30 |
# File 'lib/riak/client/node.rb', line 28 def error_rate @error_rate end |
#host ⇒ Object
What IP address or hostname does this node listen on?
17 18 19 |
# File 'lib/riak/client/node.rb', line 17 def host @host end |
#http_paths ⇒ Object
A hash of HTTP paths used on this node.
23 24 25 |
# File 'lib/riak/client/node.rb', line 23 def http_paths @http_paths end |
#http_port ⇒ Object
Which port does the HTTP interface listen on?
19 20 21 |
# File 'lib/riak/client/node.rb', line 19 def http_port @http_port end |
#pb_port ⇒ Object
Which port does the protocol buffers interface listen on?
21 22 23 |
# File 'lib/riak/client/node.rb', line 21 def pb_port @pb_port end |
#ssl_options ⇒ Object
Returns the value of attribute ssl_options.
26 27 28 |
# File 'lib/riak/client/node.rb', line 26 def @ssl_options end |
Instance Method Details
#==(o) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/riak/client/node.rb', line 48 def ==(o) o.kind_of? Node and @host == o.host and @http_port == o.http_port and @pb_port == o.pb_port end |
#http? ⇒ Boolean
Can this node be used for HTTP requests?
68 69 70 71 |
# File 'lib/riak/client/node.rb', line 68 def http? # TODO: Need to sort out capabilities true end |
#inspect ⇒ Object
98 99 100 |
# File 'lib/riak/client/node.rb', line 98 def inspect "#<Node #{@host}:#{@http_port}:#{@pb_port}>" end |
#protobuffs? ⇒ Boolean
Can this node be used for protocol buffers requests?
74 75 76 77 |
# File 'lib/riak/client/node.rb', line 74 def protobuffs? # TODO: Need to sort out capabilities true end |
#ssl=(value) ⇒ Object
Enables or disables SSL on this node to be utilized by the HTTP Backends
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/riak/client/node.rb', line 81 def ssl=(value) @ssl_options = {} if(!@ssl_options) if((!!value).class === value) # Got a boolean... @ssl_options = {} else value = Hash === value ? value : {} @ssl_options.merge!(value) end value ? ssl_enable : ssl_disable end |
#ssl_enabled? ⇒ Boolean
Checks if SSL is enabled for HTTP
94 95 96 |
# File 'lib/riak/client/node.rb', line 94 def ssl_enabled? @client.protocol == 'https' && @ssl_options.present? end |