Job

Job

Potentially long-running background job.

Constructor

new Job()

Source:
See:

Methods

info(policyopt, callbackopt) → (nullable) {Promise}

Check the progress of a background job running on the database.

Source:
Example
const Aerospike = require('aerospike')

// INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
var config = {
  hosts: '192.168.33.10:3000',
  // Timeouts disabled, latency dependent on server location. Configure as needed.
  policies: {
    scan : new Aerospike.ScanPolicy({socketTimeout : 0, totalTimeout : 0}),
  }
}
Aerospike.connect(config, (error, client) => {
  if (error) throw error

  var scan = client.scan('test', 'demo')
  scan.background('myUdfModule', 'myUdfFunction', (error, job) => {
    if (error) throw error
    var timer = setInterval(() => {
      job.info((error, info) => {
        if (error) throw error
        console.info('scan status: %d (%d%% complete, %d records scanned)', info.status, info.progressPct, info.recordsRead)
        if (info.status === Aerospike.jobStatus.COMPLETED) {
          console.info('scan completed!')
          clearInterval(timer)
          client.close()
        }
      })
    }, 1000)
  })
})
Parameters:
Name Type Attributes Description
policy Client~InfoPolicy <optional>

The Info Policy to use for this operation.

callback JobinfoCallback <optional>

The function to call with the job info response.

Returns:

If no callback function is passed, the function returns a Promise that resolves to the job info.

Type
Promise

wait(pollIntervalopt, callbackopt) → (nullable) {Promise}

Wait until the task has been completed.

Source:
Parameters:
Name Type Attributes Default Description
pollInterval number <optional>
1000

Interval in milliseconds to use when polling the cluster nodes.

callback JobdoneCallback <optional>

The function to call when the task has completed.

Returns:

If no callback function is passed, the function returns a Promise that resolves once the job is completed.

Type
Promise