aerospike
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -0,1 +1,11 @@ | ||
v3.1.1 / 2018-01-09 | ||
=================== | ||
* **Bug Fixes** | ||
* Support all data types for write operation in Client#operate [#235](https://github.com/aerospike/aerospike-client-nodejs/issues/235) | ||
* Only setup cluster events callback on Client#connect [#237](https://github.com/aerospike/aerospike-client-nodejs/issues/237) | ||
* **Updates** | ||
* Update C client library to [v4.3.2](http://www.aerospike.com/download/client/c/notes.html#4.3.2). | ||
v3.1.0 / 2017-12-18 | ||
@@ -2,0 +12,0 @@ =================== |
@@ -30,3 +30,2 @@ // ***************************************************************************** | ||
const IndexJob = require('./index_job') | ||
const InfoAllCommand = require('./commands/info_all_command') | ||
const Query = require('./query') | ||
@@ -44,2 +43,80 @@ const ReadRecordCommand = require('./commands/read_record_command') | ||
// callback function for cluster events (node added/removed, etc.) | ||
function eventsCallback (event) { | ||
/** | ||
* @event Client#nodeAdded | ||
* @type {object} | ||
* @property {string} nodeName - Name of the cluster node that triggered this event. | ||
* @property {string} nodeAddress - IP address & port of the cluster node that triggered this event. | ||
* @since v2.7.0 | ||
*/ | ||
/** | ||
* @event Client#nodeRemoved | ||
* @type {object} | ||
* @property {string} nodeName - Name of the cluster node that triggered this event. | ||
* @property {string} nodeAddress - IP address & port of the cluster node that triggered this event. | ||
* @since v2.7.0 | ||
*/ | ||
/** | ||
* @event Client#disconnected | ||
* @since v2.7.0 | ||
* | ||
* @example | ||
* | ||
* const Aerospike = require('aerospike') | ||
* | ||
* Aerospike.connect((error, client) => { | ||
* if (error) throw error | ||
* | ||
* client.on('disconnected', () => { | ||
* console.warn('Client got disconnected from cluster') | ||
* }) | ||
* | ||
* // client is now ready to accept commands, e.g. get/put/... | ||
* | ||
* }) | ||
*/ | ||
this.emit(event.name, event) | ||
/** | ||
* @event Client#event | ||
* @description Instead of adding listeners for the {@link | ||
* event:Client#nodeAdded|nodeAdded}, {@link | ||
* event:Client#nodeRemoved|nodeRemoved} and {@link | ||
* event:Client#disconnected|disconnected} events, applications can also | ||
* subscribe to the <code>event</code> event to receive callbacks for any | ||
* kind of cluster event. | ||
* | ||
* @type {object} | ||
* @property {string} name - Name of the event. | ||
* @property {string} [nodeName] - Name of the cluster node that triggered this event. | ||
* @property {string} [nodeAddress] - IP address & port of the cluster node that triggered this event. | ||
* @since v2.7.0 | ||
* | ||
* @example | ||
* | ||
* const Aerospike = require('aerospike') | ||
* | ||
* Aerospike.connect((error, client) => { | ||
* if (error) throw error | ||
* | ||
* client.on('event', (event) => { | ||
* var now = new Date().toUTCString() | ||
* console.info(now, event.name, event.nodeName) // Example output: | ||
* // Thu, 13 Jul 2017 06:47:35 GMT nodeAdded BB94DC07D270009 | ||
* // Thu, 13 Jul 2017 06:47:35 GMT nodeAdded C1D4DC0AD270002 | ||
* // Thu, 13 Jul 2017 06:48:52 GMT nodeRemoved C1D4DC0AD270002 | ||
* // Thu, 13 Jul 2017 06:49:08 GMT nodeRemoved BB94DC07D270009 | ||
* // Thu, 13 Jul 2017 06:49:08 GMT disconnected | ||
* }) | ||
* | ||
* // client is now ready to accept commands, e.g. get/put/... | ||
* | ||
* }) | ||
*/ | ||
this.emit('event', event) | ||
} | ||
/** | ||
@@ -56,80 +133,2 @@ * @class Client | ||
// callback function for cluster events (node added/removed, etc.) | ||
var eventsCb = function (event) { | ||
/** | ||
* @event Client#nodeAdded | ||
* @type {object} | ||
* @property {string} nodeName - Name of the cluster node that triggered this event. | ||
* @property {string} nodeAddress - IP address & port of the cluster node that triggered this event. | ||
* @since v2.7.0 | ||
*/ | ||
/** | ||
* @event Client#nodeRemoved | ||
* @type {object} | ||
* @property {string} nodeName - Name of the cluster node that triggered this event. | ||
* @property {string} nodeAddress - IP address & port of the cluster node that triggered this event. | ||
* @since v2.7.0 | ||
*/ | ||
/** | ||
* @event Client#disconnected | ||
* @since v2.7.0 | ||
* | ||
* @example | ||
* | ||
* const Aerospike = require('aerospike') | ||
* | ||
* Aerospike.connect((error, client) => { | ||
* if (error) throw error | ||
* | ||
* client.on('disconnected', () => { | ||
* console.warn('Client got disconnected from cluster') | ||
* }) | ||
* | ||
* // client is now ready to accept commands, e.g. get/put/... | ||
* | ||
* }) | ||
*/ | ||
this.emit(event.name, event) | ||
/** | ||
* @event Client#event | ||
* @description Instead of adding listeners for the {@link | ||
* event:Client#nodeAdded|nodeAdded}, {@link | ||
* event:Client#nodeRemoved|nodeRemoved} and {@link | ||
* event:Client#disconnected|disconnected} events, applications can also | ||
* subscribe to the <code>event</code> event to receive callbacks for any | ||
* kind of cluster event. | ||
* | ||
* @type {object} | ||
* @property {string} name - Name of the event. | ||
* @property {string} [nodeName] - Name of the cluster node that triggered this event. | ||
* @property {string} [nodeAddress] - IP address & port of the cluster node that triggered this event. | ||
* @since v2.7.0 | ||
* | ||
* @example | ||
* | ||
* const Aerospike = require('aerospike') | ||
* | ||
* Aerospike.connect((error, client) => { | ||
* if (error) throw error | ||
* | ||
* client.on('event', (event) => { | ||
* var now = new Date().toUTCString() | ||
* console.info(now, event.name, event.nodeName) // Example output: | ||
* // Thu, 13 Jul 2017 06:47:35 GMT nodeAdded BB94DC07D270009 | ||
* // Thu, 13 Jul 2017 06:47:35 GMT nodeAdded C1D4DC0AD270002 | ||
* // Thu, 13 Jul 2017 06:48:52 GMT nodeRemoved C1D4DC0AD270002 | ||
* // Thu, 13 Jul 2017 06:49:08 GMT nodeRemoved BB94DC07D270009 | ||
* // Thu, 13 Jul 2017 06:49:08 GMT disconnected | ||
* }) | ||
* | ||
* // client is now ready to accept commands, e.g. get/put/... | ||
* | ||
* }) | ||
*/ | ||
this.emit('event', event) | ||
}.bind(this) | ||
/** | ||
@@ -145,3 +144,3 @@ * @name Client#config | ||
/** @private */ | ||
this.as_client = as.client(this.config, eventsCb) | ||
this.as_client = as.client(this.config) | ||
@@ -491,2 +490,5 @@ /** @private */ | ||
let eventsCb = eventsCallback.bind(this) | ||
this.as_client.setupEventCb(eventsCb) | ||
if (typeof callback === 'function') { | ||
@@ -1078,3 +1080,3 @@ this.as_client.connect((err) => { | ||
let cmd = new InfoAllCommand(this, 'infoForeach', [request, policy], callback) | ||
let cmd = new Command(this, 'infoForeach', [request, policy], callback) | ||
return cmd.execute() | ||
@@ -1663,5 +1665,2 @@ } | ||
* @param {string} [response] - The response string with the requested info. | ||
* @param {Object} [host] - The address of the host which send the response. | ||
* @param {string} host.addr - The ip address or host name of the host. | ||
* @param {number} host.port - The port number of the host. | ||
*/ | ||
@@ -1675,13 +1674,9 @@ | ||
* non-<code>null</code> if at least one of the cluster hosts responded with an | ||
* error to the info request. To check the status of the info requeset for each | ||
* individual cluster node, you need to check the list of responses returned in | ||
* the second parameter.. | ||
* error to the info request. | ||
* | ||
* @param {?AerospikeError} error - The error code and message or <code>null</code> if the operation was successful. | ||
* @param {Object[]} [responses] - The response string with the requested info. | ||
* @param {string} responses[].info - The response string with the requested info. | ||
* @param {?AerospikeError} responses[].error - The error code and message or <code>null</code> if the info request to this cluster host was successful. | ||
* @param {Object} responses[].host - The address of the host which send the response. | ||
* @param {string} responses[].host.addr - The ip address or host name of the host. | ||
* @param {number} responses[].host.port - The port number of the host. | ||
* @param {String} responses[].info - The response string with the requested info. | ||
* @param {Object} responses[].host - The node that send the info response. | ||
* @param {String} responses[].host.node_id - The name of the node. | ||
*/ | ||
@@ -1688,0 +1683,0 @@ |
@@ -85,20 +85,14 @@ // ***************************************************************************** | ||
IndexJob.prototype.info = function () { | ||
return new Promise((resolve, reject) => { | ||
let sindex = 'sindex/' + this.namespace + '/' + this.indexName | ||
this.client.infoAll(sindex, (error, responses) => { | ||
if (responses) { | ||
error = responses | ||
.map(response => response.error) | ||
.filter(error => !!error) | ||
.find(error => error.code !== status.ERR_INDEX_NOT_FOUND) | ||
let sindex = 'sindex/' + this.namespace + '/' + this.indexName | ||
return this.client.infoAll(sindex) | ||
.catch(error => { | ||
if (error.code === status.ERR_INDEX_NOT_FOUND) { | ||
return [{ load_pct: 0 }] | ||
} else { | ||
throw error | ||
} | ||
if (error) { | ||
return reject(error) | ||
} | ||
let info = responses | ||
.map(response => Info.parse(response.info)) | ||
.map(info => info[sindex] || { load_pct: 0 }) | ||
resolve(info) | ||
}) | ||
}) | ||
.then(responses => responses | ||
.map(response => Info.parse(response.info)) | ||
.map(info => info[sindex] || { load_pct: 0 })) | ||
} | ||
@@ -105,0 +99,0 @@ |
@@ -80,15 +80,7 @@ // ***************************************************************************** | ||
UdfJob.prototype.info = function () { | ||
return new Promise((resolve, reject) => { | ||
this.client.infoAll('udf-list', function (error, info) { | ||
if (error) { | ||
reject(error) | ||
} else { | ||
info = info.reduce((map, resp) => { | ||
map[resp.host.node_id] = Info.parse(resp.info) | ||
return map | ||
}, {}) | ||
resolve(info) | ||
} | ||
}) | ||
}) | ||
return this.client.infoAll('udf-list') | ||
.then(info => info.reduce((map, resp) => { | ||
map[resp.host.node_id] = Info.parse(resp.info) | ||
return map | ||
}, {})) | ||
} | ||
@@ -95,0 +87,0 @@ |
{ | ||
"name": "aerospike", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Aerospike Client Library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -14,6 +14,6 @@ # Aerospike Node.js Client [![travis][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] | ||
This module is compatible with Node.js v4.x (LTS), v6.x (LTS) and v8.x. It | ||
supports the following operating systems: CentOS/RHEL 6/7, Debian 7/8, | ||
Ubuntu 12.04/14.04/16.04, as well as many Linux destributions compatible with | ||
one of these OS releases. macOS is also supported. | ||
This module is compatible with Node.js v4.x (LTS), v6.x (LTS), v8.x (LTS) and | ||
v9.x. It supports the following operating systems: CentOS/RHEL 6/7, Debian | ||
7/8/9, Ubuntu 12.04/14.04/16.04, as well as many Linux destributions compatible | ||
with one of these OS releases. macOS is also supported. | ||
@@ -20,0 +20,0 @@ - [Usage](#Usage) |
@@ -40,3 +40,3 @@ // ***************************************************************************** | ||
if (error) throw error | ||
client.close() | ||
client.close(false) | ||
done() | ||
@@ -43,0 +43,0 @@ }) |
@@ -134,2 +134,23 @@ // ***************************************************************************** | ||
describe('Events', function () { | ||
it('client should emit nodeAdded events when connecting', function (done) { | ||
let client = new Client(helper.config) | ||
client.once('nodeAdded', event => { | ||
client.close() | ||
done() | ||
}) | ||
client.connect() | ||
}) | ||
it('client should emit events on cluster state changes', function (done) { | ||
let client = new Client(helper.config) | ||
client.once('event', event => { | ||
expect(event.name).to.be('nodeAdded') | ||
client.close() | ||
done() | ||
}) | ||
client.connect() | ||
}) | ||
}) | ||
context('callbacks', function () { | ||
@@ -136,0 +157,0 @@ // Execute a client command on a client instance that has been setup to |
@@ -93,3 +93,2 @@ // ***************************************************************************** | ||
expect(result.info).to.be('status\tok\n') | ||
expect(result.error).to.be(null) | ||
}) | ||
@@ -113,3 +112,2 @@ done() | ||
expect(result.info).to.be('status\tok\n') | ||
expect(result.error).to.be(null) | ||
}) | ||
@@ -116,0 +114,0 @@ }) |
@@ -23,2 +23,3 @@ // ***************************************************************************** | ||
const Double = Aerospike.Double | ||
const GeoJSON = Aerospike.GeoJSON | ||
const helper = require('./test_helper') | ||
@@ -41,3 +42,7 @@ | ||
double1: 1.23, | ||
double2: new Double(1.0) | ||
double2: new Double(1.0), | ||
geo: new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]}), | ||
blob: Buffer.from('foo'), | ||
list: [1, 2, 3], | ||
map: {a: 1, b: 2, c: 3} | ||
} | ||
@@ -60,3 +65,7 @@ let policy = new Aerospike.WritePolicy({ | ||
op.write('double1', 2.34), | ||
op.write('double2', new Double(2.0)) | ||
op.write('double2', new Double(2.0)), | ||
op.write('geo', new GeoJSON({type: 'Point', coordinates: [123.456, 1.308]})), | ||
op.write('blob', Buffer.from('bar')), | ||
op.write('list', [2, 3, 4]), | ||
op.write('map', {d: 4, e: 5, f: 6}) | ||
] | ||
@@ -71,2 +80,8 @@ | ||
expect(record.bins['double2']).to.equal(2.0) | ||
expect(new GeoJSON(record.bins['geo']).toJSON()).to.eql( | ||
{ type: 'Point', coordinates: [123.456, 1.308] } | ||
) | ||
expect(record.bins['blob'].equals(Buffer.from('bar'))).to.be.ok() | ||
expect(record.bins['list']).to.eql([2, 3, 4]) | ||
expect(record.bins['map']).to.eql({d: 4, e: 5, f: 6}) | ||
}) | ||
@@ -73,0 +88,0 @@ }) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1132141
205
20014