API Docs for: 2.2.2
Show:

RiakNode Class

Module: Core

Provides the RiakNode class and its Builder.

Instances of this class maintain connections to and execute commands on a Riak node in a Riak cluster.

options is an object with the following defaults:

{
  remoteAdddress: '127.0.0.1',
  remotePort: 8087,
  maxConnections: 128,
  minConnections: 1,
  idleTimeout: 10000,
  connectionTimeout: 3000,
  requestTimeout: 5000,
  cork: true
}

As a convenience a builder class is provided;

var newNode = new RiakNode.Builder().withMinConnections(10).build();

See RiakNode.Builder

Constructor

RiakNode

(
  • options
)

Parameters:

  • options Object

    The options for this RiakNode.

    • [remoteAddress=127.0.0.1] String optional

      The address for this node. Can also be a FQDN.

    • [remotePort=8087] Number optional

      The port to connect to.

    • [minConnections=1] Number optional

      Set the minimum number of active connections to maintain.

    • [maxConnections=128] Number optional

      Set the maximum number of connections allowed.

    • [idleTimeout=10000] Number optional

      Set the idle timeout used to reap inactive connections.

    • [connectionTimeout=3000] Number optional

      Set the connection timeout used when making new connections.

    • [requestTimeout=5000] Number optional

      Set the timeout used when executing commands.

    • [auth] Object optional

      Set the authentication information for connections made by this node.

      • user String
        Riak username.
      • [password] String optional
        Riak password. Not required if using user cert.
      • [pfx] String | Buffer optional
        A string or buffer holding the PFX or PKCS12 encoded private key, certificate and CA certificates.
      • [key] String | Buffer optional
        A string holding the PEM encoded private key.
      • [passphrase] String optional
        A string of passphrase for the private key or pfx.
      • [cert] String | Buffer optional
        A string holding the PEM encoded certificate.
      • [ca] String | String | Buffer optional
        Either a string or list of strings of PEM encoded CA certificates to trust.
      • [crl] String | String | Buffer optional
        Either a string or list of strings of PEM encoded CRLs (Certificate Revocation List).
      • [rejectUnauthorized] Boolean optional
        A boolean indicating whether a server should automatically reject clients with invalid certificates. Only applies to servers with requestCert enabled.
    • [cork] Boolean optional

      Use 'cork' on all sockets. Default is true.

    • [externalLoadBalancer] Boolean optional

      This RiakNode object connects to a load balancer. Default is false.

Item Index

Methods

Properties

Methods

execute

(
  • command
)
Boolean

Execute a command on this RiakNode.

Parameters:

  • command Object
    • a command to execute.

Returns:

Boolean:
  • if this RiakNode accepted the command for execution.

start

(
  • callback
)

Start this RiakNode.

Parameters:

  • callback Function
    • a callback for when node is started.

stop

(
  • callback
)

Stop this RiakNode.

Parameters:

  • callback Function
    • called when node completely stopped.

Properties

State

Object final static

The state of this node.

If listeneing for stateChange events, a numeric value will be sent that can be compared to:

RiakNode.State.CREATED
RiakNode.State.RUNNING
RiakNode.State.HEALTH_CHECKING
RiakNode.State.SHUTTING_DOWN
RiakNode.State.SHUTDOWN

See: stateChange

Events

retryCommand

This event is fired whenever a command fails and needs to be retried.

Event Payload:

  • command Object
    • the command to retry
  • node RiakNode
    • this RiakNode

stateChange

This event is fired whenever the state of the RiakNode changes.

Event Payload:

  • node Object
    • the RiakNode object whose state changed
  • state Number