diff --git a/Cargo.toml b/Cargo.toml index 7fc77dd4..85cf8838 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,6 @@ arrow-array = "42.0" arrow-data = "42.0" arrow-schema = "42.0" arrow-ipc = "42.0" -half = { "version" = "2.2.1", default-features = false } +half = { "version" = "=2.2.1", default-features = false } object_store = "0.6.1" diff --git a/node/src/index.ts b/node/src/index.ts index 887aaa8c..e475e21a 100644 --- a/node/src/index.ts +++ b/node/src/index.ts @@ -44,6 +44,9 @@ export interface ConnectionOptions { apiKey?: string // Region to connect region?: string + + // override the host for the remote connections + hostOverride?: string } /** diff --git a/node/src/remote/client.ts b/node/src/remote/client.ts index 64b22a8d..289f378b 100644 --- a/node/src/remote/client.ts +++ b/node/src/remote/client.ts @@ -19,7 +19,11 @@ import { tableFromIPC, type Table as ArrowTable } from 'apache-arrow' export class HttpLancedbClient { private readonly _url: string - public constructor (url: string, private readonly _apiKey: string) { + public constructor ( + url: string, + private readonly _apiKey: string, + private readonly _dbName?: string + ) { this._url = url } @@ -49,7 +53,8 @@ export class HttpLancedbClient { { headers: { 'Content-Type': 'application/json', - 'x-api-key': this._apiKey + 'x-api-key': this._apiKey, + ...(this._dbName !== undefined ? { 'x-lancedb-database': this._dbName } : {}) }, responseType: 'arraybuffer', timeout: 10000 diff --git a/node/src/remote/index.ts b/node/src/remote/index.ts index 4c1a81a4..4078a04d 100644 --- a/node/src/remote/index.ts +++ b/node/src/remote/index.ts @@ -37,8 +37,13 @@ export class RemoteConnection implements Connection { } this._dbName = opts.uri.slice('db://'.length) - const server = `https://${this._dbName}.${opts.region}.api.lancedb.com` - this._client = new HttpLancedbClient(server, opts.apiKey) + let server: string + if (opts.hostOverride === undefined) { + server = `https://${this._dbName}.${opts.region}.api.lancedb.com` + } else { + server = opts.hostOverride + } + this._client = new HttpLancedbClient(server, opts.apiKey, opts.hostOverride === undefined ? undefined : this._dbName) } get uri (): string {