Class: Riak::Client::Node

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

Constant Summary

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

- (Node) initialize(client, opts = {})

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

- (Object) error_rate (readonly)

A Decaying rate of errors.



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

def error_rate
  @error_rate
end

- (Object) host

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

- (Object) pb_port

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

- (Object) ==(o)



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

- (Object) inspect



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

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

- (Boolean) protobuffs?

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