RiakNode Class
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
ObjectThe options for this RiakNode.
-
[remoteAddress=127.0.0.1]
String optionalThe address for this node. Can also be a FQDN.
-
[remotePort=8087]
Number optionalThe port to connect to.
-
[minConnections=1]
Number optionalSet the minimum number of active connections to maintain.
-
[maxConnections=128]
Number optionalSet the maximum number of connections allowed.
-
[idleTimeout=10000]
Number optionalSet the idle timeout used to reap inactive connections.
-
[connectionTimeout=3000]
Number optionalSet the connection timeout used when making new connections.
-
[requestTimeout=5000]
Number optionalSet the timeout used when executing commands.
-
[auth]
Object optionalSet the authentication information for connections made by this node.
-
user
StringRiak username. -
[password]
String optionalRiak password. Not required if using user cert. -
[pfx]
String | Buffer optionalA string or buffer holding the PFX or PKCS12 encoded private key, certificate and CA certificates. -
[key]
String | Buffer optionalA string holding the PEM encoded private key. -
[passphrase]
String optionalA string of passphrase for the private key or pfx. -
[cert]
String | Buffer optionalA string holding the PEM encoded certificate. -
[ca]
String | String | Buffer optionalEither a string or list of strings of PEM encoded CA certificates to trust. -
[crl]
String | String | Buffer optionalEither a string or list of strings of PEM encoded CRLs (Certificate Revocation List). -
[rejectUnauthorized]
Boolean optionalA boolean indicating whether a server should automatically reject clients with invalid certificates. Only applies to servers with requestCert enabled.
-
-
[cork]
Boolean optionalUse 'cork' on all sockets. Default is true.
-
[externalLoadBalancer]
Boolean optionalThis RiakNode object connects to a load balancer. Default is false.
-
Methods
execute
-
command
Execute a command on this RiakNode.
Parameters:
-
command
Object- a command to execute.
Returns:
- 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- the RiakNode.State