Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/client-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const {
AddressTranslator,
} = require("./policies/address-resolution.js");

// Imports for the purpose of type hints in JS docs.
// eslint-disable-next-line no-unused-vars
const { ExecutionProfile } = require("./execution-profile.js");

/**
* Client options.
*
Expand Down Expand Up @@ -220,7 +224,6 @@ const {
*
* Note, that using Integer as Varint (`useBigIntAsVarint == false`) is deprecated.
* @property {Array.<ExecutionProfile>} [profiles] The array of [execution profiles]{@link ExecutionProfile}.
* [TODO: Add support for this field]
* @property {Function} [promiseFactory] Function to be used to create a `Promise` from a
* callback-style function.
*
Expand Down
112 changes: 56 additions & 56 deletions lib/execution-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,12 @@
const utils = require("./utils");
const types = require("./types");
const promiseUtils = require("./promise-utils");
const { throwNotSupported } = require("./new-utils");

/**
* Creates a new instance of {@link ExecutionProfile}.
* @classdesc
* Represents a set configurations to be used in a statement execution to be used for a single {@link Client} instance.
*
* An {@link ExecutionProfile} instance should not be shared across different {@link Client} instances.
* @param {String} name Name of the execution profile.
*
* Use `'default'` to specify that the new instance should be the default {@link ExecutionProfile} if no
* profile is specified in the execution.
* @param {Object} [options] Profile options, when any of the options is not specified the {@link Client} will the use
* the ones defined in the default profile.
* @param {Number} [options.consistency] The consistency level to use for this profile.
* @param {LoadBalancingPolicy} [options.loadBalancing] The load-balancing policy to use for this profile.
* @param {Number} [options.readTimeout] The client per-host request timeout to use for this profile.
* @param {RetryPolicy} [options.retry] The retry policy to use for this profile.
* @param {Number} [options.serialConsistency] The serial consistency level to use for this profile.
* @param {LoadBalancingPolicy} [options.loadBalancing] The load-balancing policy to use for this profile.
* @param {Number} [options.readTimeout] The client per-host request timeout to use for this profile.
* @param {RetryPolicy} [options.retry] The retry policy to use for this profile.
* @param {Number} [options.serialConsistency] The serial consistency level to use for this profile.
* @example
* const { Client, ExecutionProfile } = require('cassandra-driver');
* const client = new Client({
Expand All @@ -38,48 +22,64 @@ const promiseUtils = require("./promise-utils");
* });
*
* client.execute(query, params, { executionProfile: 'metrics-oltp' }, callback);
* @constructor
*/
function ExecutionProfile(name, options) {
if (typeof name !== "string") {
throw new TypeError("Execution profile name must be a string");
}
options = options || utils.emptyObject;
/**
* Name of the execution profile.
* @type {String}
*/
this.name = name;
/**
* Consistency level.
* @type {Number}
*/
this.consistency = options.consistency;
/**
* Load-balancing policy
* @type {LoadBalancingPolicy}
*/
this.loadBalancing = options.loadBalancing;
/**
* Client read timeout.
* @type {Number}
*/
this.readTimeout = options.readTimeout;
/**
* Retry policy.
* @type {RetryPolicy}
*/
this.retry = options.retry;
/**
* Serial consistency level.
* @type {Number}
*/
this.serialConsistency = options.serialConsistency;
class ExecutionProfile {
/**
* Legacy field
* @type {undefined}
* @param {String} name Name of the execution profile.
* Use `'default'` to specify that the new instance should be the default {@link ExecutionProfile} if no
* profile is specified in the execution.
* @param {Object} [options] Profile options, when any of the options is not specified the {@link Client} will the use
* the ones defined in the default profile.
* @param {Number} [options.consistency] The consistency level to use for this profile.
* @param {LoadBalancingPolicy} [options.loadBalancing] The load-balancing policy to use for this profile.
* @param {Number} [options.readTimeout] The client per-host request timeout to use for this profile.
* @param {RetryPolicy} [options.retry] The retry policy to use for this profile.
* @param {Number} [options.serialConsistency] The serial consistency level to use for this profile.
* @param {LoadBalancingPolicy} [options.loadBalancing] The load-balancing policy to use for this profile.
* @param {Number} [options.readTimeout] The client per-host request timeout to use for this profile.
* @param {RetryPolicy} [options.retry] The retry policy to use for this profile.
* @param {Number} [options.serialConsistency] The serial consistency level to use for this profile.
*/
this.graphOptions = undefined;
constructor(name, options) {
if (typeof name !== "string") {
throw new TypeError("Execution profile name must be a string");
}
options = options || utils.emptyObject;
/**
* Name of the execution profile.
* @type {String}
*/
this.name = name;
/**
* Consistency level.
* @type {Number}
*/
this.consistency = options.consistency;
/**
* Load-balancing policy
* @type {LoadBalancingPolicy}
*/
this.loadBalancing = options.loadBalancing;
/**
* Client read timeout.
* @type {Number}
*/
this.readTimeout = options.readTimeout;
/**
* Retry policy.
* @type {RetryPolicy}
*/
this.retry = options.retry;
/**
* Serial consistency level.
* @type {Number}
*/
this.serialConsistency = options.serialConsistency;

if (options.graphOptions !== undefined) {
throwNotSupported("Graph options");
}
}
}

/**
Expand Down
Loading
Loading