Was this page helpful?
Global Functions and Constants¶
Members¶
(constant) INITIAL_FRAME_SIZE
The buffer size of a new FrameWriter.
Source
(constant) Integer
Source
Deprecated
Integer is deprecated. See `./types/integer.ts`
(constant) MAX_FRAME_VALUES
Largest value count that the [short] count of a frame can hold.
Source
(constant) MAX_RETAINED_FRAME_SIZE
A FrameWriter keeps its buffer between frames up to this size. After a larger frame, it starts again with a small buffer.
Source
(constant) VIntCoding
Contains the methods for reading and writing vints into binary format. Exposes only 2 internal methods, the rest are hidden.
Source
(constant) _maxValue
Highest value of the ring, and its inclusive end.
Source
(constant) _minToken
The token the ring starts at, exclusively, and ends at, inclusively: the range ]minToken, minToken] covers the whole ring.
Source
(constant) _minValue
Lowest value of the ring: not a valid token, but the exclusive start of the ring.
Source
(constant) _ringLength
Number of values the ring spans, used to wrap around its end.
Source
(constant) coreConnectionsPerHostV2
Core connections per host for protocol versions 1 and 2
(constant) coreConnectionsPerHostV3
Core connections per host for protocol version 3 and above
(constant) loggingFinalizationRegistry
FinalizationRegistry that ensures the Rust logging callback is unregistered when a Client instance is garbage-collected without being explicitly shut down.
While in general FinalizationRegistry usage is discouraged, we use it here to avoid blocking the client from being cleaned up, once it's no longer used by the user, and also clean up all the resources in the process. This justifies using finalization registry, despite heavy warnings against it in the documentation.
To understand more, check the JS documentation. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry
Source
(constant) maxInt
Max int that can be accurately represented with 64-bit Number (2^53)
Source
(constant) maxRequestsPerConnectionV2
Default maxRequestsPerConnection value for protocol v1 and v2
(constant) maxRequestsPerConnectionV3
Default maxRequestsPerConnection value for protocol v3+
Methods¶
_split(start, end, numberOfSplits)
Splits the range ]start, end] into numberOfSplits parts of equal "size" (referring to the
number of tokens, not the actual amount of data), returning the tokens the parts are split at.
Parameters:
| Name | Type | Description |
|---|---|---|
start |
Starting token. |
|
end |
End token. |
|
numberOfSplits |
Number of splits to make. |
Source
Returns:
The numberOfSplits - 1 points the range is split at.
adaptNamedParamsPrepared()
Adapts the parameters based on the prepared metadata. This function assumes params are passed as an associative array (Object), and it adapts the object into an array with the same order as bound parameters in the prepared statement.
Source
Throws:
-
In case a parameter with a specific name is not defined.
- Type
- Error
Returns:
Returns an array of parameters.
adaptNamedParamsWithHints()
Adapts the associative-array of parameters and hints for simple statements into Arrays based on the (arbitrary) position of the keys.
Source
Returns:
Returns an array of parameters and the keys as an associative array.
arbitraryValueToBigInt()
Ensure the value is one of the accepted numeric types, and convert them to BigInt.
Source
arrayIterator()
Uses the iterator protocol to go through the items of the Array
Source
asDouble()
Deprecated
Not supported by the driver. Usage will throw an error.
asFloat()
Deprecated
Not supported by the driver. Usage will throw an error.
asInt()
Deprecated
Not supported by the driver. Usage will throw an error.
asTimestamp()
Deprecated
Not supported by the driver. Usage will throw an error.
asUdt()
Deprecated
Not supported by the driver. Usage will throw an error.
bigintToLong()
Converts from bigint provided by napi into Long type. BigInt is the way napi handles values too big for js Number type, while Long is the legacy way the code handles 64-bit integers.
Source
binarySearch(key)
Searches the specified Array for the provided key using the binary search algorithm. The Array must be sorted.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
Source
Returns:
The position of the key in the Array, if it is found. If it is not found, it returns a negative number which is the bitwise complement of the index of the first element that is larger than key.
callbackOnce()
Source
Returns:
Returns a wrapper function that invokes the underlying callback only once.
convertComplexType()
Convert rust ComplexType into type representation used in the driver encoder
convertTlsVersion()
According to the TS type definition, SecureVersion (the value we are handling here), can be one of the following: type SecureVersion = "TLSv1.3" | "TLSv1.2" | "TLSv1.1" | "TLSv1";
copyBuffer()
Creates a copy of a buffer
Source
deepExtend()
Extends the target by the most inner props of sources
Source
delay()
Creates a non-clearable timer that resolves the promise once elapses.
ensure32SignedInteger(number, name)
Checks whether the number is a 32 bit signed integer. Throws an error, when a value that cannot be represented as i32 is passed.
Parameters:
| Name | Type | Description |
|---|---|---|
number |
||
name |
used in the thrown error |
Source
Throws:
ensure64SignedInteger(number, name)
Checks whether the number is a 64 bit signed integer. Throws an error, when a value that cannot be represented as i64 is passed.
Parameters:
| Name | Type | Description |
|---|---|---|
number |
||
name |
used in the thrown error |
Source
Throws:
extend(baseOptions)
Extends and validates the user options
Parameters:
| Name | Type | Description |
|---|---|---|
baseOptions |
The source object instance that will be overridden |
extend()
Merge the contents of two or more objects together into the first object. Similar to jQuery.extend / Object.assign.
The main difference between this method is that declared properties with an undefined value are not set
to the target.
Source
fixStack()
Appends the original stack trace to the error after a tick of the event loop
Source
fromCallback()
Creates a Promise from a callback based function.
fromEvent()
Creates a Promise that gets resolved or rejected based on an event.
getCallback()
Gets a function that has the signature of a callback that invokes the appropriate promise handler parameters.
getRowsFromResultsWrapper(columnsCache)
Simple way of getting results from rust driver. Calls the driver, decoding the whole page at once.
Parameters:
| Name | Type | Description |
|---|---|---|
columnsCache |
Converted columns of the prepared handle that produced the result, when available. |
Returns:
Returns array of rows if the result is of the RowsResult kind, and undefined otherwise
hostIdToString()
Derives the hex string representation of a host id from a host id's raw bytes.
Source
ifUndefined()
Returns the first not undefined param
Source
ifUndefined3()
Returns the first not undefined param
Source
insertSorted(item)
Inserts the value in the position determined by its natural order determined by the compare func
Parameters:
| Name | Type | Description |
|---|---|---|
item |
Source
isNamedParameters()
Returns true when params is a named (object) parameter set rather than an array.
Source
Throws:
-
In case params are of unexpected type
- Type
- ArgumentError
iteratorToArray(iterator)
Convert the iterator values into an array
Parameters:
| Name | Type | Description |
|---|---|---|
iterator |
Source
log(furtherInfoopt)
Uses the logEmitter to emit log events.
Respects the logLevel option — events below the configured severity are suppressed.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
furtherInfo |
<optional> |
Source
newQueryPlan(lbp, keyspace, executionOptions)
Invokes the new query plan of the load balancing policy and returns a Promise.
Parameters:
| Name | Type | Description |
|---|---|---|
lbp |
The load balancing policy. |
|
keyspace |
Name of currently logged keyspace at |
|
executionOptions |
The information related to the execution of the request. |
normalizeKey(name)
Normalizes a key that can be either a string or a buffer into a string.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
Name of the option being normalized, used for error messages |
normalizePagingState()
This function normalizes the type, and combines all possible page state sources.
Page state can come from two sources:
- pageState variable: when we execute the following page of the query
- execOptions: when the user start a new query from requested state
PageState has a priority over execOptions, as execOptions.pageState will not be cleared for the following pages of the execution.
Source
normalizeSslOptions()
Normalizes SSL options to be passed to the Rust layer. The SslOptions class can have values as multiple types, while the Rust code expects a specific format. We could do this at the napi layer by trying all accepted types until we successfully convert it, but we can also convert it here.
objectValues()
Returns an array containing the values of the Object, similar to Object.values(). If obj is null or undefined, it will return an empty array.
Source
optionalCallback()
Method that handles optional callbacks (dual promise and callback support). When callback is undefined it returns the promise. When using a callback, it will use it as handlers of the continuation of the promise.
promiseWrapper()
Wraps the callback-based method. When no originalCallback is not defined, it returns a Promise.
Source
rejectUnsupportedReadTimeout()
Rejects legacy timeout settings that would otherwise be silently ignored. Only socketOptions.readTimeout may retain its built-in 12000 ms default; query and execution-profile settings have no such default.
Source
series()
Similar to async.series(), but instead accumulating the result in an Array, it callbacks with the result of the last function in the array.
Source
setMetadataDependent()
Sets the default options that depend on the protocol version and other metadata.
socketAddressToString()
Returns the string representation of a given socket address.
Source
stringRepeat()
Returns a string with a value repeated n times
Source
throwNotSupported(name)
Internal utility for marking not supported endpoints.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
Source
Throws:
times()
Invokes the provided function multiple times, considering the concurrency level limit.
toBackground()
Deals with unexpected rejections in order to avoid the unhandled promise rejection warning or failure.
toCallback()
Invokes the callback once outside the promise chain the promise is resolved or rejected.
toLowerCaseProperties()
Returns a new object with the property names set to lowercase.
Source
totalLength()
Gets the sum of the length of the items of an array
Source
validateFn(fn, name)
Validates the provided parameter is of type function.
Parameters:
| Name | Type | Description |
|---|---|---|
fn |
The instance to validate. |
|
name |
Name of the function to use in the error message. Defaults to 'callback'. |
Source
validateRequestTimeout()
Validates a request timeout before it crosses the N-API boundary as an i32.
undefined means that the caller should use the next value in the option
precedence chain.
Source