Socket
Socket
Sign inDemoInstall

aerospike

Package Overview
Dependencies
Maintainers
3
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.1 to 3.2.0

benchmarks/node_modules/ansi-regex/index.js

2

benchmarks/config.json

@@ -16,3 +16,3 @@ {

"filename" : null,
"operations" : 100,
"operations" : 10,
"iterations" : null,

@@ -19,0 +19,0 @@ "processes" : 4,

@@ -11,2 +11,3 @@ {

],
"license": "Apache-2.0",
"engines": {

@@ -27,9 +28,8 @@ "node": ">=4"

"dependencies": {
"aerospike": "^3.0.2",
"cli-table": "0.2.0",
"colors": "0.6.2",
"winston": "0.7.2",
"yargs": "1.2.1"
"aerospike": "file:..",
"cli-table": "^0.3.1",
"winston": "^2.4.0",
"yargs": "^10.1.1"
},
"main": "main.js"
}

@@ -36,3 +36,3 @@ # Benchmarks

- log : Log level of the client module (default INFO).
- operations : Number of operations for a single batch of operations. (default `100`).
- operations : Number of operations for a single batch of operations. (default `10`).
- iterations : Number of iterations the benchmark should run. (default `null` - runs indefinitely).

@@ -39,0 +39,0 @@ - processes : Number of worker process. These are work horses for the benchmark, that does actual read/write or scan/query operations in a aerospike cluster. (default `4` - Recommened value Number of CPUs/cores in the machine).

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -20,3 +20,4 @@ // Licensed under the Apache License, Version 2.0 (the "License")

const as = require('bindings')('aerospike.node')
const asEventLoop = require('./event_loop')
const AerospikeError = require('./error')
const EventLoop = require('./event_loop')
const utils = require('./utils')

@@ -96,2 +97,3 @@

exports.BatchPolicy = policy.BatchPolicy
exports.CommandQueuePolicy = policy.CommandQueuePolicy
exports.InfoPolicy = policy.InfoPolicy

@@ -125,3 +127,3 @@ exports.MapPolicy = policy.MapPolicy

*/
exports.AerospikeError = require('./error')
exports.AerospikeError = AerospikeError

@@ -325,3 +327,3 @@ /**

exports.print = utils.print
exports.releaseEventLoop = asEventLoop.releaseEventLoop
exports.releaseEventLoop = EventLoop.releaseEventLoop

@@ -418,2 +420,36 @@ let Client = exports.Client

/**
* Configures the global command queue. (Disabled by default.)
*
* This method must be called before an {@link Client} instances are connected.
*
* @param {CommandQueuePolicy} policy
* @see {@link CommandQueuePolicy}
*
* @example
*
* const Aerospike = require('aerospike')
*
* Aerospike.setupGlobalCommandQueue({
* maxCommandsInProcess: 50,
* maxCommandsInQueue: 150
* })
* Aerospike.connect()
* .then(client => {
* let commands = []
* for (var i = 0; i < 100; i++) {
* commands.push(client.put(new Aerospike.Key('test', 'test', i), {i: i}))
* }
* // First 50 commands will be executed immediately,
* // remaining commands will be queued and executed once the client frees up.
* Promise.all(commands)
* .then(() => console.info('All commands executed successfully'))
* .catch(error => console.error('Error:', error))
* .then(() => client.close())
* })
*/
exports.setupGlobalCommandQueue = function (policy) {
EventLoop.setCommandQueuePolicy(policy)
}
// Set default log level

@@ -420,0 +456,0 @@ as.setDefaultLogging({

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -25,13 +25,9 @@ // Licensed under the Apache License, Version 2.0 (the "License")

const AerospikeError = require('./error')
const BatchCommand = require('./commands/batch_command')
const Command = require('./commands/command')
const Commands = require('./commands')
const Config = require('./config')
const ExistsCommand = require('./commands/exists_command')
const EventLoop = require('./event_loop')
const IndexJob = require('./index_job')
const Query = require('./query')
const ReadRecordCommand = require('./commands/read_record_command')
const Scan = require('./scan')
const UdfJob = require('./udf_job')
const WriteRecordCommand = require('./commands/write_record_command')
const asEventLoop = require('./event_loop')
const operations = require('./operations')

@@ -147,3 +143,27 @@ const utils = require('./utils')

/** @private */
/**
* @name Client#captureStackTraces
*
* @summary Set to <code>true</code> to enable capturing of debug stacktraces for
* every database command.
*
* @description The client will capture a stacktrace before each database
* command is executed, instead of capturing the stacktrace only when an
* error is raised. This generally results in much more useful stacktraces
* that include stackframes from the calling application issuing the database
* command.
*
* **Note:** Enabling this feature incurs a significant performance overhead for
* every database command. It is recommended to leave this feature disabled
* in production environments.
*
* By default, the client will set this flag to true, if the
* <code>AEROSPIKE_DEBUG_STACKTRACES</code> environment variable is set (to
* any value).
*
* @type {boolean}
* @default <code>true</code>, if
* <code>process.env.AEROSPIKE_DEBUG_STACKTRACES</code> is set;
* <code>false</code> otherwise.
*/
this.captureStackTraces = !!process.env.AEROSPIKE_DEBUG_STACKTRACES

@@ -240,3 +260,3 @@ }

let cmd = new BatchCommand(this, 'batchExists', [keys, policy], callback)
let cmd = new Commands.BatchExists(this, [keys, policy], callback)
return cmd.execute()

@@ -294,3 +314,3 @@ }

let cmd = new BatchCommand(this, 'batchGet', [keys, policy], callback)
let cmd = new Commands.BatchGet(this, [keys, policy], callback)
return cmd.execute()

@@ -350,3 +370,3 @@ }

let cmd = new BatchCommand(this, 'batchRead', [records, policy], callback)
let cmd = new Commands.BatchRead(this, [records, policy], callback)
return cmd.execute()

@@ -406,3 +426,3 @@ }

let cmd = new BatchCommand(this, 'batchSelect', [keys, bins, policy], callback)
let cmd = new Commands.BatchSelect(this, [keys, bins, policy], callback)
return cmd.execute()

@@ -439,3 +459,3 @@ }

if (releaseEventLoop && _connectedClients === 0) {
asEventLoop.releaseEventLoop()
EventLoop.releaseEventLoop()
}

@@ -491,3 +511,3 @@ }

Client.prototype.connect = function (callback) {
asEventLoop.registerASEventLoop()
EventLoop.registerASEventLoop()

@@ -638,3 +658,3 @@ let eventsCb = eventsCallback.bind(this)

let cmd = new Command(this, 'indexCreate', args, callback)
let cmd = new Commands.IndexCreate(this, args, callback)
cmd.convertResult = () => new IndexJob(this, options.ns, options.index)

@@ -837,3 +857,3 @@ return cmd.execute()

let cmd = new Command(this, 'applyAsync', [key, udfArgs, policy], callback)
let cmd = new Commands.Apply(this, [key, udfArgs, policy], callback)
return cmd.execute()

@@ -882,3 +902,3 @@ }

let cmd = new ExistsCommand(this, 'existsAsync', [key, policy], callback)
let cmd = new Commands.Exists(this, [key, policy], callback)
return cmd.execute()

@@ -919,3 +939,3 @@ }

let cmd = new ReadRecordCommand(this, 'getAsync', [key, policy], callback)
let cmd = new Commands.Get(this, key, [policy], callback)
return cmd.execute()

@@ -954,3 +974,3 @@ }

let cmd = new Command(this, 'indexRemove', [namespace, index, policy], callback)
let cmd = new Commands.IndexRemove(this, [namespace, index, policy], callback)
return cmd.execute()

@@ -1001,3 +1021,3 @@ }

let cmd = new Command(this, 'info', [request, host, policy], callback)
let cmd = new Commands.Info(this, [request, host, policy], callback)
return cmd.execute()

@@ -1044,3 +1064,3 @@ }

let cmd = new Command(this, 'info', [request, null, policy], callback)
let cmd = new Commands.Info(this, [request, null, policy], callback)
return cmd.execute()

@@ -1090,3 +1110,3 @@ }

let cmd = new Command(this, 'infoForeach', [request, policy], callback)
let cmd = new Commands.InfoForeach(this, [request, policy], callback)
return cmd.execute()

@@ -1164,3 +1184,3 @@ }

let cmd = new ReadRecordCommand(this, 'operateAsync', [key, operations, metadata, policy], callback)
let cmd = new Commands.Operate(this, key, [operations, metadata, policy], callback)
return cmd.execute()

@@ -1308,3 +1328,3 @@ }

let cmd = new WriteRecordCommand(this, 'putAsync', [key, bins, meta, policy], callback)
let cmd = new Commands.Put(this, key, [bins, meta, policy], callback)
return cmd.execute()

@@ -1370,3 +1390,3 @@ }

let cmd = new WriteRecordCommand(this, 'removeAsync', [key, policy], callback)
let cmd = new Commands.Remove(this, key, [policy], callback)
return cmd.execute()

@@ -1428,3 +1448,3 @@ }

let cmd = new ReadRecordCommand(this, 'selectAsync', [key, bins, policy], callback)
let cmd = new Commands.Select(this, key, [bins, policy], callback)
return cmd.execute()

@@ -1439,3 +1459,3 @@ }

* @description This method is many orders of magnitude faster than deleting
* records one at a time. Works with Aerospike Server version >= 3.12.
* records one at a time. It requires Aerospike Server version 3.12 or later.
*

@@ -1452,2 +1472,4 @@ * @param {string} ns - Required namespace.

* operation completes with the result of the operation.
*
* @see https://www.aerospike.com/docs/reference/info#truncate
*/

@@ -1469,3 +1491,3 @@ Client.prototype.truncate = function (ns, set, beforeNanos, policy, callback) {

let cmd = new Command(this, 'truncate', [ns, set, beforeNanos, policy], callback)
let cmd = new Commands.Truncate(this, [ns, set, beforeNanos, policy], callback)
return cmd.execute()

@@ -1530,3 +1552,3 @@ }

let cmd = new Command(this, 'udfRegister', [udfPath, udfType, policy], callback)
let cmd = new Commands.UdfRegister(this, [udfPath, udfType, policy], callback)
cmd.convertResult = () => {

@@ -1584,3 +1606,3 @@ let module = path.basename(udfPath)

let cmd = new Command(this, 'udfRemove', [udfModule, policy], callback)
let cmd = new Commands.UdfRemove(this, [udfModule, policy], callback)
cmd.convertResult = () => new UdfJob(this, udfModule, UdfJob.UNREGISTER)

@@ -1587,0 +1609,0 @@ return cmd.execute()

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -29,3 +29,3 @@ // Licensed under the Apache License, Version 2.0 (the "License")

class BatchCommand extends Command {
module.exports = asCommand => class BatchCommand extends Command(asCommand) {
convertResult (results) {

@@ -40,3 +40,1 @@ if (!results) return []

}
module.exports = BatchCommand
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -20,19 +20,64 @@ // Licensed under the Apache License, Version 2.0 (the "License")

const AerospikeError = require('../error')
const status = require('../status')
class Command {
constructor (client, name, args, callback) {
// Command is an abstract template (aka "mix-in") for concrete command
// subclasses, that execute a specific database command method on the native
// Aerospike add-on. A concrete command subclass should be defined like this,
// where "getAsync" is the native command method to call:
//
// class GetCommand extends Command("getAsync") {
// // ...
// }
/**
* @class Command
* @classdesc Database command.
*/
module.exports = asCommand => class Command {
/** @private */
constructor (client, args, callback) {
/**
* Client instance used to execute this command.
*
* @name Command#client
* @type {Client}
* @readonly
*/
this.client = client
this.name = name
/** @private */
this.args = args
if (callback) this.callback = callback
if (callback) {
/** @private */
this.callback = callback
}
/**
* Whether debug stacktraces are enabled.
*
* @name Command#captureStackTraces
* @type {boolean}
* @readonly
* @see {@link Client#captureStackTraces}
*/
this.captureStackTraces = client.captureStackTraces
/**
* The record key for which the command was issued. (Single-key commands only.)
*
* @name Command#key
* @type {?Key}
* @readonly
*/
this.key = undefined
}
/** @private */
captureStackTrace () {
if (this.captureStackTraces) {
this.stackTrace = AerospikeError.captureStackTrace()
AerospikeError.captureStackTrace(this, this.captureStackTrace)
}
}
/** @private */
connected () {

@@ -42,6 +87,8 @@ return this.client.isConnected(false)

/** @private */
convertError (error) {
return AerospikeError.fromASError(error, this.stackTrace)
return AerospikeError.fromASError(error, this)
}
/** @private */
convertResult (arg1, arg2, arg3) {

@@ -51,2 +98,3 @@ return arg1

/** @private */
convertResponse (err, arg1, arg2, arg3) {

@@ -58,2 +106,3 @@ let error = this.convertError(err)

/** @private */
execute () {

@@ -73,2 +122,3 @@ if (!this.connected()) {

/** @private */
executeWithCallback (callback) {

@@ -89,2 +139,3 @@ // C client will call the callback function synchronously under certain error

/** @private */
executeAndReturnPromise () {

@@ -102,2 +153,3 @@ return new Promise((resolve, reject) => {

/** @private */
expectsPromise () {

@@ -107,2 +159,8 @@ return !this.callback

/** @private */
asCommand () {
return asCommand
}
/** @private */
process (cb) {

@@ -116,7 +174,8 @@ let asCallback = (err, arg1, arg2, arg3) => {

let asArgs = this.args.concat([asCallback])
this.client.asExec(this.name, asArgs)
this.client.asExec(this.asCommand(), asArgs)
}
/** @private */
sendError (message) {
let error = new AerospikeError(status.ERR_CLIENT, message)
let error = new AerospikeError(message, this)
if (this.expectsPromise()) {

@@ -129,3 +188,1 @@ return Promise.reject(error)

}
module.exports = Command
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -22,3 +22,3 @@ // Licensed under the Apache License, Version 2.0 (the "License")

class ExistsCommand extends Command {
module.exports = asCommand => class ExistsCommand extends Command(asCommand) {
convertResponse (error) {

@@ -35,3 +35,1 @@ error = this.convertError(error)

}
module.exports = ExistsCommand
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -22,6 +22,7 @@ // Licensed under the Apache License, Version 2.0 (the "License")

class ReadRecordCommand extends Command {
constructor (client, name, args, callback) {
super(client, name, args, callback)
this.key = args[0]
module.exports = asCommand => class ReadRecordCommand extends Command(asCommand) {
constructor (client, key, args, callback) {
args = [key].concat(args)
super(client, args, callback)
this.key = key
}

@@ -33,3 +34,1 @@

}
module.exports = ReadRecordCommand
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -25,5 +25,5 @@ // Licensed under the Apache License, Version 2.0 (the "License")

class StreamCommand extends Command {
constructor (stream, name, args) {
super(stream.client, name, args)
module.exports = asCommand => class StreamCommand extends Command(asCommand) {
constructor (stream, args) {
super(stream.client, args)
this.stream = stream

@@ -49,3 +49,1 @@ }

}
module.exports = StreamCommand
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -21,6 +21,7 @@ // Licensed under the Apache License, Version 2.0 (the "License")

class WriteRecordCommand extends Command {
constructor (client, name, args, callback) {
super(client, name, args, callback)
this.key = args[0]
module.exports = asCommand => class WriteRecordCommand extends Command(asCommand) {
constructor (client, key, args, callback) {
args = [key].concat(args)
super(client, args, callback)
this.key = key
}

@@ -32,3 +33,1 @@

}
module.exports = WriteRecordCommand
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -20,126 +20,135 @@ // Licensed under the Apache License, Version 2.0 (the "License")

const status = require('./status')
const util = require('util')
/**
* @class AerospikeError
* Error raised by the client when execution of a database command fails. This
* may be either due to an error status code returned by the server, or caused
* by an error condition that occured on the client side.
*
* @extends Error
* @classdesc Error status returned by the server.
*
* @summary Construct a new AerospikeError instance.
* @example <caption>Expected output: "Error: 127.0.0.1:3000 Record does not exist in database. May be returned by read, or write with policy Aerospike.policy.exists.UPDATE [2]"</caption>
*
* @param {number} code - The status code of the error.
* @param {string} [message] - A message describing the status code.
* @param {string} [func] - The name of the function in which the error occurred.
* @param {string} [file] - The file name in which the error occurred.
* @param {string} [line] - The line number on which the error occurred.
*
* @see <code>Aerospike.status</code> contains the full list of possible status codes.
*
* @example
*
* const Aerospike = require('aerospike')
* var key = new Aerospike.Key('test', 'key', 'does_not_exist')
* Aerospike.connect((error, client) => {
* if (error) throw error
* client.get(key, (error, record) => {
* console.log(error) // => { [AerospikeError: ERR_RECORD_NOT_FOUND]
* // code: 2,
* // message: 'ERR_RECORD_NOT_FOUND',
* // func: 'as_event_command_parse_result',
* // file: 'src/main/aerospike/as_event.c',
* // line: 614,
* // name: 'AerospikeError' }
* let key = new Aerospike.Key('test', 'key', 'does_not_exist')
* Aerospike.connect()
* .then(client => {
* client.get(key)
* .then(record => console.info(record))
* .catch(error => console.error(`Error: ${error.message} [${error.code}]`))
* .then(() => client.close())
* })
* client.close()
* })
*/
function AerospikeError (code, message, func, file, line, stack) {
/**
* Error name
*
* @name AerospikeError#name
* @type {string}
* @readonly
*/
Object.defineProperty(this, 'name', {value: 'AerospikeError'})
class AerospikeError extends Error {
/** @private */
constructor (message, command) {
super(message)
this.name = this.constructor.name
/**
* Error message
*
* @name AerospikeError#message
* @type {string}
* @readonly
*/
this.message = message || 'Aerospike Error'
/**
* Numeric status code returned by the server or the client.
*
* @type {number}
* @readonly
*
* @see {@link module:aerospike.status} contains the full list of possible status codes.
*/
this.code = status.ERR_CLIENT
/**
* Status code.
*
* @name AerospikeError#code
* @type {number}
* @readonly
*
* @see List of status codes defined at {@link module:aerospike.status}
*/
this.code = code
/**
* Command during which the error occurred.
*
* @type {?Command}
* @readonly
*/
this.command = command || null
/**
* C/C++ function name where the error occurred.
*
* @name AerospikeError#func
* @type {?string}
* @readonly
*/
this.func = func
/**
* C/C++ function name in which the error occurred.
*
* @type {?string}
* @readonly
*/
this.func = null
/**
* File name of the C/C++ source file in which the error occurred.
*
* @name AerospikeError#file
* @type {?string}
* @readonly
*/
this.file = file
/**
* File name of the C/C++ source file in which the error occurred.
*
* @type {?string}
* @readonly
*/
this.file = null
/**
* Line number in the C/C++ source file in which the error occurred.
*
* @name AerospikeError#file
* @type {?string}
* @readonly
*/
this.line = line
/**
* Line number in the C/C++ source file in which the error occurred.
*
* @type {?number}
* @readonly
*/
this.line = null
if (stack) {
stack = stack.replace(/^.*$/m, util.format('%s: %s', this.name, this.message))
Object.defineProperty(this, 'stack', {value: stack})
} else {
Error.captureStackTrace(this, this.constructor)
/**
* It is possible that a write transaction completed even though the client
* returned this error. This may be the case when a client error occurs
* (like timeout) after the command was sent to the server.
*
* @type {boolean}
* @readonly
*/
this.inDoubt = false
if (command && command.stack) {
this.setStackTrace(command.stack)
}
}
}
/** @private */
AerospikeError.fromASError = function (err, stackTrace) {
if (!err) {
return null
} else if (err.code === status.OK) {
return null
} else if (err instanceof AerospikeError) {
return err
} else {
let message = err.message
if (message.startsWith('AEROSPIKE_')) {
message = status.getMessage(err.code)
/** @private */
static fromASError (asError, command) {
if (!asError) {
return null
} else if (asError.code === status.OK) {
return null
} else if (asError instanceof AerospikeError) {
return asError
} else {
let message = this.formatMessage(asError.message, asError.code)
let error = new AerospikeError(message, command)
this.copyASErrorProperties(error, asError)
return error
}
return new AerospikeError(err.code, message, err.func, err.file, err.line, stackTrace)
}
}
/** @private */
AerospikeError.captureStackTrace = function () {
return new AerospikeError().stack
/** @private */
static copyASErrorProperties (target, source) {
target.code = source.code
target.inDoubt = source.inDoubt
target.func = source.func
target.file = source.file
target.line = Number.parseInt(source.line)
}
/** @private */
static formatMessage (message, code) {
if (message) {
message = message.replace(/AEROSPIKE_[A-Z_]+/, () => status.getMessage(code))
}
return message
}
/** @private */
setStackTrace (stack) {
let firstLine = `${this.name}: ${this.message}`
stack = stack.replace(/^.*$/m, firstLine)
Object.defineProperty(this, 'stack', {value: stack})
}
/**
* Indicates whether the error originated on the database server.
*
* @returns {boolean} - <code>true</code> if the server raised the error, <code>false</code> otherwise.
*/
isServerError () {
return this.code > status.OK
}
}
util.inherits(AerospikeError, Error)
module.exports = AerospikeError
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -20,2 +20,4 @@ // Licensed under the Apache License, Version 2.0 (the "License")

const as = require('bindings')('aerospike.node')
const AerospikeError = require('./error')
const CommandQueuePolicy = require('./policies/command_queue_policy')

@@ -38,2 +40,4 @@ /**

let _commandQueuePolicy = new CommandQueuePolicy()
/**

@@ -86,7 +90,7 @@ * @memberof! module:aerospike

if (_eventLoopReleased) {
throw new Error('Event loop resources have already been released! Call Client#close() with releaseEventLoop set to false to avoid this error.')
throw new AerospikeError('Event loop resources have already been released! Call Client#close() with releaseEventLoop set to false to avoid this error.')
}
if (!_eventLoopInitialized) {
as.register_as_event_loop()
as.register_as_event_loop(_commandQueuePolicy)
_eventLoopInitialized = true

@@ -96,5 +100,16 @@ }

/**
* @private
*/
function setCommandQueuePolicy (policy) {
if (_eventLoopInitialized) {
throw new AerospikeError('Command queue has already been initialized! Call Aerospike#setGlobalCommandQueuePolicy() before connecting any client instances.')
}
_commandQueuePolicy = policy
}
module.exports = {
releaseEventLoop: releaseEventLoop,
registerASEventLoop: registerASEventLoop
registerASEventLoop: registerASEventLoop,
setCommandQueuePolicy: setCommandQueuePolicy
}
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -20,3 +20,3 @@ // Licensed under the Apache License, Version 2.0 (the "License")

const as = require('bindings')('aerospike.node')
const Command = require('./commands/command')
const Commands = require('./commands')

@@ -134,3 +134,3 @@ const DEFAULT_POLL_INTERVALL = 1000

let cmd = new Command(this.client, 'jobInfo', [this.jobID, this.module, policy], callback)
let cmd = new Commands.JobInfo(this.client, [this.jobID, this.module, policy], callback)
return cmd.execute()

@@ -137,0 +137,0 @@ }

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -23,2 +23,3 @@ // Licensed under the Apache License, Version 2.0 (the "License")

let BatchPolicy = require('./policies/batch_policy')
let CommandQueuePolicy = require('./policies/command_queue_policy')
let InfoPolicy = require('./policies/info_policy')

@@ -224,2 +225,9 @@ let MapPolicy = require('./policies/map_policy')

/**
* A policy affecting the use of the global command queue.
*
* @summary {@link CommandQueuePolicy} class
*/
exports.CommandQueuePolicy = CommandQueuePolicy
/**
* A policy affecting the behavior of info operations.

@@ -226,0 +234,0 @@ *

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -19,6 +19,5 @@ // Licensed under the Apache License, Version 2.0 (the "License")

const Command = require('./commands/command')
const Commands = require('./commands')
const Job = require('./job')
const RecordStream = require('./record_stream')
const StreamCommand = require('./commands/stream_command')

@@ -328,5 +327,9 @@ const assert = require('assert')

let cmdName = this.udf ? 'queryForeach' : 'queryAsync'
let args = [this.ns, this.set, this, policy]
let cmd = new StreamCommand(stream, cmdName, args)
let cmd
if (this.udf) {
cmd = new Commands.QueryForeach(stream, args)
} else {
cmd = new Commands.Query(stream, args)
}
cmd.execute()

@@ -368,3 +371,3 @@

let cmd = new Command(this.client, 'queryApply', [this.ns, this.set, this, policy], callback)
let cmd = new Commands.QueryApply(this.client, [this.ns, this.set, this, policy], callback)
return cmd.execute()

@@ -413,3 +416,3 @@ }

let cmd = new Command(this.client, 'queryBackground', [this.ns, this.set, this, policy, queryID], callback)
let cmd = new Commands.QueryBackground(this.client, [this.ns, this.set, this, policy, queryID], callback)
cmd.convertResult = () => {

@@ -416,0 +419,0 @@ let module = this.filters.length > 0 ? 'query' : 'scan'

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -19,6 +19,5 @@ // Licensed under the Apache License, Version 2.0 (the "License")

const Command = require('./commands/command')
const Commands = require('./commands')
const Job = require('./job')
const RecordStream = require('./record_stream')
const StreamCommand = require('./commands/stream_command')

@@ -225,3 +224,3 @@ /**

let cmd = new Command(this.client, 'scanBackground', [this.ns, this.set, this, policy, scanID], callback)
let cmd = new Commands.ScanBackground(this.client, [this.ns, this.set, this, policy, scanID], callback)
cmd.convertResult = () => new Job(this.client, scanID, 'scan')

@@ -251,3 +250,3 @@ return cmd.execute()

let args = [this.ns, this.set, this, policy, scanID]
let cmd = new StreamCommand(stream, 'scanAsync', args)
let cmd = new Commands.Scan(stream, args)
cmd.execute()

@@ -254,0 +253,0 @@

@@ -32,2 +32,14 @@ // *****************************************************************************

/**
* Async command delay queue is full.
* @const {number}
*/
exports.ERR_ASYNC_QUEUE_FULL = as.status.AEROSPIKE_ERR_ASYNC_QUEUE_FULL
/**
* Synchronous connection error.
* @const {number}
*/
exports.ERR_CONNECTION = as.status.AEROSPIKE_ERR_INVALID_NODE
/**
* Node invalid or could not be found.

@@ -465,2 +477,3 @@ * @const {number}

exports.getMessage = function (code) {
/* istanbul ignore next */
switch (code) {

@@ -467,0 +480,0 @@ case exports.ERR_INVALID_NODE:

{
"name": "aerospike",
"version": "3.1.1",
"version": "3.2.0",
"description": "Aerospike Client Library",

@@ -18,3 +18,4 @@ "keywords": [

"linux",
"darwin"
"darwin",
"win32"
],

@@ -32,3 +33,3 @@ "cpu": [

"scripts": {
"test": "./scripts/shuffle_tests",
"test": "mocha",
"posttest": "standard",

@@ -46,2 +47,3 @@ "coverage": "nyc npm test && nyc --reporter=lcov report",

"devDependencies": {
"choma": "^1.1.0",
"codecov": "^2.3.0",

@@ -52,9 +54,9 @@ "expect.js": "^0.3",

"mocha": "^3.5.3",
"mocha-clean": "^1.0.0",
"nyc": "^11.2.1",
"seedrandom": "^2.4.3",
"standard": "^10.0",
"tmp": "^0.0.33",
"yargs": "^1.3.3"
},
"optionalDependencies": {
"webworker-threads": "^0.7"
},
"standard": {

@@ -61,0 +63,0 @@ "ignore": [

@@ -17,3 +17,3 @@ # Aerospike Node.js Client [![travis][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url]

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.
with one of these OS releases. macOS and Windows are also supported.

@@ -105,11 +105,12 @@ - [Usage](#Usage)

The aerospike package supports Node.js v4.x (LTS), v6.x (LTS) and v8.x. To
download and install the latest stable version of Node.js, visit
The Aerospike Node.js client supports all Node.js [LTS
releases](https://github.com/nodejs/Release#release-schedule). To download and
install the latest stable version of Node.js, visit
[nodejs.org](http://nodejs.org/) or use the version that comes bundled with
your operating system.
The Aerospike package includes a native addon. `gcc`/`g++` v4.8 or newer or
`clang`/`clang++` v3.4 or newer are required to build the addon.
The package includes a native add-on. `gcc`/`g++` v4.8 or newer or
`clang`/`clang++` v3.4 or newer are required to build the add-on.
The Aerospike addon depends on the Aerospike C client library, which gets
The Aerospike add-on depends on the Aerospike C client library, which is
downloaded during package installation. Either the cURL or Wget command line tool

@@ -135,3 +136,3 @@ is required for this. See ["C Client Resolution"](#C-Client-Resolution) below for

Note: The `gcc` tool chain included in CentOS/RHEL 6.x is gcc-4.4. To build the
Aerospike addon using Node.js v4 or later, gcc-4.8 or later is required. To
Aerospike add-on using Node.js v4 or later, gcc-4.8 or later is required. To
update the gcc tool chain you can install a recent version of the

@@ -176,2 +177,6 @@ [Red Hat Developer Toolset](https://access.redhat.com/documentation/en/red-hat-developer-toolset/)

### Windows
See [Prerequisites for Aerospike Node.js Client on Windows](https://github.com/aerospike/aerospike-client-nodejs/blob/master/README_WINDOWS.md).
<a name="Installation"></a>

@@ -340,3 +345,3 @@ ## Installation

* [Managing Aerospike connections in a Node cluster](https://www.aerospike.com/apidocs/nodejs/tutorial-node_clusters.html)
* [Handling asynchronous database operations using Callbacks, Promises or async/await](https://www.aerospike.com/apidocs/nodejs/tutorial-callbacks_promises_async_await.html)
* [Handling asynchronous database operations using Callbacks, Promises or `async`/`await`](https://www.aerospike.com/apidocs/nodejs/tutorial-callbacks_promises_async_await.html)

@@ -346,4 +351,3 @@ A variety of additional example applications are provided in the

The list of [backward incompatible API changes](docs/api-changes.md) by release,
to the API by release.
The list of [backward incompatible API changes](docs/api-changes.md) by release.

@@ -350,0 +354,0 @@ ### API Versioning

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -25,3 +25,3 @@ // Licensed under the Apache License, Version 2.0 (the "License")

describe('Aerospike', function () {
describe('Aerospike.client()', function () {
describe('Aerospike.client() #noserver', function () {
it('instantiates a new client instance', function (done) {

@@ -28,0 +28,0 @@ var client = Aerospike.client(helper.config)

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -58,3 +58,3 @@ // Licensed under the Apache License, Version 2.0 (the "License")

describe('#close', function () {
it('should be a no-op if close is called after connection error', function (done) {
it('should be a no-op if close is called after connection error #noserver', function (done) {
const client = new Client({hosts: '127.0.0.1:0'})

@@ -179,3 +179,3 @@ client.connect(error => {

it('callback is asynchronous in case of an client error', function (done) {
it('callback is asynchronous in case of an client error #noserver', function (done) {
// trying to send a command to a client that is not connected will trigger a client error

@@ -182,0 +182,0 @@ var client = Aerospike.client()

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -25,3 +25,3 @@ // Licensed under the Apache License, Version 2.0 (the "License")

describe('Config', function () {
describe('Config #noserver', function () {
var asHostsEnv

@@ -28,0 +28,0 @@ beforeEach(function () {

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -26,3 +26,3 @@ // Licensed under the Apache License, Version 2.0 (the "License")

describe('Aerospike.Double', function () {
describe('Aerospike.Double #noserver', function () {
describe('constructor', function () {

@@ -29,0 +29,0 @@ it('returns a new Double value', function () {

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -22,6 +22,8 @@ // Licensed under the Apache License, Version 2.0 (the "License")

const AerospikeError = require('../lib/error')
const status = require('../lib/status')
require('./test_helper.js')
describe('AerospikeError', function () {
describe('new AerospikeError()', function () {
describe('AerospikeError #noserver', function () {
describe('constructor', function () {
it('creates a new AerospikeError instance', function () {

@@ -35,17 +37,38 @@ expect(new AerospikeError()).to.be.a(AerospikeError)

it('sets the error code, message, function, file and line information', function () {
var subject = new AerospikeError(-1, 'client error', 'connect', 'lib/client.js', 101)
expect(subject.code).to.be(-1)
expect(subject.message).to.be('client error')
expect(subject.func).to.be('connect')
expect(subject.file).to.be('lib/client.js')
expect(subject.line).to.be(101)
it('initializes the error with default values', function () {
let subject = new AerospikeError()
expect(subject.message).to.be('')
expect(subject.code).to.be(status.ERR_CLIENT)
expect(subject.command).to.be(null)
expect(subject.func).to.be(null)
expect(subject.file).to.be(null)
expect(subject.line).to.be(null)
expect(subject.inDoubt).to.be(false)
})
it('captures a stack trace', function () {
var subject = new AerospikeError(-1, 'client error', 'connect', 'lib/client.js', 101)
var stack = subject.stack.split('\n')
it('sets an error message', function () {
let subject = new AerospikeError('Dooh!')
expect(subject.message).to.be('Dooh!')
})
it('keeps a reference to the command', function () {
let cmd = {}
let subject = new AerospikeError('Dooh!', cmd)
expect(subject.command).to.be(cmd)
})
it('captures a stacktrace', function () {
let subject = new AerospikeError('Dooh!')
let stack = subject.stack.split('\n')
expect(stack).to.not.be.empty()
expect(stack.shift()).to.be('AerospikeError: client error')
expect(stack.shift()).to.be('AerospikeError: Dooh!')
})
it('copies the stacktrace of the command', function () {
let cmd = {}
Error.captureStackTrace(cmd)
let subject = new AerospikeError('Dooh!', cmd)
let expected = ['AerospikeError: Dooh!'].concat(cmd.stack.split('\n').slice(1)).join('\n')
expect(subject.stack).to.equal(expected)
})
})

@@ -55,23 +78,63 @@

it('copies the info from a AerospikeClient error instance', function () {
var error = {code: -1, message: 'client error', func: 'connect', file: 'lib/client.js', line: 101}
var subject = AerospikeError.fromASError(error)
expect(subject.code).to.be(-1)
expect(subject.message).to.be('client error')
let error = {
code: -11,
message: 'Dooh!',
func: 'connect',
file: 'lib/client.js',
line: 101,
inDoubt: true
}
let subject = AerospikeError.fromASError(error)
expect(subject.code).to.be(-11)
expect(subject.message).to.be('Dooh!')
expect(subject.func).to.be('connect')
expect(subject.file).to.be('lib/client.js')
expect(subject.line).to.be(101)
expect(subject.inDoubt).to.be(true)
})
it('replaces error codes with descriptive messages', function () {
let error = {
code: status.ERR_RECORD_NOT_FOUND,
message: '127.0.0.1:3000 AEROSPIKE_ERR_RECORD_NOT_FOUND'
}
let subject = AerospikeError.fromASError(error)
expect(subject.message).to.be('127.0.0.1:3000 Record does not exist in database. May be returned by read, or write with policy Aerospike.policy.exists.UPDATE')
})
it('returns an AerospikeError instance unmodified', function () {
let error = new AerospikeError(-1, 'client error', 'connect', 'lib/client.js', 101)
let error = new AerospikeError('Dooh!')
expect(AerospikeError.fromASError(error)).to.equal(error)
})
it('returns null if the status code is OK', function () {
let error = { code: status.OK }
expect(AerospikeError.fromASError(error)).to.be(null)
})
it('returns null if no error is passed', function () {
expect(AerospikeError.fromASError(null)).to.be(null)
})
})
describe('#isServerError()', function () {
it('returns true if the error code indicates a server error', function () {
let error = { code: status.ERR_RECORD_NOT_FOUND }
let subject = AerospikeError.fromASError(error)
expect(subject.isServerError()).to.be(true)
})
it('returns false if the error code indicates a client error', function () {
let error = { code: status.ERR_PARAM }
let subject = AerospikeError.fromASError(error)
expect(subject.isServerError()).to.be(false)
})
})
describe('#toString()', function () {
it('sets an informative error message', function () {
var subject = new AerospikeError(-1, 'client error', 'connect', 'lib/client.js', 101)
expect(subject.toString()).to.eql('AerospikeError: client error')
let subject = new AerospikeError('Dooh!')
expect(subject.toString()).to.eql('AerospikeError: Dooh!')
})
})
})
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -19,3 +19,4 @@ // Licensed under the Apache License, Version 2.0 (the "License")

/* global expect, describe, it */
/* eslint-env mocha */
/* global expect */

@@ -28,53 +29,55 @@ const Aerospike = require('../lib/aerospike')

describe('Aerospike.GeoJSON', function () {
var subject = new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]})
context('GeoJSON class #noserver', function () {
let subject = new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]})
describe('constructor', function () {
it('returns a new GeoJSON value when called as an Object constructor', function () {
expect(new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]})).to.be.a(GeoJSON)
})
describe('constructor', function () {
it('returns a new GeoJSON value when called as an Object constructor', function () {
expect(new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]})).to.be.a(GeoJSON)
})
it('returns a new GeoJSON value when called as function', function () {
expect(GeoJSON({type: 'Point', coordinates: [103.913, 1.308]})).to.be.a(GeoJSON)
})
it('returns a new GeoJSON value when called as function', function () {
expect(GeoJSON({type: 'Point', coordinates: [103.913, 1.308]})).to.be.a(GeoJSON)
})
it('parses a GeoJSON string', function () {
expect(new GeoJSON('{"type": "Point", "coordinates": [103.913, 1.308]}')).to.be.a(GeoJSON)
})
it('parses a GeoJSON string', function () {
expect(new GeoJSON('{"type": "Point", "coordinates": [103.913, 1.308]}')).to.be.a(GeoJSON)
})
it('throws a type error if passed an invalid GeoJSON value', function () {
let fn = () => new GeoJSON(45)
expect(fn).to.throwException(ex =>
expect(ex).to.be.a(TypeError))
it('throws a type error if passed an invalid GeoJSON value', function () {
let fn = () => new GeoJSON(45)
expect(fn).to.throwException(ex =>
expect(ex).to.be.a(TypeError))
})
})
})
describe('#value()', function () {
it('returns the value as a JSON object', function () {
expect(subject.value()).to.eql({type: 'Point', coordinates: [103.913, 1.308]})
describe('#value()', function () {
it('returns the value as a JSON object', function () {
expect(subject.value()).to.eql({type: 'Point', coordinates: [103.913, 1.308]})
})
})
})
describe('#toJSON()', function () {
it('returns the GeoJSON value as a JSON object', function () {
expect(subject.toJSON()).to.eql({type: 'Point', coordinates: [103.913, 1.308]})
describe('#toJSON()', function () {
it('returns the GeoJSON value as a JSON object', function () {
expect(subject.toJSON()).to.eql({type: 'Point', coordinates: [103.913, 1.308]})
})
})
})
describe('#toString()', function () {
it('returns a string representation of the GeoJSON value', function () {
expect(subject.toString()).to.equal('{"type":"Point","coordinates":[103.913,1.308]}')
describe('#toString()', function () {
it('returns a string representation of the GeoJSON value', function () {
expect(subject.toString()).to.equal('{"type":"Point","coordinates":[103.913,1.308]}')
})
})
})
describe('GeoJSON.Point()', function () {
it('returns the lat, lng as a GeoJSON point value', function () {
var point = new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]})
expect(GeoJSON.Point(103.913, 1.308)).to.eql(point)
describe('GeoJSON.Point()', function () {
it('returns the lat, lng as a GeoJSON point value', function () {
var point = new GeoJSON({type: 'Point', coordinates: [103.913, 1.308]})
expect(GeoJSON.Point(103.913, 1.308)).to.eql(point)
})
})
})
describe('GeoJSON.Polygon()', function () {
it('returns the coordinates as a GeoJSON polygon value', function () {
var polygon = new GeoJSON({type: 'Polygon', coordinates: [[[103.913, 1.308], [104.913, 1.308], [104.913, 1.408], [103.913, 1.408], [103.913, 1.408]]]})
expect(GeoJSON.Polygon([103.913, 1.308], [104.913, 1.308], [104.913, 1.408], [103.913, 1.408], [103.913, 1.408])).to.eql(polygon)
describe('GeoJSON.Polygon()', function () {
it('returns the coordinates as a GeoJSON polygon value', function () {
var polygon = new GeoJSON({type: 'Polygon', coordinates: [[[103.913, 1.308], [104.913, 1.308], [104.913, 1.408], [103.913, 1.408], [103.913, 1.408]]]})
expect(GeoJSON.Polygon([103.913, 1.308], [104.913, 1.308], [104.913, 1.408], [103.913, 1.408], [103.913, 1.408])).to.eql(polygon)
})
})

@@ -81,0 +84,0 @@ })

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -100,2 +100,13 @@ // Licensed under the Apache License, Version 2.0 (the "License")

})
it('fetches a record given the digest', function () {
let key = new Aerospike.Key('test', 'test', 'digestOnly')
client.put(key, {foo: 'bar'})
.then(() => {
let digest = key.digest
let key2 = new Aerospike.Key('test', null, null, digest)
return client.get(key2)
.then(record => expect(record.bins.foo).to.equal('bar'))
})
})
})
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -19,3 +19,4 @@ // Licensed under the Apache License, Version 2.0 (the "License")

/* global expect, beforeEach, afterEach, context, describe, it */
/* eslint-env mocha */
/* global expect */

@@ -28,3 +29,3 @@ const Aerospike = require('../lib/aerospike')

context('secondary indexes', function () {
var client = helper.client
let client = helper.client

@@ -38,33 +39,38 @@ // generate unique index name for each test

})
afterEach(() => helper.index.remove(testIndex.name))
function verifyIndexExists (namespace, indexName, callback) {
var sindex = 'sindex/' + namespace + '/' + indexName
var checkStatus = function (callback) {
return new Promise((resolve, reject) => {
client.infoAll(sindex, function (err, info) {
if (err) {
switch (err.code) {
case Aerospike.status.ERR_INDEX_NOT_FOUND:
resolve(false)
break
default:
reject(err)
}
} else {
resolve(true)
function verifyIndexExists (namespace, indexName) {
let sindex = 'sindex/' + namespace + '/' + indexName
let checkStatus = function () {
return client.infoAll(sindex)
.then(() => true)
.catch(error => {
if (error.code !== Aerospike.status.ERR_INDEX_NOT_FOUND) {
return Promise.reject(error)
}
return false
})
})
}
Job.pollUntilDone(checkStatus, 10)
.then(() => callback())
.catch(error => { throw error })
return Job.pollUntilDone(checkStatus, 10)
.then(() => helper.index.remove(indexName))
}
describe('Client#indexCreate()', function () {
it('should create a complex index on list', function (done) {
var options = {
it('returns an IndexJob instance', function () {
let options = {
ns: helper.namespace,
set: helper.set,
bin: testIndex.bin + 'slkfjslkdfjslkdfjlskdfjslf',
index: testIndex.name,
datatype: Aerospike.indexDataType.NUMERIC
}
return client.createIndex(options)
.then(job => expect(job).to.be.an(IndexJob))
.then(() => verifyIndexExists(helper.namespace, testIndex.name))
})
it('should create a complex index on list', function () {
let options = {
ns: helper.namespace,
set: helper.set,
bin: testIndex.bin,

@@ -75,10 +81,8 @@ index: testIndex.name,

}
client.createIndex(options, function (err, job) {
expect(err).not.to.be.ok()
expect(job).to.be.a(IndexJob)
verifyIndexExists(helper.namespace, testIndex.name, done)
})
return client.createIndex(options)
.then(() => verifyIndexExists(helper.namespace, testIndex.name))
})
it('should create an integer index with info policy', function (done) {
it('should create an integer index with info policy', function () {
let options = {

@@ -95,6 +99,4 @@ ns: helper.namespace,

client.createIndex(options, policy, function (error) {
if (error) throw error
verifyIndexExists(helper.namespace, testIndex.name, done)
})
return client.createIndex(options, policy)
.then(() => verifyIndexExists(helper.namespace, testIndex.name))
})

@@ -110,2 +112,3 @@

}
return client.createIndex(options)

@@ -126,4 +129,4 @@ .then(job => job.wait(10))

describe('Client#createIntegerIndex()', function () {
it('should create an integer index', function (done) {
var options = {
it('should create an integer index', function () {
let options = {
ns: helper.namespace,

@@ -134,6 +137,5 @@ set: helper.set,

}
client.createIntegerIndex(options, function (err) {
expect(err).not.to.be.ok()
verifyIndexExists(helper.namespace, testIndex.name, done)
})
return client.createIntegerIndex(options)
.then(() => verifyIndexExists(helper.namespace, testIndex.name))
})

@@ -143,4 +145,4 @@ })

describe('Client#createStringIndex()', function () {
it('should create an string index', function (done) {
var args = {
it('should create an string index', function () {
let args = {
ns: helper.namespace,

@@ -151,6 +153,5 @@ set: helper.set,

}
client.createStringIndex(args, function (err) {
expect(err).not.to.be.ok()
verifyIndexExists(helper.namespace, testIndex.name, done)
})
return client.createStringIndex(args)
.then(() => verifyIndexExists(helper.namespace, testIndex.name))
})

@@ -160,4 +161,4 @@ })

describe('Client#createGeo2DSphereIndex()', function () {
it('should create a geospatial index', function (done) {
var args = {
it('should create a geospatial index', function () {
let args = {
ns: helper.namespace,

@@ -168,6 +169,5 @@ set: helper.set,

}
client.createGeo2DSphereIndex(args, function (err) {
expect(err).not.to.be.ok()
verifyIndexExists(helper.namespace, testIndex.name, done)
})
return client.createGeo2DSphereIndex(args)
.then(() => verifyIndexExists(helper.namespace, testIndex.name))
})

@@ -174,0 +174,0 @@ })

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -26,3 +26,3 @@ // Licensed under the Apache License, Version 2.0 (the "License")

describe('Key', function () {
describe('Key #noserver', function () {
describe('constructor', function () {

@@ -120,4 +120,2 @@ context('namespace', function () {

context('digest', function () {
var client = helper.client
it('allows creating a new key with just the namespace and digest', function () {

@@ -135,45 +133,3 @@ var digest = Buffer.from([0x15, 0xc7, 0x49, 0xfd, 0x01, 0x54, 0x43, 0x8b, 0xa9, 0xd9, 0x5d, 0x0c, 0x6e, 0x27, 0x0f, 0x1a, 0x76, 0xfc, 0x31, 0x15])

})
it('fetches a record given the digest', function (done) {
var key = new Key('test', 'test', 'digestOnly')
client.put(key, {foo: 'bar'}, function (err) {
if (err) throw err
var digest = key.digest
var key2 = new Key('test', null, null, digest)
client.get(key2, function (err, record) {
if (err) throw err
expect(record.bins.foo).to.equal('bar')
done()
})
})
})
})
context('plain object keys (for backward compatibility)', function () {
var client = helper.client
it('accepts plain objects as user keys', function (done) {
var key = {ns: helper.namespace, set: helper.set, key: 1234}
client.put(key, {foo: 'bar'}, function (err) {
expect(err).to.not.be.ok()
done()
})
})
it('returns an error for an unsupported float user key', function (done) {
var key = {ns: helper.namespace, set: helper.set, key: 3.1415}
client.put(key, {foo: 'bar'}, function (err) {
expect(err.code).to.be(status.ERR_PARAM)
done()
})
})
it('returns an error for an invalid user key', function (done) {
var key = {ns: helper.namespace, set: helper.set, key: {a: 1, b: 2, c: 3}}
client.put(key, {foo: 'bar'}, function (err) {
expect(err.code).to.be(status.ERR_PARAM)
done()
})
})
})
})

@@ -260,1 +216,29 @@

})
context('Plain Object Keys (for backward compatibility)', function () {
var client = helper.client
it('accepts plain objects as user keys', function (done) {
var key = {ns: helper.namespace, set: helper.set, key: 1234}
client.put(key, {foo: 'bar'}, function (err) {
expect(err).to.not.be.ok()
done()
})
})
it('returns an error for an unsupported float user key', function (done) {
var key = {ns: helper.namespace, set: helper.set, key: 3.1415}
client.put(key, {foo: 'bar'}, function (err) {
expect(err.code).to.be(status.ERR_PARAM)
done()
})
})
it('returns an error for an invalid user key', function (done) {
var key = {ns: helper.namespace, set: helper.set, key: {a: 1, b: 2, c: 3}}
client.put(key, {foo: 'bar'}, function (err) {
expect(err.code).to.be(status.ERR_PARAM)
done()
})
})
})
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -19,3 +19,4 @@ // Licensed under the Apache License, Version 2.0 (the "License")

/* global describe, it, expect */
/* eslint-env mocha */
/* global expect */

@@ -25,203 +26,205 @@ const Aerospike = require('../lib/aerospike')

describe('ApplyPolicy', function () {
describe('new ApplyPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.ApplyPolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
gen: Aerospike.policy.gen.EQ,
key: Aerospike.policy.key.SEND,
commitLevel: 2,
ttl: 3600,
durableDelete: true
context('Client Policies #noserver', function () {
describe('ApplyPolicy', function () {
describe('new ApplyPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.ApplyPolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
gen: Aerospike.policy.gen.EQ,
key: Aerospike.policy.key.SEND,
commitLevel: 2,
ttl: 3600,
durableDelete: true
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.gen).to.be(Aerospike.policy.gen.EQ)
expect(subject.key).to.be(Aerospike.policy.key.SEND)
expect(subject.commitLevel).to.be(2)
expect(subject.ttl).to.be(3600)
expect(subject.durableDelete).to.be(true)
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.gen).to.be(Aerospike.policy.gen.EQ)
expect(subject.key).to.be(Aerospike.policy.key.SEND)
expect(subject.commitLevel).to.be(2)
expect(subject.ttl).to.be(3600)
expect(subject.durableDelete).to.be(true)
})
})
})
describe('WritePolicy', function () {
describe('new WritePolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.WritePolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
compressionThreshold: 500,
key: Aerospike.policy.key.SEND,
gen: Aerospike.policy.gen.EQ,
exists: Aerospike.policy.exists.CREATE,
commitLevel: 2,
durableDelete: true
describe('WritePolicy', function () {
describe('new WritePolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.WritePolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
compressionThreshold: 500,
key: Aerospike.policy.key.SEND,
gen: Aerospike.policy.gen.EQ,
exists: Aerospike.policy.exists.CREATE,
commitLevel: 2,
durableDelete: true
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.compressionThreshold).to.be(500)
expect(subject.key).to.be(Aerospike.policy.key.SEND)
expect(subject.gen).to.be(Aerospike.policy.gen.EQ)
expect(subject.exists).to.be(Aerospike.policy.exists.CREATE)
expect(subject.commitLevel).to.be(2)
expect(subject.durableDelete).to.be(true)
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.compressionThreshold).to.be(500)
expect(subject.key).to.be(Aerospike.policy.key.SEND)
expect(subject.gen).to.be(Aerospike.policy.gen.EQ)
expect(subject.exists).to.be(Aerospike.policy.exists.CREATE)
expect(subject.commitLevel).to.be(2)
expect(subject.durableDelete).to.be(true)
})
})
})
describe('ReadPolicy', function () {
describe('new ReadPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.ReadPolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
key: Aerospike.policy.key.SEND,
replica: Aerospike.policy.replica.MASTER,
consistencyLevel: Aerospike.policy.consistencyLevel.ONE
describe('ReadPolicy', function () {
describe('new ReadPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.ReadPolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
key: Aerospike.policy.key.SEND,
replica: Aerospike.policy.replica.MASTER,
consistencyLevel: Aerospike.policy.consistencyLevel.ONE
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.key).to.be(Aerospike.policy.key.SEND)
expect(subject.replica).to.be(Aerospike.policy.replica.MASTER)
expect(subject.consistencyLevel).to.be(Aerospike.policy.consistencyLevel.ONE)
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.key).to.be(Aerospike.policy.key.SEND)
expect(subject.replica).to.be(Aerospike.policy.replica.MASTER)
expect(subject.consistencyLevel).to.be(Aerospike.policy.consistencyLevel.ONE)
})
})
})
describe('BatchPolicy', function () {
describe('new BatchPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.BatchPolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
consistencyLevel: Aerospike.policy.consistencyLevel.ONE,
allowInline: false,
sendSetName: true
describe('BatchPolicy', function () {
describe('new BatchPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.BatchPolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
consistencyLevel: Aerospike.policy.consistencyLevel.ONE,
allowInline: false,
sendSetName: true
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.consistencyLevel).to.be(Aerospike.policy.consistencyLevel.ONE)
expect(subject.allowInline).to.be(false)
expect(subject.sendSetName).to.be(true)
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.consistencyLevel).to.be(Aerospike.policy.consistencyLevel.ONE)
expect(subject.allowInline).to.be(false)
expect(subject.sendSetName).to.be(true)
})
})
})
describe('InfoPolicy', function () {
describe('new InfoPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.InfoPolicy({
totalTimeout: 1000,
sendAsIs: true,
checkBounds: false
describe('InfoPolicy', function () {
describe('new InfoPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.InfoPolicy({
totalTimeout: 1000,
sendAsIs: true,
checkBounds: false
})
expect(subject.totalTimeout).to.be(1000)
expect(subject.sendAsIs).to.be(true)
expect(subject.checkBounds).to.be(false)
})
expect(subject.totalTimeout).to.be(1000)
expect(subject.sendAsIs).to.be(true)
expect(subject.checkBounds).to.be(false)
})
})
})
describe('RemovePolicy', function () {
describe('new RemovePolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.RemovePolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
generation: 1234,
key: Aerospike.policy.key.SEND,
gen: Aerospike.policy.gen.EQ,
commitLevel: 2,
durableDelete: true
describe('RemovePolicy', function () {
describe('new RemovePolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.RemovePolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
generation: 1234,
key: Aerospike.policy.key.SEND,
gen: Aerospike.policy.gen.EQ,
commitLevel: 2,
durableDelete: true
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.generation).to.be(1234)
expect(subject.key).to.be(Aerospike.policy.key.SEND)
expect(subject.gen).to.be(Aerospike.policy.gen.EQ)
expect(subject.commitLevel).to.be(2)
expect(subject.durableDelete).to.be(true)
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.generation).to.be(1234)
expect(subject.key).to.be(Aerospike.policy.key.SEND)
expect(subject.gen).to.be(Aerospike.policy.gen.EQ)
expect(subject.commitLevel).to.be(2)
expect(subject.durableDelete).to.be(true)
})
})
})
describe('OperatePolicy', function () {
describe('new OperatePolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.OperatePolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
key: Aerospike.policy.key.SEND,
gen: Aerospike.policy.gen.EQ,
replica: Aerospike.policy.replica.MASTER,
consistencyLevel: Aerospike.policy.consistencyLevel.ONE,
commitLevel: 2,
durableDelete: true
describe('OperatePolicy', function () {
describe('new OperatePolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.OperatePolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
key: Aerospike.policy.key.SEND,
gen: Aerospike.policy.gen.EQ,
replica: Aerospike.policy.replica.MASTER,
consistencyLevel: Aerospike.policy.consistencyLevel.ONE,
commitLevel: 2,
durableDelete: true
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.key).to.be(Aerospike.policy.key.SEND)
expect(subject.gen).to.be(Aerospike.policy.gen.EQ)
expect(subject.replica).to.be(Aerospike.policy.replica.MASTER)
expect(subject.consistencyLevel).to.be(Aerospike.policy.consistencyLevel.ONE)
expect(subject.commitLevel).to.be(2)
expect(subject.durableDelete).to.be(true)
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.key).to.be(Aerospike.policy.key.SEND)
expect(subject.gen).to.be(Aerospike.policy.gen.EQ)
expect(subject.replica).to.be(Aerospike.policy.replica.MASTER)
expect(subject.consistencyLevel).to.be(Aerospike.policy.consistencyLevel.ONE)
expect(subject.commitLevel).to.be(2)
expect(subject.durableDelete).to.be(true)
})
})
})
describe('ScanPolicy', function () {
describe('new ScanPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.ScanPolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
failOnClusterChange: true,
durableDelete: true
describe('ScanPolicy', function () {
describe('new ScanPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.ScanPolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1,
failOnClusterChange: true,
durableDelete: true
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.failOnClusterChange).to.be(true)
expect(subject.durableDelete).to.be(true)
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
expect(subject.failOnClusterChange).to.be(true)
expect(subject.durableDelete).to.be(true)
})
})
})
describe('QueryPolicy', function () {
describe('new QueryPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.QueryPolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1
describe('QueryPolicy', function () {
describe('new QueryPolicy', function () {
it('sets the policy values from a value object', function () {
let subject = new Aerospike.QueryPolicy({
socketTimeout: 1000,
totalTimeout: 2000,
maxRetries: 1
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
})
expect(subject.socketTimeout).to.be(1000)
expect(subject.totalTimeout).to.be(2000)
expect(subject.maxRetries).to.be(1)
})
})
})

@@ -242,5 +242,4 @@ // *****************************************************************************

it('returns a Promise that resolves to a Job', function () {
let token = valgen.string({length: {min: 10, max: 10}})()
let backgroundScan = client.scan(helper.namespace, testSet)
return backgroundScan.background('udf', 'updateRecord', ['x', token])
return backgroundScan.background('udf', 'noop')
.then(job => {

@@ -247,0 +246,0 @@ expect(job).to.be.a(Job)

// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -23,5 +23,7 @@ // Licensed under the Apache License, Version 2.0 (the "License")

const options = require('./util/options')
const semver = require('./util/semver')
const expect = require('expect.js')
const util = require('util')
const path = require('path')
const runInNewProcessFn = require('./util/run_in_new_process')

@@ -120,3 +122,3 @@ global.expect = expect

ServerInfoHelper.prototype.build_gte = function (minVer) {
return semverCmp(this.build, minVer) >= 0
return semver.compare(this.build, minVer) >= 0
}

@@ -175,8 +177,18 @@

/* global before */
before(() => client.connect()
.then(() => serverInfoHelper.fetch_info())
.then(() => serverInfoHelper.fetch_namespace_config(options.namespace))
)
exports.runInNewProcess = function (fn, timeout) {
let env = {
NODE_PATH: path.join(process.cwd(), 'node_modules'),
AEROSPIKE_HOSTS: client.config.hosts
}
return runInNewProcessFn(fn, timeout, env)
}
if (process.env.GLOBAL_CLIENT !== 'false') {
/* global before */
before(() => client.connect()
.then(() => serverInfoHelper.fetch_info())
.then(() => serverInfoHelper.fetch_namespace_config(options.namespace))
)
}
/* global after */

@@ -187,15 +199,1 @@ after(function (done) {

})
function semverCmp (a, b) {
var pa = a.split('.')
var pb = b.split('.')
for (var i = 0; i < 4; i++) {
var na = Number(pa[i])
var nb = Number(pb[i])
if (na > nb) return 1
if (nb > na) return -1
if (!isNaN(na) && isNaN(nb)) return 1
if (isNaN(na) && !isNaN(nb)) return -1
}
return 0
}
// *****************************************************************************
// Copyright 2013-2017 Aerospike, Inc.
// Copyright 2013-2018 Aerospike, Inc.
//

@@ -24,3 +24,3 @@ // Licensed under the Apache License, Version 2.0 (the "License")

describe('utils.parseHostString()', function () {
describe('utils.parseHostString() #noserver', function () {
it('parses a domain name', function () {

@@ -93,3 +93,3 @@ var host = utils.parseHostString('aero.local')

describe('utils.parseHostsString()', function () {
describe('utils.parseHostsString() #noserver', function () {
it('parses a comma separate list of hosts', function () {

@@ -96,0 +96,0 @@ var hosts = utils.parseHostsString('aero.local:aero.tls:3000,192.168.33.10:3000,[fde4:8dba:82e1::c4]')

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 too big to display

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc