rinzler

0.0.2 • Public • Published

Rinzler

Rinzler is a Cassandra connection pooling agent that supports node rediscovery and health checks. Rinzler uses the node-cassandra-cql driver.

$ npm i rinzler

API

rinzler(seedNode, options)

Constructs a Cassandra discovery pool.

  • seedNode (String): Specifies a {host}:{port}-formatted discovery seed node, where {host} may be a host name, IPv4 address, or IPv6 address. IPv6 addresses must be enclosed in square brackets if a port number is specified (e.g., [::1]:9042). If a port is not specified, it will default to 9042.

options is an object that may contain the following fields:

  • pingInterval (Number >= 0): The health check interval, expressed in milliseconds. Defaults to 5 seconds.
  • discoveryInterval (Number >= 0): The ring rediscovery interval, expressed in milliseconds. Defaults to 30 seconds.
  • maxRetries (Number >= 0): The maximum number of times to retry failed health checks. Defaults to 5 attempts.
  • retryDelay (Number >= 0): The scaling delay for exponential backoff when retrying failed health checks, expressed in milliseconds. Defaults to 20 ms.
  • maxDelay (Number >= 0): The maximum delay between retried health checks, expressed in milliseconds. Defaults to 2.5 seconds.
  • lookupSeed (Boolean): Specifies whether a second query should be executed against one of the seed node's peers to discover the IP address of the seed node. This is useful if the seed node is a load balancing proxy.
var rinzler = require('rinzler');
 
var discoveryPool = rinzler('cassandra.discovery.example.net:9042', {
    pingInterval: 5000,
    discoveryInterval: 30000,
    maxRetries: 5,
    retryDelay: 20,
    maxDelay: 2500,
    lookupSeed: true
});

discoveryPool.connect(callback)

Opens a connection to the seed node, retrieves a list of nodes in the associated Cassandra ring, and constructs a node-cassandra-cql Client instance with the resulting nodes. Yields (error, client) to the callback. Emits connect and connectError events. If a connectError listener is not attached, an error event will be emitted instead. Multiple successive calls to #connect() will be debounced. If the pool is already connected, the callback will be called on the next tick.

discoveryPool.ping(callback)

Pings a node in the Cassandra connection pool to verify that the pool can respond to queries. The ping will be retried using exponential backoff if necessary. Yields (error, keyspaceNames) to the callback. Emits ping and pingError events, and error events if no pingError listeners are attached.

discoveryPool.rediscover(callback)

Rediscovers all nodes in the Cassandra ring. Stale connections will be removed from the pool and closed; new connections will be opened before being added to the pool. All prepared queries executed on any stale connections will be cleaned up. Yields (error) to the callback. Emits discover and discoverError events, following the same policy for the error event as #connect() and #ping().

discoveryPool.close()

Closes the Cassandra connection pool and cleans up any associated timers and listeners. Emits a close event.

discoveryPool.health(callback)

Retrieves the health status for each node in the connection pool. Yields (error, healthInfo) to the callback, where healthInfo is a tuple in the form of { healthy: [String...], unhealthy: String[...] }.

License

MIT.

Package Sidebar

Install

npm i rinzler

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • kitcambridge