@valkey/valkey-glide 1.3.5-rc8 → 2.0.0-rc5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -7
- package/build-ts/BaseClient.d.ts +85 -18
- package/build-ts/BaseClient.js +288 -246
- package/build-ts/Batch.d.ts +6 -6
- package/build-ts/Batch.js +230 -230
- package/build-ts/Commands.d.ts +14 -2
- package/build-ts/Commands.js +24 -12
- package/build-ts/Errors.js +1 -0
- package/build-ts/GlideClient.d.ts +7 -38
- package/build-ts/GlideClient.js +56 -55
- package/build-ts/GlideClusterClient.d.ts +12 -4
- package/build-ts/GlideClusterClient.js +60 -54
- package/build-ts/Logger.d.ts +30 -15
- package/build-ts/Logger.js +36 -24
- package/build-ts/OpenTelemetry.d.ts +101 -0
- package/build-ts/OpenTelemetry.js +134 -0
- package/build-ts/ProtobufMessage.d.ts +18 -84
- package/build-ts/ProtobufMessage.js +52 -184
- package/build-ts/index.d.ts +2 -2
- package/build-ts/index.js +2 -25
- package/build-ts/native.d.ts +158 -14
- package/build-ts/native.js +134 -105
- package/build-ts/server-modules/GlideFt.d.ts +1 -4
- package/build-ts/server-modules/GlideFt.js +10 -11
- package/build-ts/server-modules/GlideFtOptions.d.ts +1 -2
- package/build-ts/server-modules/GlideJson.d.ts +3 -5
- package/build-ts/server-modules/GlideJson.js +2 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -27,23 +27,30 @@ Refer to the [Supported Engine Versions table](https://github.com/valkey-io/valk
|
|
|
27
27
|
|
|
28
28
|
The release of Valkey GLIDE was tested on the following platforms:
|
|
29
29
|
|
|
30
|
-
Linux
|
|
30
|
+
### Linux GNU
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
- Amazon Linux 2023 (AL2023) (x86_64/amd64 and arm64/aarch64)
|
|
32
|
+
Linux with **glibc 2.17** or higher.
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
### MacOS (Darwin)
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
- macOS 13.7 (x86_64/amd64)
|
|
36
|
+
MacOS Apple Silicon/aarch_64 and x86_64/amd64.
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
- Full tests are running on MacOS 15.0 arm64/aarch64
|
|
39
|
+
- Minimal tests are running on: MacOS 13.5 x86*64/amd64*(We do not recommend using MacOS Intel for production, It is supported for development purposes)\_
|
|
40
|
+
|
|
41
|
+
### Alpine
|
|
42
|
+
|
|
43
|
+
All alpine versions that are using _musl libc_ 1.2.3 (All Alpine non deprecated alpine versions) or higher should be supported.
|
|
44
|
+
Tests are running on:
|
|
41
45
|
|
|
42
46
|
- node:alpine (x86_64/amd64 and arm64/aarch64)
|
|
43
47
|
|
|
44
48
|
## NodeJS supported version
|
|
45
49
|
|
|
46
50
|
Node.js 16 or higher.
|
|
51
|
+
**For npm users on linux it is recommended to use npm >=11 since it support optional download base on libc, yarn users should not be concerned**
|
|
52
|
+
|
|
53
|
+
- Note: The library is dependent on the [protobufjs library](https://protobufjs.github.io/protobuf.js/#installation), which add a size to the package. The package is using the protobufjs/minimal version, hence, if size matter, bundlers should be able to strip the unused code. It should reduce the size of the dependency from 19kb gzipped to 6.5kb gzipped.
|
|
47
54
|
|
|
48
55
|
### Building & Testing
|
|
49
56
|
|
|
@@ -75,6 +82,8 @@ const client = await GlideClient.createClient({
|
|
|
75
82
|
addresses: addresses,
|
|
76
83
|
// if the server uses TLS, you'll need to enable it. Otherwise, the connection attempt will time out silently.
|
|
77
84
|
// useTLS: true,
|
|
85
|
+
// It is recommended to set a timeout for your specific use case
|
|
86
|
+
requestTimeout: 500, // 500ms timeout
|
|
78
87
|
clientName: "test_standalone_client",
|
|
79
88
|
});
|
|
80
89
|
// The empty array signifies that there are no additional arguments.
|
|
@@ -102,6 +111,8 @@ const client = await GlideClusterClient.createClient({
|
|
|
102
111
|
addresses: addresses,
|
|
103
112
|
// if the cluster nodes use TLS, you'll need to enable it. Otherwise the connection attempt will time out silently.
|
|
104
113
|
// useTLS: true,
|
|
114
|
+
// It is recommended to set a timeout for your specific use case
|
|
115
|
+
requestTimeout: 500, // 500ms timeout
|
|
105
116
|
clientName: "test_cluster_client",
|
|
106
117
|
});
|
|
107
118
|
// The empty array signifies that there are no additional arguments.
|
package/build-ts/BaseClient.d.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { Buffer, Writer } from "protobufjs/minimal";
|
|
2
|
-
import {
|
|
3
|
-
import { AggregationType, BaseScanOptions, BatchOptions, BitFieldGet, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { AggregationType, BaseScanOptions, BitFieldGet, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
3
|
BitFieldSubCommands, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
-
BitOffsetOptions, BitwiseOperation, Boundary,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
RangeByIndex, RangeByLex, RangeByScore, RestoreOptions, ScoreFilter, SearchOrigin, SetOptions, SortOptions, StreamAddOptions, StreamClaimOptions, StreamGroupOptions, StreamPendingOptions, StreamReadGroupOptions, StreamReadOptions, StreamTrimOptions, TimeUnit, ZAddOptions, ZScanOptions } from "./Commands";
|
|
9
|
-
import { ConnectionError, RequestError, ValkeyError } from "./Errors";
|
|
10
|
-
import { GlideClientConfiguration } from "./GlideClient";
|
|
11
|
-
import { GlideClusterClientConfiguration, Routes } from "./GlideClusterClient";
|
|
12
|
-
import { Script } from "./native";
|
|
4
|
+
BitOffsetOptions, BitwiseOperation, Boundary, ConnectionError, ExpireOptions, GeoAddOptions, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
GeoSearchResultOptions, GeoSearchShape, GeoSearchStoreResultOptions, GeoUnit, GeospatialData, GlideClientConfiguration, GlideClusterClientConfiguration, HScanOptions, InsertPosition, KeyWeight, LPosOptions, ListDirection, RangeByIndex, RangeByLex, RangeByScore, RequestError, RestoreOptions, Routes, ScoreFilter, Script, SearchOrigin, SetOptions, SortOptions, StreamAddOptions, StreamClaimOptions, StreamGroupOptions, StreamPendingOptions, StreamReadGroupOptions, StreamReadOptions, StreamTrimOptions, TimeUnit, ValkeyError, ZAddOptions, ZScanOptions } from ".";
|
|
6
|
+
import { command_request, connection_request, response } from "../build-ts/ProtobufMessage";
|
|
13
7
|
type PromiseFunction = (value?: any) => void;
|
|
14
8
|
type ErrorFunction = (error: ValkeyError) => void;
|
|
15
9
|
export type ReturnTypeRecord = {
|
|
@@ -154,6 +148,8 @@ export type ReadFrom =
|
|
|
154
148
|
* ### Security Settings
|
|
155
149
|
*
|
|
156
150
|
* - **TLS**: Enable secure communication using `useTLS`.
|
|
151
|
+
* Should match the TLS configuration of the server/cluster, otherwise the connection attempt will fail.
|
|
152
|
+
* For advanced tls configuration, , see {@link AdvancedBaseClientConfiguration}.
|
|
157
153
|
* - **Authentication**: Provide `credentials` to authenticate with the server.
|
|
158
154
|
*
|
|
159
155
|
* ### Communication Settings
|
|
@@ -181,6 +177,14 @@ export type ReadFrom =
|
|
|
181
177
|
*
|
|
182
178
|
* - **Inflight Requests Limit**: Control the number of concurrent requests using `inflightRequestsLimit`.
|
|
183
179
|
*
|
|
180
|
+
* ### Reconnection Strategy
|
|
181
|
+
* - **Reconnection Strategy**: Customize how the client should attempt reconnections using `connectionBackoff`.
|
|
182
|
+
* - `numberOfRetries`: The maximum number of retry attempts with increasing delays.
|
|
183
|
+
* - After this limit is reached, the retry interval becomes constant.
|
|
184
|
+
* - `factor`: A multiplier applied to the base delay between retries (e.g., `500` means a 500ms base delay).
|
|
185
|
+
* - `exponentBase`: The exponential growth factor for delays (e.g., `2` means the delay doubles with each retry).
|
|
186
|
+
* - `jitterPercent`: An optional percentage of jitter to add to the delay (e.g., `30` means the final delay will vary randomly between 70% and 130% of the calculated delay).
|
|
187
|
+
*
|
|
184
188
|
* @example
|
|
185
189
|
* ```typescript
|
|
186
190
|
* const config: BaseClientConfiguration = {
|
|
@@ -200,6 +204,12 @@ export type ReadFrom =
|
|
|
200
204
|
* clientAz: 'us-east-1a',
|
|
201
205
|
* defaultDecoder: Decoder.String,
|
|
202
206
|
* inflightRequestsLimit: 1000,
|
|
207
|
+
* connectionBackoff: {
|
|
208
|
+
* numberOfRetries: 10, // Maximum retries before delay becomes constant
|
|
209
|
+
* factor: 500, // Base delay in milliseconds
|
|
210
|
+
* exponentBase: 2, // Delay doubles with each retry (2^N)
|
|
211
|
+
* jitterPercent: 20, // Optional jitter percentage
|
|
212
|
+
* },
|
|
203
213
|
* };
|
|
204
214
|
* ```
|
|
205
215
|
*/
|
|
@@ -239,7 +249,7 @@ export interface BaseClientConfiguration {
|
|
|
239
249
|
credentials?: ServerCredentials;
|
|
240
250
|
/**
|
|
241
251
|
* The duration in milliseconds that the client should wait for a request to complete.
|
|
242
|
-
* This duration encompasses sending the request, awaiting for a response from the server, and any required
|
|
252
|
+
* This duration encompasses sending the request, awaiting for a response from the server, and any required reconnection or retries.
|
|
243
253
|
* If the specified timeout is exceeded for a pending request, it will result in a timeout error.
|
|
244
254
|
* If not explicitly set, a default value of 250 milliseconds will be used.
|
|
245
255
|
* Value must be an integer.
|
|
@@ -285,6 +295,37 @@ export interface BaseClientConfiguration {
|
|
|
285
295
|
* ```
|
|
286
296
|
*/
|
|
287
297
|
clientAz?: string;
|
|
298
|
+
/**
|
|
299
|
+
* Strategy used to determine how and when to reconnect, in case of connection failures.
|
|
300
|
+
* The time between attempts grows exponentially, following the formula rand(0 ... factor * (exponentBase ^ N)), where N is the number of failed attempts,
|
|
301
|
+
* and rand(...) applies a jitter of up to `jitterPercent`% to introduce randomness and reduce retry storms.
|
|
302
|
+
* The client will attempt to reconnect indefinitely. Once the maximum value is reached, that will remain the time between retry attempts until a
|
|
303
|
+
* reconnect attempt is successful.
|
|
304
|
+
* If not set, a default backoff strategy will be used.
|
|
305
|
+
*/
|
|
306
|
+
connectionBackoff?: {
|
|
307
|
+
/**
|
|
308
|
+
* Number of retry attempts that the client should perform when disconnected from the server, where the time between retries increases.
|
|
309
|
+
* Once the retries have reached the maximum value, the time between retries will remain constant until a reconnect attempt is succesful.
|
|
310
|
+
* Value must be an integer.
|
|
311
|
+
*/
|
|
312
|
+
numberOfRetries: number;
|
|
313
|
+
/**
|
|
314
|
+
* The multiplier that will be applied to the waiting time between each retry.
|
|
315
|
+
* Value must be an integer.
|
|
316
|
+
*/
|
|
317
|
+
factor: number;
|
|
318
|
+
/**
|
|
319
|
+
* The exponent base configured for the strategy.
|
|
320
|
+
* Value must be an integer.
|
|
321
|
+
*/
|
|
322
|
+
exponentBase: number;
|
|
323
|
+
/** The Jitter percent on the calculated duration.
|
|
324
|
+
* If not set, a default value will be used.
|
|
325
|
+
* Value is optional, and must be an integer.
|
|
326
|
+
*/
|
|
327
|
+
jitterPercent?: number;
|
|
328
|
+
};
|
|
288
329
|
}
|
|
289
330
|
/**
|
|
290
331
|
* Represents advanced configuration settings for a client, including connection-related options.
|
|
@@ -296,6 +337,10 @@ export interface BaseClientConfiguration {
|
|
|
296
337
|
*
|
|
297
338
|
* - **Connection Timeout**: The `connectionTimeout` property specifies the duration (in milliseconds) the client should wait for a connection to be established.
|
|
298
339
|
*
|
|
340
|
+
* ### TLS config
|
|
341
|
+
*
|
|
342
|
+
* - **TLS Configuration**: The `tlsAdvancedConfiguration` property allows for advanced TLS settings, such as enabling insecure mode.
|
|
343
|
+
*
|
|
299
344
|
* @example
|
|
300
345
|
* ```typescript
|
|
301
346
|
* const config: AdvancedBaseClientConfiguration = {
|
|
@@ -306,11 +351,33 @@ export interface BaseClientConfiguration {
|
|
|
306
351
|
export interface AdvancedBaseClientConfiguration {
|
|
307
352
|
/**
|
|
308
353
|
* The duration in milliseconds to wait for a TCP/TLS connection to complete.
|
|
309
|
-
* This applies both during initial client creation and any
|
|
354
|
+
* This applies both during initial client creation and any reconnection that may occur during request processing.
|
|
310
355
|
* **Note**: A high connection timeout may lead to prolonged blocking of the entire command pipeline.
|
|
311
|
-
* If not explicitly set, a default value of
|
|
356
|
+
* If not explicitly set, a default value of 2000 milliseconds will be used.
|
|
312
357
|
*/
|
|
313
358
|
connectionTimeout?: number;
|
|
359
|
+
/**
|
|
360
|
+
* The advanced TLS configuration settings. This allows for more granular control of TLS behavior,
|
|
361
|
+
* such as enabling an insecure mode that bypasses certificate validation.
|
|
362
|
+
*/
|
|
363
|
+
tlsAdvancedConfiguration?: {
|
|
364
|
+
/**
|
|
365
|
+
* Whether to bypass TLS certificate verification.
|
|
366
|
+
*
|
|
367
|
+
* - When set to `true`, the client skips certificate validation.
|
|
368
|
+
* This is useful when connecting to servers or clusters using self-signed certificates,
|
|
369
|
+
* or when DNS entries (e.g., CNAMEs) don't match certificate hostnames.
|
|
370
|
+
*
|
|
371
|
+
* - This setting is typically used in development or testing environments.
|
|
372
|
+
* **It is strongly discouraged in production**, as it introduces security risks such as man-in-the-middle attacks.
|
|
373
|
+
*
|
|
374
|
+
* - Only valid if TLS is already enabled in the base client configuration.
|
|
375
|
+
* Enabling it without TLS will result in a `ConfigurationError`.
|
|
376
|
+
*
|
|
377
|
+
* - Default: false (verification is enforced).
|
|
378
|
+
*/
|
|
379
|
+
insecure?: boolean;
|
|
380
|
+
};
|
|
314
381
|
}
|
|
315
382
|
/**
|
|
316
383
|
* Enum of Valkey data types
|
|
@@ -334,7 +401,6 @@ export interface PubSubMsg {
|
|
|
334
401
|
channel: GlideString;
|
|
335
402
|
pattern?: GlideString | null;
|
|
336
403
|
}
|
|
337
|
-
export type WritePromiseOptions = BaseOptions | (BaseOptions & (ClusterBatchOptions | BatchOptions));
|
|
338
404
|
/**
|
|
339
405
|
* Base client interface for GLIDE
|
|
340
406
|
*/
|
|
@@ -355,6 +421,7 @@ export declare class BaseClient {
|
|
|
355
421
|
protected configurePubsub(options: GlideClusterClientConfiguration | GlideClientConfiguration, configuration: connection_request.IConnectionRequest): void;
|
|
356
422
|
private handleReadData;
|
|
357
423
|
protected toProtobufRoute(route: Routes | undefined): command_request.Routes | undefined;
|
|
424
|
+
private dropCommandSpan;
|
|
358
425
|
processResponse(message: response.Response): void;
|
|
359
426
|
processPush(response: response.Response): void;
|
|
360
427
|
protected getCallbackIndex(): number;
|
|
@@ -4219,16 +4286,16 @@ export declare class BaseClient {
|
|
|
4219
4286
|
* @param key - The key of the HyperLogLog data structure to add elements into.
|
|
4220
4287
|
* @param elements - An array of members to add to the HyperLogLog stored at `key`.
|
|
4221
4288
|
* @returns - If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is
|
|
4222
|
-
* altered, then returns `
|
|
4289
|
+
* altered, then returns `true`. Otherwise, returns `false`.
|
|
4223
4290
|
* @example
|
|
4224
4291
|
* ```typescript
|
|
4225
4292
|
* const result = await client.pfadd("hll_1", ["a", "b", "c"]);
|
|
4226
|
-
* console.log(result); // Output:
|
|
4293
|
+
* console.log(result); // Output: true - Indicates that a data structure was created or modified
|
|
4227
4294
|
* const result = await client.pfadd("hll_2", []);
|
|
4228
|
-
* console.log(result); // Output:
|
|
4295
|
+
* console.log(result); // Output: true - Indicates that a new empty data structure was created
|
|
4229
4296
|
* ```
|
|
4230
4297
|
*/
|
|
4231
|
-
pfadd(key: GlideString, elements: GlideString[]): Promise<
|
|
4298
|
+
pfadd(key: GlideString, elements: GlideString[]): Promise<boolean>;
|
|
4232
4299
|
/** Estimates the cardinality of the data stored in a HyperLogLog structure for a single key or
|
|
4233
4300
|
* calculates the combined cardinality of multiple keys by merging their HyperLogLogs temporarily.
|
|
4234
4301
|
*
|