Class: Riak::Client::Node

Inherits:
Object show all
Includes:
Util::Escape, Util::Translation
Defined in:
lib/riak/client/node.rb

Constant Summary collapse

VALID_OPTIONS =
[:host, :pb_port]
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

Instance Method Summary collapse

Methods included from Util::Escape

#escape, #maybe_escape, #maybe_unescape, #unescape

Methods included from Util::Translation

#i18n_scope, #t

Constructor Details

#initialize(client, opts = {}) ⇒ Node

Returns a new instance of Node.



24
25
26
27
28
29
30
# File 'lib/riak/client/node.rb', line 24

def initialize(client, opts = {})
  @client = client
  @host = opts[:host] || "127.0.0.1"
  @pb_port = opts[:pb_port] || 8087

  @error_rate = Decaying.new
end

Instance Attribute Details

#error_rateObject (readonly)

A Decaying rate of errors.



22
23
24
# File 'lib/riak/client/node.rb', line 22

def error_rate
  @error_rate
end

#hostObject

What IP address or hostname does this node listen on?



16
17
18
# File 'lib/riak/client/node.rb', line 16

def host
  @host
end

#pb_portObject

Which port does the protocol buffers interface listen on?



19
20
21
# File 'lib/riak/client/node.rb', line 19

def pb_port
  @pb_port
end

Instance Method Details

#==(o) ⇒ Object



32
33
34
35
36
# File 'lib/riak/client/node.rb', line 32

def ==(o)
  o.kind_of? Node and
    @host == o.host and
    @pb_port == o.pb_port
end

#inspectObject



44
45
46
# File 'lib/riak/client/node.rb', line 44

def inspect
  "#<Node #{@host}:#{@pb_port}>"
end

#protobuffs?Boolean

Can this node be used for protocol buffers requests?

Returns:

  • (Boolean)


39
40
41
42
# File 'lib/riak/client/node.rb', line 39

def protobuffs?
  # TODO: Need to sort out capabilities
  true
end