Type alias AstraAdminBlockingOptions

Overview

Options controlling the blocking behavior of certain admin operations.

Some admin operations require repeatedly polling the database's status to check if said operation is complete. These operations may be long- or short-running, but they are not instantaneous.

By default, these operations block until completion, with a method-defined polling interval that can be overridden.

Alternatively, you can opt for non-blocking behavior, in which case the operation returns immediately, leaving it up to the caller to manually determine completion.


Blocking

When blocking is true (default), the operation will not return until it is fully complete. Completion is determined by polling the database's status at a regular interval.

You can customize the polling interval using the pollInterval option (in milliseconds).

Example

// Will block by default until the operation is complete.
const dbAdmin1 = await admin.createDatabase({ ... });

// Blocks with a custom poll interval (e.g. every 5 seconds).
const dbAdmin2 = await admin.createDatabase({ ... }, {
pollInterval: 5000,
});

Non-blocking

When blocking is false, the operation returns immediately after initiating the request. It becomes your responsibility to check when the operation has completed.

Important: In this mode, resources will still not be usable until the operation finishes.

For instance:

  • createDatabase returns an AstraDbAdmin object, but it won’t point to an active database until creation is complete.
  • createKeyspace won't actually allow you to use that keyspace until the database is back to active.

Example

// Will return immediately without waiting for operation completion
//
// The AstraDbAdmin object is still returned, but it's not very useful
// until the operation completes.
const dbAdmin3 = await admin.createDatabase({...}, {
blocking: false,
});

Field

blocking - Whether to block the operation until it is complete (default: true)

Field

pollInterval - The interval (in milliseconds) at which to poll the operation for completion (optional)