Sha256: 48648335a575dcc5ac5472969a1dd99d1260092c52a21fb9a0b869f3ec50e16f

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

module Riak
  class Client
    class Node
      # Represents a single riak node in a cluster.

      include Util::Translation
      include Util::Escape

      VALID_OPTIONS = [:host, :pb_port]

      # For a score which halves in 10 seconds, choose
      # ln(1/2)/10
      ERRORS_DECAY_RATE = Math.log(0.5)/10

      # What IP address or hostname does this node listen on?
      attr_accessor :host

      # Which port does the protocol buffers interface listen on?
      attr_accessor :pb_port

      # A Decaying rate of errors.
      attr_reader :error_rate

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

        @error_rate = Decaying.new
      end

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

      # Can this node be used for protocol buffers requests?
      def protobuffs?
        # TODO: Need to sort out capabilities
        true
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
riak-client-2.4.1 lib/riak/client/node.rb
riak-client-2.4.0 lib/riak/client/node.rb
riak-client-2.4.0.pre1 lib/riak/client/node.rb
riak-client-2.3.2 lib/riak/client/node.rb
riak-client-2.3.1 lib/riak/client/node.rb