From f1c19550e4e359df3fe7b0848b61141e41cdd02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Czech?= Date: Fri, 21 Nov 2025 16:38:23 +0100 Subject: [PATCH 1/2] Update client options passing Instead of extending client options after converting them to rust options, we extend them with default values before that. There were some inconsistencies in handling some default values that are fix in this PR. --- lib/client-options.js | 6 ++++-- lib/client.js | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/client-options.js b/lib/client-options.js index 9391e8f5c..ef8ac503b 100644 --- a/lib/client-options.js +++ b/lib/client-options.js @@ -664,7 +664,9 @@ function setRustOptions(options) { rustOptions.applicationName = options.applicationName; rustOptions.applicationVersion = options.applicationVersion; rustOptions.keyspace = options.keyspace; - rustOptions.cacheSize = options.maxPrepared; + if (rustOptions.cacheSize) { + rustOptions.cacheSize = options.maxPrepared; + } if (options.credentials) { rustOptions.credentialsUsername = options.credentials.username; rustOptions.credentialsPassword = options.credentials.password; @@ -672,7 +674,7 @@ function setRustOptions(options) { if (options.authProvider instanceof auth.PlainTextAuthProvider) { rustOptions.credentialsUsername = options.authProvider.username; rustOptions.credentialsPassword = options.authProvider.password; - } else { + } else if (!(options.authProvider instanceof auth.NoAuthProvider)) { throw new errors.ArgumentError( // TODO: Add support for other auth providers "Unsupported auth provider: " + options.authProvider, diff --git a/lib/client.js b/lib/client.js index 42b62cae9..2ee0c3dbc 100644 --- a/lib/client.js +++ b/lib/client.js @@ -49,13 +49,14 @@ class Client extends events.EventEmitter { */ constructor(options) { super(); - this.rustOptions = clientOptions.setRustOptions(options); - /** @type {clientOptions.ClientOptions} */ this.options = clientOptions.extend( { logEmitter: this.emit.bind(this), id: types.Uuid.random() }, options, ); + + this.rustOptions = clientOptions.setRustOptions(this.options); + Object.defineProperty(this, "profileManager", { value: new ProfileManager(this.options), }); From 51c92ed100ae3764100f921a9a42a4453707357a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Czech?= Date: Fri, 21 Nov 2025 13:17:29 +0100 Subject: [PATCH 2/2] Add support for client ID Compared to the DSx driver, this supports ids both as uuid and strings. When uuid is provided, it's converted to string, as this is how client id is represented in the Rust driver. --- lib/client-options.js | 9 ++++++--- src/session.rs | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/client-options.js b/lib/client-options.js index ef8ac503b..074afa2e6 100644 --- a/lib/client-options.js +++ b/lib/client-options.js @@ -46,10 +46,9 @@ const errors = require("./errors.js"); * * @property {String} [credentials.username] The username to use for plain-text authentication. * @property {String} [credentials.password] The password to use for plain-text authentication. - * @property {Uuid} [id] A unique identifier assigned to a {@link Client} object, that will be communicated to the - * server (DSE 6.0+) to identify the client instance created with this options. When not defined, the driver will + * @property {Uuid | string} [id] A unique identifier assigned to a {@link Client} object, that will be communicated to the + * server to identify the client instance created with this options. When not defined, the driver will * generate a random identifier. - * [TODO: Add support for this field] * @property {String} [applicationName] An optional setting identifying the name of the application using * the {@link Client} instance. * @@ -663,6 +662,10 @@ function setRustOptions(options) { rustOptions.connectPoints = options.contactPoints; rustOptions.applicationName = options.applicationName; rustOptions.applicationVersion = options.applicationVersion; + if (options.id instanceof types.Uuid) { + options.id = options.id.toString(); + } + rustOptions.clientId = options.id; rustOptions.keyspace = options.keyspace; if (rustOptions.cacheSize) { rustOptions.cacheSize = options.maxPrepared; diff --git a/src/session.rs b/src/session.rs index bb87a6c34..1bfc90ed6 100644 --- a/src/session.rs +++ b/src/session.rs @@ -32,6 +32,7 @@ define_js_to_rust_convertible_object!(SessionOptions { keyspace, keyspace: String, application_name, applicationName: String, application_version, applicationVersion: String, + client_id, clientId: String, credentials_username, credentialsUsername: String, credentials_password, credentialsPassword: String, cache_size, cacheSize: u32, @@ -359,5 +360,8 @@ fn self_identity(options: &SessionOptions) -> SelfIdentity<'static> { if let Some(app_version) = &options.application_name { self_identity.set_application_version(app_version.clone()); } + if let Some(client_id) = &options.client_id { + self_identity.set_client_id(client_id.to_owned()); + } self_identity }