@valkey/valkey-glide 1.3.5-rc9 → 2.0.0-rc7
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 +125 -22
- package/build-ts/BaseClient.js +293 -250
- package/build-ts/Batch.d.ts +10 -10
- package/build-ts/Batch.js +234 -234
- 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 +22 -82
- package/build-ts/ProtobufMessage.js +59 -176
- 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 = {
|
|
@@ -150,10 +144,13 @@ export type ReadFrom =
|
|
|
150
144
|
* - **Addresses**: Use the `addresses` property to specify the hostnames and ports of the server(s) to connect to.
|
|
151
145
|
* - **Cluster Mode**: In cluster mode, the client will discover other nodes based on the provided addresses.
|
|
152
146
|
* - **Standalone Mode**: In standalone mode, only the provided nodes will be used.
|
|
147
|
+
* - **Lazy Connect**: Set `lazyConnect` to `true` to defer connection establishment until the first command is sent.
|
|
153
148
|
*
|
|
154
149
|
* ### Security Settings
|
|
155
150
|
*
|
|
156
151
|
* - **TLS**: Enable secure communication using `useTLS`.
|
|
152
|
+
* Should match the TLS configuration of the server/cluster, otherwise the connection attempt will fail.
|
|
153
|
+
* For advanced tls configuration, , see {@link AdvancedBaseClientConfiguration}.
|
|
157
154
|
* - **Authentication**: Provide `credentials` to authenticate with the server.
|
|
158
155
|
*
|
|
159
156
|
* ### Communication Settings
|
|
@@ -181,6 +178,14 @@ export type ReadFrom =
|
|
|
181
178
|
*
|
|
182
179
|
* - **Inflight Requests Limit**: Control the number of concurrent requests using `inflightRequestsLimit`.
|
|
183
180
|
*
|
|
181
|
+
* ### Reconnection Strategy
|
|
182
|
+
* - **Reconnection Strategy**: Customize how the client should attempt reconnections using `connectionBackoff`.
|
|
183
|
+
* - `numberOfRetries`: The maximum number of retry attempts with increasing delays.
|
|
184
|
+
* - After this limit is reached, the retry interval becomes constant.
|
|
185
|
+
* - `factor`: A multiplier applied to the base delay between retries (e.g., `500` means a 500ms base delay).
|
|
186
|
+
* - `exponentBase`: The exponential growth factor for delays (e.g., `2` means the delay doubles with each retry).
|
|
187
|
+
* - `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).
|
|
188
|
+
*
|
|
184
189
|
* @example
|
|
185
190
|
* ```typescript
|
|
186
191
|
* const config: BaseClientConfiguration = {
|
|
@@ -200,6 +205,13 @@ export type ReadFrom =
|
|
|
200
205
|
* clientAz: 'us-east-1a',
|
|
201
206
|
* defaultDecoder: Decoder.String,
|
|
202
207
|
* inflightRequestsLimit: 1000,
|
|
208
|
+
* connectionBackoff: {
|
|
209
|
+
* numberOfRetries: 10, // Maximum retries before delay becomes constant
|
|
210
|
+
* factor: 500, // Base delay in milliseconds
|
|
211
|
+
* exponentBase: 2, // Delay doubles with each retry (2^N)
|
|
212
|
+
* jitterPercent: 20, // Optional jitter percentage
|
|
213
|
+
* },
|
|
214
|
+
* lazyConnect: true,
|
|
203
215
|
* };
|
|
204
216
|
* ```
|
|
205
217
|
*/
|
|
@@ -239,7 +251,7 @@ export interface BaseClientConfiguration {
|
|
|
239
251
|
credentials?: ServerCredentials;
|
|
240
252
|
/**
|
|
241
253
|
* 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
|
|
254
|
+
* This duration encompasses sending the request, awaiting for a response from the server, and any required reconnection or retries.
|
|
243
255
|
* If the specified timeout is exceeded for a pending request, it will result in a timeout error.
|
|
244
256
|
* If not explicitly set, a default value of 250 milliseconds will be used.
|
|
245
257
|
* Value must be an integer.
|
|
@@ -285,6 +297,71 @@ export interface BaseClientConfiguration {
|
|
|
285
297
|
* ```
|
|
286
298
|
*/
|
|
287
299
|
clientAz?: string;
|
|
300
|
+
/**
|
|
301
|
+
* Strategy used to determine how and when to reconnect, in case of connection failures.
|
|
302
|
+
* The time between attempts grows exponentially, following the formula rand(0 ... factor * (exponentBase ^ N)), where N is the number of failed attempts,
|
|
303
|
+
* and rand(...) applies a jitter of up to `jitterPercent`% to introduce randomness and reduce retry storms.
|
|
304
|
+
* The client will attempt to reconnect indefinitely. Once the maximum value is reached, that will remain the time between retry attempts until a
|
|
305
|
+
* reconnect attempt is successful.
|
|
306
|
+
* If not set, a default backoff strategy will be used.
|
|
307
|
+
*/
|
|
308
|
+
connectionBackoff?: {
|
|
309
|
+
/**
|
|
310
|
+
* Number of retry attempts that the client should perform when disconnected from the server, where the time between retries increases.
|
|
311
|
+
* Once the retries have reached the maximum value, the time between retries will remain constant until a reconnect attempt is succesful.
|
|
312
|
+
* Value must be an integer.
|
|
313
|
+
*/
|
|
314
|
+
numberOfRetries: number;
|
|
315
|
+
/**
|
|
316
|
+
* The multiplier that will be applied to the waiting time between each retry.
|
|
317
|
+
* Value must be an integer.
|
|
318
|
+
*/
|
|
319
|
+
factor: number;
|
|
320
|
+
/**
|
|
321
|
+
* The exponent base configured for the strategy.
|
|
322
|
+
* Value must be an integer.
|
|
323
|
+
*/
|
|
324
|
+
exponentBase: number;
|
|
325
|
+
/** The Jitter percent on the calculated duration.
|
|
326
|
+
* If not set, a default value will be used.
|
|
327
|
+
* Value is optional, and must be an integer.
|
|
328
|
+
*/
|
|
329
|
+
jitterPercent?: number;
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* Enables lazy connection mode, where physical connections to the server(s) are deferred
|
|
333
|
+
* until the first command is sent. This can reduce startup latency and allow for client
|
|
334
|
+
* creation in disconnected environments.
|
|
335
|
+
*
|
|
336
|
+
* - **Default**: `false` – connections are established immediately during client creation.
|
|
337
|
+
*
|
|
338
|
+
* @remarks
|
|
339
|
+
* When `lazyConnect` is set to `true`, the client will not attempt to connect to the specified
|
|
340
|
+
* nodes during initialization. Instead, connections will be established only when a command is
|
|
341
|
+
* actually executed.
|
|
342
|
+
*
|
|
343
|
+
* Note that the first command executed with lazy connections may experience additional latency
|
|
344
|
+
* as it needs to establish the connection first. During this initial connection, the standard
|
|
345
|
+
* request timeout does not apply yet - instead, the connection establishment is governed by
|
|
346
|
+
* `AdvancedBaseClientConfiguration::connectionTimeout`. The request timeout (`requestTimeout`)
|
|
347
|
+
* only begins counting after the connection has been successfully established. This behavior
|
|
348
|
+
* can effectively increase the total time needed for the first command to complete.
|
|
349
|
+
*
|
|
350
|
+
* This setting applies to both standalone and cluster modes. Note that if an operation is
|
|
351
|
+
* attempted and connection fails (e.g., unreachable nodes), errors will surface at that point.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```typescript
|
|
355
|
+
* const client = await GlideClient.createClient({
|
|
356
|
+
* addresses: [{ host: "localhost", port: 6379 }],
|
|
357
|
+
* lazyConnect: true
|
|
358
|
+
* });
|
|
359
|
+
*
|
|
360
|
+
* // No connection is made yet
|
|
361
|
+
* await client.ping(); // Now the client connects and sends the command
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
lazyConnect?: boolean;
|
|
288
365
|
}
|
|
289
366
|
/**
|
|
290
367
|
* Represents advanced configuration settings for a client, including connection-related options.
|
|
@@ -296,6 +373,10 @@ export interface BaseClientConfiguration {
|
|
|
296
373
|
*
|
|
297
374
|
* - **Connection Timeout**: The `connectionTimeout` property specifies the duration (in milliseconds) the client should wait for a connection to be established.
|
|
298
375
|
*
|
|
376
|
+
* ### TLS config
|
|
377
|
+
*
|
|
378
|
+
* - **TLS Configuration**: The `tlsAdvancedConfiguration` property allows for advanced TLS settings, such as enabling insecure mode.
|
|
379
|
+
*
|
|
299
380
|
* @example
|
|
300
381
|
* ```typescript
|
|
301
382
|
* const config: AdvancedBaseClientConfiguration = {
|
|
@@ -306,11 +387,33 @@ export interface BaseClientConfiguration {
|
|
|
306
387
|
export interface AdvancedBaseClientConfiguration {
|
|
307
388
|
/**
|
|
308
389
|
* The duration in milliseconds to wait for a TCP/TLS connection to complete.
|
|
309
|
-
* This applies both during initial client creation and any
|
|
390
|
+
* This applies both during initial client creation and any reconnection that may occur during request processing.
|
|
310
391
|
* **Note**: A high connection timeout may lead to prolonged blocking of the entire command pipeline.
|
|
311
|
-
* If not explicitly set, a default value of
|
|
392
|
+
* If not explicitly set, a default value of 2000 milliseconds will be used.
|
|
312
393
|
*/
|
|
313
394
|
connectionTimeout?: number;
|
|
395
|
+
/**
|
|
396
|
+
* The advanced TLS configuration settings. This allows for more granular control of TLS behavior,
|
|
397
|
+
* such as enabling an insecure mode that bypasses certificate validation.
|
|
398
|
+
*/
|
|
399
|
+
tlsAdvancedConfiguration?: {
|
|
400
|
+
/**
|
|
401
|
+
* Whether to bypass TLS certificate verification.
|
|
402
|
+
*
|
|
403
|
+
* - When set to `true`, the client skips certificate validation.
|
|
404
|
+
* This is useful when connecting to servers or clusters using self-signed certificates,
|
|
405
|
+
* or when DNS entries (e.g., CNAMEs) don't match certificate hostnames.
|
|
406
|
+
*
|
|
407
|
+
* - This setting is typically used in development or testing environments.
|
|
408
|
+
* **It is strongly discouraged in production**, as it introduces security risks such as man-in-the-middle attacks.
|
|
409
|
+
*
|
|
410
|
+
* - Only valid if TLS is already enabled in the base client configuration.
|
|
411
|
+
* Enabling it without TLS will result in a `ConfigurationError`.
|
|
412
|
+
*
|
|
413
|
+
* - Default: false (verification is enforced).
|
|
414
|
+
*/
|
|
415
|
+
insecure?: boolean;
|
|
416
|
+
};
|
|
314
417
|
}
|
|
315
418
|
/**
|
|
316
419
|
* Enum of Valkey data types
|
|
@@ -334,7 +437,6 @@ export interface PubSubMsg {
|
|
|
334
437
|
channel: GlideString;
|
|
335
438
|
pattern?: GlideString | null;
|
|
336
439
|
}
|
|
337
|
-
export type WritePromiseOptions = BaseOptions | (BaseOptions & (ClusterBatchOptions | BatchOptions));
|
|
338
440
|
/**
|
|
339
441
|
* Base client interface for GLIDE
|
|
340
442
|
*/
|
|
@@ -355,6 +457,7 @@ export declare class BaseClient {
|
|
|
355
457
|
protected configurePubsub(options: GlideClusterClientConfiguration | GlideClientConfiguration, configuration: connection_request.IConnectionRequest): void;
|
|
356
458
|
private handleReadData;
|
|
357
459
|
protected toProtobufRoute(route: Routes | undefined): command_request.Routes | undefined;
|
|
460
|
+
private dropCommandSpan;
|
|
358
461
|
processResponse(message: response.Response): void;
|
|
359
462
|
processPush(response: response.Response): void;
|
|
360
463
|
protected getCallbackIndex(): number;
|
|
@@ -1531,7 +1634,7 @@ export declare class BaseClient {
|
|
|
1531
1634
|
* @param start - The starting point of the range.
|
|
1532
1635
|
* @param end - The end of the range.
|
|
1533
1636
|
* @returns always "OK".
|
|
1534
|
-
* If `start` exceeds the end of the list, or if `start` is greater than `end`, the
|
|
1637
|
+
* If `start` exceeds the end of the list, or if `start` is greater than `end`, the list is emptied and the key is removed.
|
|
1535
1638
|
* If `end` exceeds the actual end of the list, it will be treated like the last element of the list.
|
|
1536
1639
|
* If `key` does not exist the command will be ignored.
|
|
1537
1640
|
*
|
|
@@ -1544,12 +1647,12 @@ export declare class BaseClient {
|
|
|
1544
1647
|
*/
|
|
1545
1648
|
ltrim(key: GlideString, start: number, end: number): Promise<"OK">;
|
|
1546
1649
|
/** Removes the first `count` occurrences of elements equal to `element` from the list stored at `key`.
|
|
1547
|
-
* If `count` is positive : Removes elements equal to `element` moving from head to tail.
|
|
1548
|
-
* If `count` is negative : Removes elements equal to `element` moving from tail to head.
|
|
1549
|
-
* If `count` is 0 or `count` is greater than the occurrences of elements equal to `element`: Removes all elements equal to `element`.
|
|
1550
1650
|
*
|
|
1551
1651
|
* @param key - The key of the list.
|
|
1552
1652
|
* @param count - The count of the occurrences of elements equal to `element` to remove.
|
|
1653
|
+
* If `count` is positive : Removes elements equal to `element` moving from head to tail.
|
|
1654
|
+
* If `count` is negative : Removes elements equal to `element` moving from tail to head.
|
|
1655
|
+
* If `count` is 0 or `count` is greater than the occurrences of elements equal to `element`: Removes all elements equal to `element`.
|
|
1553
1656
|
* @param element - The element to remove from the list.
|
|
1554
1657
|
* @returns the number of the removed elements.
|
|
1555
1658
|
* If `key` does not exist, 0 is returned.
|
|
@@ -4219,16 +4322,16 @@ export declare class BaseClient {
|
|
|
4219
4322
|
* @param key - The key of the HyperLogLog data structure to add elements into.
|
|
4220
4323
|
* @param elements - An array of members to add to the HyperLogLog stored at `key`.
|
|
4221
4324
|
* @returns - If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is
|
|
4222
|
-
* altered, then returns `
|
|
4325
|
+
* altered, then returns `true`. Otherwise, returns `false`.
|
|
4223
4326
|
* @example
|
|
4224
4327
|
* ```typescript
|
|
4225
4328
|
* const result = await client.pfadd("hll_1", ["a", "b", "c"]);
|
|
4226
|
-
* console.log(result); // Output:
|
|
4329
|
+
* console.log(result); // Output: true - Indicates that a data structure was created or modified
|
|
4227
4330
|
* const result = await client.pfadd("hll_2", []);
|
|
4228
|
-
* console.log(result); // Output:
|
|
4331
|
+
* console.log(result); // Output: true - Indicates that a new empty data structure was created
|
|
4229
4332
|
* ```
|
|
4230
4333
|
*/
|
|
4231
|
-
pfadd(key: GlideString, elements: GlideString[]): Promise<
|
|
4334
|
+
pfadd(key: GlideString, elements: GlideString[]): Promise<boolean>;
|
|
4232
4335
|
/** Estimates the cardinality of the data stored in a HyperLogLog structure for a single key or
|
|
4233
4336
|
* calculates the combined cardinality of multiple keys by merging their HyperLogLogs temporarily.
|
|
4234
4337
|
*
|