How to use the aerospike.connect function in aerospike

To help you get started, we’ve selected a few aerospike examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aerospike / aerospike-client-nodejs / examples / range_remove.js View on Github external
log: {
    level: argv['log-level'],
    file: argv['log-file'] ? fs.openSync(argv['log-file'], 'a') : 2
  },
  policies: {
    timeout: argv.timeout
  },
  user: argv.user,
  password: argv.password
}

// *****************************************************************************
// Perform the operation
// *****************************************************************************

Aerospike.connect(config, function (err, client) {
  if (err) {
    console.error('Error: Aerospike server connection error. ', err.message)
    process.exit(1)
  }

  //
  // Perform the operation
  //

  const maxConcurrent = 200
  var inFlight = 0

  function removeDone (client, start, end, skip) {
    var total = end - start + 1
    var done = 0
    var success = 0
github aerospike / aerospike-client-nodejs / examples / range_get.js View on Github external
log: {
    level: argv['log-level'],
    file: argv['log-file'] ? fs.openSync(argv['log-file'], 'a') : 2
  },
  policies: {
    timeout: argv.timeout
  },
  user: argv.user,
  password: argv.password
}

// *****************************************************************************
// Perform the operation
// *****************************************************************************

Aerospike.connect(config, function (err, client) {
  if (err) {
    console.error('Error: Aerospike server connection error. ', err.message)
    process.exit(1)
  }

  //
  // Perform the operation
  //

  const maxConcurrent = 200
  var inFlight = 0

  function getDone (client, start, end, skip) {
    var total = end - start + 1
    var done = 0
    var success = 0
github aerospike / aerospike-client-nodejs / examples / range_validate.js View on Github external
log: {
    level: argv['log-level'],
    file: argv['log-file'] ? fs.openSync(argv['log-file'], 'a') : 2
  },
  policies: {
    timeout: argv.timeout
  },
  user: argv.user,
  password: argv.password
}

// *****************************************************************************
// Perform the operation
// *****************************************************************************

Aerospike.connect(config, function (err, client) {
  if (err) {
    console.error('Error: Aerospike server connection error. ', err.message)
    process.exit(1)
  }

  //
  // Perform the operation
  //

  const maxConcurrent = 200
  var inFlight = 0

  function putDone (client, start, end) {
    var total = end - start + 1
    var done = 0
    var timeLabel = 'range_put @ ' + total
github aerospike / aerospike-client-nodejs / examples / scan_info.js View on Github external
user: argv.user,
  password: argv.password
}

// *****************************************************************************
// Perform the operation
// *****************************************************************************

function run (client, done) {
  client.query(argv.namespace, argv.set).info(scanId, function (res) {
    !argv.quiet && console.log(JSON.stringify(res, null, '    '))
    done()
  })
}

Aerospike.connect(config, function (err, client) {
  if (err) throw err
  run(client, function () {
    client.close()
  })
})
github aerospike / aerospike-client-nodejs / examples / scan_background.js View on Github external
},
  policies: {
    timeout: argv.timeout
  },
  modllua: {
    userPath: __dirname
  },
  user: argv.user,
  password: argv.password
}

// *****************************************************************************
// Establish a connection to the cluster.
// *****************************************************************************

Aerospike.connect(config, function (err, client) {
  if (err) throw err

  var scan = client.query(argv.namespace, argv.set)
  scan.background('scan', 'updateRecord', function (error, job) {
    if (error) throw error

    var timer = setInterval(function () {
      job.info((error, info) => {
        if (error) {
          console.info('Error checking background scan status:', error)
          clearInterval(timer)
          client.close()
        } else if (info.status === Aerospike.jobStatus.COMPLETED) {
          console.info('Scan completed')
          clearInterval(timer)
          client.close()
github aerospike / aerospike-client-nodejs / examples / llist.js View on Github external
password: argv.password
}

// *****************************************************************************
// Perform the operation
// *****************************************************************************

var checkError = function (err, msg) {
  if (err) {
    console.error(err)
  } else {
    console.log(msg)
  }
}

Aerospike.connect(config, function (err, client) {
  if (err) throw err

  // Get a largelist object from client.
  var listkey = new Aerospike.Key(argv.namespace, argv.set, 'ldt_list_key')
  var policy = { timeout: 1000 }
  var list = client.LargeList(listkey, 'ldt_list_bin', policy)

  // perform all the largelist operations.

  // add single value to the list.
  var val = 'listvalsingle'
  list.add(val, function (err, val) {
    checkError(err, 'Added a single value')
  })

  // update single value added to the list.
github aerospike / aerospike-client-nodejs / examples / udf_register.js View on Github external
// *****************************************************************************
// Perform the operation
// *****************************************************************************

function run (client, done) {
  client.udfRegister(file, function (err, job) {
    if (err) throw err
    job.waitUntilDone(function (err) {
      if (err) throw err
      !argv.quiet && console.log('UDF module registered successfully: %s', file)
      done()
    })
  })
}

Aerospike.connect(config, function (err, client) {
  if (err) throw err
  run(client, function () {
    client.close()
  })
})
github aerospike / aerospike-client-nodejs / examples / udf_remove.js View on Github external
// *****************************************************************************
// Perform the operation
// *****************************************************************************

function run (client, done) {
  client.udfRemove(module, function (err, job) {
    if (err) throw err
    job.waitUntilDone(function (err) {
      if (err) throw err
      !argv.quiet && console.log('UDF module removed successfully: %s', module)
      done()
    })
  })
}

Aerospike.connect(config, function (err, client) {
  if (err) throw err
  run(client, function () {
    client.close()
  })
})
github aerospike / aerospike-client-nodejs / examples / range_exists.js View on Github external
log: {
    level: argv['log-level'],
    file: argv['log-file'] ? fs.openSync(argv['log-file'], 'a') : 2
  },
  policies: {
    timeout: argv.timeout
  },
  user: argv.user,
  password: argv.password
}

// *****************************************************************************
// Perform the operation
// *****************************************************************************

Aerospike.connect(config, function (err, client) {
  if (err) throw err

  //
  // Perform the operation
  //

  const maxConcurrent = 200
  var inFlight = 0

  function existsDone (client, start, end, skip) {
    var total = end - start + 1
    var done = 0
    var success = 0
    var notfound = 0
    var failure = 0
    var skipped = 0
github aerospike / aerospike-client-nodejs / examples / query_geospatial.js View on Github external
return removeIndex(client, done)
  }

  var key = new Key(argv.namespace, argv.set, ndx)

  client.remove(key, function (err, key) {
    if (err && err.code !== status.ERR_RECORD_NOT_FOUND) throw err
    removeRecords(client, ndx + 1, end, done)
  })
}

function cleanup (client, done) {
  removeRecords(client, 0, numberOfRecords, done)
}

Aerospike.connect(config, function (err, client) {
  if (err) throw err
  createIndex(client, function () {
    client.close()
  })
})