@valkey/valkey-glide 2.2.6 → 2.3.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 +1 -2
- package/build-ts/BaseClient.d.ts +5 -5
- package/build-ts/BaseClient.js +9 -6
- package/build-ts/Batch.d.ts +5 -5
- package/build-ts/Batch.js +5 -5
- package/build-ts/Commands.js +6 -2
- package/build-ts/GlideClient.d.ts +22 -4
- package/build-ts/GlideClient.js +8 -4
- package/build-ts/GlideClusterClient.d.ts +5 -5
- package/build-ts/GlideClusterClient.js +5 -5
- package/build-ts/OpenTelemetry.d.ts +104 -16
- package/build-ts/OpenTelemetry.js +172 -20
- package/build-ts/ProtobufMessage.d.ts +131 -1
- package/build-ts/ProtobufMessage.js +317 -2
- package/build-ts/native.d.ts +5 -0
- package/build-ts/native.js +2 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -14,8 +14,7 @@ Valkey General Language Independent Driver for the Enterprise (GLIDE) is the off
|
|
|
14
14
|
|
|
15
15
|
## Documentation
|
|
16
16
|
|
|
17
|
-
See GLIDE's [documentation site](https://valkey.io/
|
|
18
|
-
Visit our [wiki](https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper) for examples and further details on TLS, Read strategy, Timeouts and various other configurations.
|
|
17
|
+
See GLIDE's Node.js [documentation site](https://glide.valkey.io/languages/nodejs).
|
|
19
18
|
|
|
20
19
|
## Supported Engine Versions
|
|
21
20
|
|
package/build-ts/BaseClient.d.ts
CHANGED
|
@@ -2265,7 +2265,7 @@ export declare class BaseClient {
|
|
|
2265
2265
|
*
|
|
2266
2266
|
* @see {@link https://valkey.io/commands/blmove/|valkey.io} for details.
|
|
2267
2267
|
* @remarks When in cluster mode, both `source` and `destination` must map to the same hash slot.
|
|
2268
|
-
* @remarks `BLMOVE` is a client blocking command, see {@link https://
|
|
2268
|
+
* @remarks `BLMOVE` is a client blocking command, see {@link https://glide.valkey.io/how-to/connection-management/#blocking-commands|Valkey GLIDE Documentation} for more details and best practices.
|
|
2269
2269
|
* @remarks Since Valkey version 6.2.0.
|
|
2270
2270
|
*
|
|
2271
2271
|
* @param source - The key to the source list.
|
|
@@ -5248,7 +5248,7 @@ export declare class BaseClient {
|
|
|
5248
5248
|
*
|
|
5249
5249
|
* @see {@link https://valkey.io/commands/brpop/|valkey.io} for more details.
|
|
5250
5250
|
* @remarks When in cluster mode, all `keys` must map to the same hash slot.
|
|
5251
|
-
* @remarks `BRPOP` is a blocking command, see [Blocking Commands](https://
|
|
5251
|
+
* @remarks `BRPOP` is a blocking command, see [Blocking Commands](https://glide.valkey.io/how-to/connection-management/#blocking-commands) for more details and best practices.
|
|
5252
5252
|
*
|
|
5253
5253
|
* @param keys - The `keys` of the lists to pop from.
|
|
5254
5254
|
* @param timeout - The `timeout` in seconds.
|
|
@@ -5273,7 +5273,7 @@ export declare class BaseClient {
|
|
|
5273
5273
|
*
|
|
5274
5274
|
* @see {@link https://valkey.io/commands/blpop/|valkey.io} for more details.
|
|
5275
5275
|
* @remarks When in cluster mode, all `keys` must map to the same hash slot.
|
|
5276
|
-
* @remarks `BLPOP` is a blocking command, see [Blocking Commands](https://
|
|
5276
|
+
* @remarks `BLPOP` is a blocking command, see [Blocking Commands](https://glide.valkey.io/how-to/connection-management/#blocking-commands) for more details and best practices.
|
|
5277
5277
|
*
|
|
5278
5278
|
* @param keys - The `keys` of the lists to pop from.
|
|
5279
5279
|
* @param timeout - The `timeout` in seconds.
|
|
@@ -5768,7 +5768,7 @@ export declare class BaseClient {
|
|
|
5768
5768
|
*
|
|
5769
5769
|
* @see {@link https://valkey.io/commands/bzmpop/|valkey.io} for more details.
|
|
5770
5770
|
* @remarks When in cluster mode, all `keys` must map to the same hash slot.
|
|
5771
|
-
* @remarks `BZMPOP` is a client blocking command, see {@link https://
|
|
5771
|
+
* @remarks `BZMPOP` is a client blocking command, see {@link https://glide.valkey.io/how-to/connection-management/#blocking-commands | Valkey GLIDE Documentation} for more details and best practices.
|
|
5772
5772
|
* @remarks Since Valkey version 7.0.0.
|
|
5773
5773
|
*
|
|
5774
5774
|
* @param keys - The keys of the sorted sets.
|
|
@@ -6067,7 +6067,7 @@ export declare class BaseClient {
|
|
|
6067
6067
|
* will only execute commands if the watched keys are not modified before execution of the
|
|
6068
6068
|
* transaction. Executing a transaction will automatically flush all previously watched keys.
|
|
6069
6069
|
*
|
|
6070
|
-
* @see {@link https://valkey.io/commands/watch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey
|
|
6070
|
+
* @see {@link https://valkey.io/commands/watch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey GLIDE Documentation} for more details.
|
|
6071
6071
|
*
|
|
6072
6072
|
* @remarks In cluster mode, if keys in `keys` map to different hash slots,
|
|
6073
6073
|
* the command will be split across these slots and executed separately for each.
|
package/build-ts/BaseClient.js
CHANGED
|
@@ -476,7 +476,10 @@ class BaseClient {
|
|
|
476
476
|
const commandName = command instanceof ProtobufMessage_1.command_request.Command
|
|
477
477
|
? ProtobufMessage_1.command_request.RequestType[command.requestType]
|
|
478
478
|
: "Batch";
|
|
479
|
-
const
|
|
479
|
+
const parentCtx = _1.OpenTelemetry.getParentSpanContext();
|
|
480
|
+
const pair = parentCtx
|
|
481
|
+
? (0, _1.createOtelSpanWithTraceContext)(commandName, parentCtx.traceId, parentCtx.spanId, parentCtx.traceFlags, parentCtx.traceState)
|
|
482
|
+
: (0, _1.createLeakedOtelSpan)(commandName);
|
|
480
483
|
spanPtr = new long_1.default(pair[0], pair[1]);
|
|
481
484
|
}
|
|
482
485
|
this.promiseCallbackFunctions[callbackIndex] = [
|
|
@@ -2540,7 +2543,7 @@ class BaseClient {
|
|
|
2540
2543
|
*
|
|
2541
2544
|
* @see {@link https://valkey.io/commands/blmove/|valkey.io} for details.
|
|
2542
2545
|
* @remarks When in cluster mode, both `source` and `destination` must map to the same hash slot.
|
|
2543
|
-
* @remarks `BLMOVE` is a client blocking command, see {@link https://
|
|
2546
|
+
* @remarks `BLMOVE` is a client blocking command, see {@link https://glide.valkey.io/how-to/connection-management/#blocking-commands|Valkey GLIDE Documentation} for more details and best practices.
|
|
2544
2547
|
* @remarks Since Valkey version 6.2.0.
|
|
2545
2548
|
*
|
|
2546
2549
|
* @param source - The key to the source list.
|
|
@@ -5722,7 +5725,7 @@ class BaseClient {
|
|
|
5722
5725
|
*
|
|
5723
5726
|
* @see {@link https://valkey.io/commands/brpop/|valkey.io} for more details.
|
|
5724
5727
|
* @remarks When in cluster mode, all `keys` must map to the same hash slot.
|
|
5725
|
-
* @remarks `BRPOP` is a blocking command, see [Blocking Commands](https://
|
|
5728
|
+
* @remarks `BRPOP` is a blocking command, see [Blocking Commands](https://glide.valkey.io/how-to/connection-management/#blocking-commands) for more details and best practices.
|
|
5726
5729
|
*
|
|
5727
5730
|
* @param keys - The `keys` of the lists to pop from.
|
|
5728
5731
|
* @param timeout - The `timeout` in seconds.
|
|
@@ -5749,7 +5752,7 @@ class BaseClient {
|
|
|
5749
5752
|
*
|
|
5750
5753
|
* @see {@link https://valkey.io/commands/blpop/|valkey.io} for more details.
|
|
5751
5754
|
* @remarks When in cluster mode, all `keys` must map to the same hash slot.
|
|
5752
|
-
* @remarks `BLPOP` is a blocking command, see [Blocking Commands](https://
|
|
5755
|
+
* @remarks `BLPOP` is a blocking command, see [Blocking Commands](https://glide.valkey.io/how-to/connection-management/#blocking-commands) for more details and best practices.
|
|
5753
5756
|
*
|
|
5754
5757
|
* @param keys - The `keys` of the lists to pop from.
|
|
5755
5758
|
* @param timeout - The `timeout` in seconds.
|
|
@@ -6282,7 +6285,7 @@ class BaseClient {
|
|
|
6282
6285
|
*
|
|
6283
6286
|
* @see {@link https://valkey.io/commands/bzmpop/|valkey.io} for more details.
|
|
6284
6287
|
* @remarks When in cluster mode, all `keys` must map to the same hash slot.
|
|
6285
|
-
* @remarks `BZMPOP` is a client blocking command, see {@link https://
|
|
6288
|
+
* @remarks `BZMPOP` is a client blocking command, see {@link https://glide.valkey.io/how-to/connection-management/#blocking-commands | Valkey GLIDE Documentation} for more details and best practices.
|
|
6286
6289
|
* @remarks Since Valkey version 7.0.0.
|
|
6287
6290
|
*
|
|
6288
6291
|
* @param keys - The keys of the sorted sets.
|
|
@@ -6596,7 +6599,7 @@ class BaseClient {
|
|
|
6596
6599
|
* will only execute commands if the watched keys are not modified before execution of the
|
|
6597
6600
|
* transaction. Executing a transaction will automatically flush all previously watched keys.
|
|
6598
6601
|
*
|
|
6599
|
-
* @see {@link https://valkey.io/commands/watch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey
|
|
6602
|
+
* @see {@link https://valkey.io/commands/watch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey GLIDE Documentation} for more details.
|
|
6600
6603
|
*
|
|
6601
6604
|
* @remarks In cluster mode, if keys in `keys` map to different hash slots,
|
|
6602
6605
|
* the command will be split across these slots and executed separately for each.
|
package/build-ts/Batch.d.ts
CHANGED
|
@@ -922,7 +922,7 @@ export declare class BaseBatch<T extends BaseBatch<T>> {
|
|
|
922
922
|
*
|
|
923
923
|
* @see {@link https://valkey.io/commands/blmove/|valkey.io} for details.
|
|
924
924
|
* @remarks When in cluster mode, both `source` and `destination` must map to the same hash slot.
|
|
925
|
-
* @remarks `BLMOVE` is a client blocking command, see {@link https://
|
|
925
|
+
* @remarks `BLMOVE` is a client blocking command, see {@link https://glide.valkey.io/how-to/connection-management/#blocking-commands|Valkey GLIDE Documentation} for more details and best practices.
|
|
926
926
|
* @remarks Since Valkey version 6.2.0.
|
|
927
927
|
*
|
|
928
928
|
* @param source - The key to the source list.
|
|
@@ -1945,7 +1945,7 @@ export declare class BaseBatch<T extends BaseBatch<T>> {
|
|
|
1945
1945
|
/** Executes a single command, without checking inputs. Every part of the command, including subcommands,
|
|
1946
1946
|
* should be added as a separate value in args.
|
|
1947
1947
|
*
|
|
1948
|
-
* @see {@link https://
|
|
1948
|
+
* @see {@link https://glide.valkey.io/concepts/client-features/custom-commands/|Valkey GLIDE Documentation} for details on the restrictions and limitations of the custom command API.
|
|
1949
1949
|
*
|
|
1950
1950
|
* Command Response - A response from Valkey with an `Object`.
|
|
1951
1951
|
*/
|
|
@@ -2362,7 +2362,7 @@ export declare class BaseBatch<T extends BaseBatch<T>> {
|
|
|
2362
2362
|
* Blocks the connection when there are no elements to pop from any of the given lists.
|
|
2363
2363
|
*
|
|
2364
2364
|
* @see {@link https://valkey.io/commands/brpop/|valkey.io} for details.
|
|
2365
|
-
* @remarks `BRPOP` is a blocking command, see [Blocking Commands](https://
|
|
2365
|
+
* @remarks `BRPOP` is a blocking command, see [Blocking Commands](https://glide.valkey.io/how-to/connection-management/#blocking-commands) for more details and best practices.
|
|
2366
2366
|
*
|
|
2367
2367
|
* @param keys - The `keys` of the lists to pop from.
|
|
2368
2368
|
* @param timeout - The `timeout` in seconds.
|
|
@@ -2377,7 +2377,7 @@ export declare class BaseBatch<T extends BaseBatch<T>> {
|
|
|
2377
2377
|
* Blocks the connection when there are no elements to pop from any of the given lists.
|
|
2378
2378
|
*
|
|
2379
2379
|
* @see {@link https://valkey.io/commands/blpop/|valkey.io} for details.
|
|
2380
|
-
* @remarks `BLPOP` is a blocking command, see [Blocking Commands](https://
|
|
2380
|
+
* @remarks `BLPOP` is a blocking command, see [Blocking Commands](https://glide.valkey.io/how-to/connection-management/#blocking-commands) for more details and best practices.
|
|
2381
2381
|
*
|
|
2382
2382
|
* @param keys - The `keys` of the lists to pop from.
|
|
2383
2383
|
* @param timeout - The `timeout` in seconds.
|
|
@@ -2761,7 +2761,7 @@ export declare class BaseBatch<T extends BaseBatch<T>> {
|
|
|
2761
2761
|
* to pop from any of the given sorted sets. `BZMPOP` is the blocking variant of {@link zmpop}.
|
|
2762
2762
|
*
|
|
2763
2763
|
* @see {@link https://valkey.io/commands/bzmpop/|valkey.io} for details.
|
|
2764
|
-
* @remarks `BZMPOP` is a client blocking command, see {@link https://
|
|
2764
|
+
* @remarks `BZMPOP` is a client blocking command, see {@link https://glide.valkey.io/how-to/connection-management/#blocking-commands | Valkey GLIDE Documentation} for more details and best practices.
|
|
2765
2765
|
* @remarks Since Valkey version 7.0.0.
|
|
2766
2766
|
*
|
|
2767
2767
|
* @param keys - The keys of the sorted sets.
|
package/build-ts/Batch.js
CHANGED
|
@@ -1061,7 +1061,7 @@ class BaseBatch {
|
|
|
1061
1061
|
*
|
|
1062
1062
|
* @see {@link https://valkey.io/commands/blmove/|valkey.io} for details.
|
|
1063
1063
|
* @remarks When in cluster mode, both `source` and `destination` must map to the same hash slot.
|
|
1064
|
-
* @remarks `BLMOVE` is a client blocking command, see {@link https://
|
|
1064
|
+
* @remarks `BLMOVE` is a client blocking command, see {@link https://glide.valkey.io/how-to/connection-management/#blocking-commands|Valkey GLIDE Documentation} for more details and best practices.
|
|
1065
1065
|
* @remarks Since Valkey version 6.2.0.
|
|
1066
1066
|
*
|
|
1067
1067
|
* @param source - The key to the source list.
|
|
@@ -2216,7 +2216,7 @@ class BaseBatch {
|
|
|
2216
2216
|
/** Executes a single command, without checking inputs. Every part of the command, including subcommands,
|
|
2217
2217
|
* should be added as a separate value in args.
|
|
2218
2218
|
*
|
|
2219
|
-
* @see {@link https://
|
|
2219
|
+
* @see {@link https://glide.valkey.io/concepts/client-features/custom-commands/|Valkey GLIDE Documentation} for details on the restrictions and limitations of the custom command API.
|
|
2220
2220
|
*
|
|
2221
2221
|
* Command Response - A response from Valkey with an `Object`.
|
|
2222
2222
|
*/
|
|
@@ -2695,7 +2695,7 @@ class BaseBatch {
|
|
|
2695
2695
|
* Blocks the connection when there are no elements to pop from any of the given lists.
|
|
2696
2696
|
*
|
|
2697
2697
|
* @see {@link https://valkey.io/commands/brpop/|valkey.io} for details.
|
|
2698
|
-
* @remarks `BRPOP` is a blocking command, see [Blocking Commands](https://
|
|
2698
|
+
* @remarks `BRPOP` is a blocking command, see [Blocking Commands](https://glide.valkey.io/how-to/connection-management/#blocking-commands) for more details and best practices.
|
|
2699
2699
|
*
|
|
2700
2700
|
* @param keys - The `keys` of the lists to pop from.
|
|
2701
2701
|
* @param timeout - The `timeout` in seconds.
|
|
@@ -2712,7 +2712,7 @@ class BaseBatch {
|
|
|
2712
2712
|
* Blocks the connection when there are no elements to pop from any of the given lists.
|
|
2713
2713
|
*
|
|
2714
2714
|
* @see {@link https://valkey.io/commands/blpop/|valkey.io} for details.
|
|
2715
|
-
* @remarks `BLPOP` is a blocking command, see [Blocking Commands](https://
|
|
2715
|
+
* @remarks `BLPOP` is a blocking command, see [Blocking Commands](https://glide.valkey.io/how-to/connection-management/#blocking-commands) for more details and best practices.
|
|
2716
2716
|
*
|
|
2717
2717
|
* @param keys - The `keys` of the lists to pop from.
|
|
2718
2718
|
* @param timeout - The `timeout` in seconds.
|
|
@@ -3154,7 +3154,7 @@ class BaseBatch {
|
|
|
3154
3154
|
* to pop from any of the given sorted sets. `BZMPOP` is the blocking variant of {@link zmpop}.
|
|
3155
3155
|
*
|
|
3156
3156
|
* @see {@link https://valkey.io/commands/bzmpop/|valkey.io} for details.
|
|
3157
|
-
* @remarks `BZMPOP` is a client blocking command, see {@link https://
|
|
3157
|
+
* @remarks `BZMPOP` is a client blocking command, see {@link https://glide.valkey.io/how-to/connection-management/#blocking-commands | Valkey GLIDE Documentation} for more details and best practices.
|
|
3158
3158
|
* @remarks Since Valkey version 7.0.0.
|
|
3159
3159
|
*
|
|
3160
3160
|
* @param keys - The keys of the sorted sets.
|
package/build-ts/Commands.js
CHANGED
|
@@ -252,11 +252,15 @@ function isLargeCommand(args) {
|
|
|
252
252
|
function toBuffersArray(args) {
|
|
253
253
|
const argsBytes = [];
|
|
254
254
|
for (const arg of args) {
|
|
255
|
-
if (
|
|
255
|
+
if (Buffer.isBuffer(arg)) {
|
|
256
|
+
argsBytes.push(arg);
|
|
257
|
+
}
|
|
258
|
+
else if (typeof arg === "string") {
|
|
256
259
|
argsBytes.push(Buffer.from(arg));
|
|
257
260
|
}
|
|
258
261
|
else {
|
|
259
|
-
|
|
262
|
+
// Fallback for unexpected types (number, boolean, etc.)
|
|
263
|
+
argsBytes.push(Buffer.from(String(arg)));
|
|
260
264
|
}
|
|
261
265
|
}
|
|
262
266
|
return argsBytes;
|
|
@@ -71,6 +71,24 @@ export type GlideClientConfiguration = BaseClientConfiguration & {
|
|
|
71
71
|
* Advanced configuration settings for the client.
|
|
72
72
|
*/
|
|
73
73
|
advancedConfiguration?: AdvancedGlideClientConfiguration;
|
|
74
|
+
/**
|
|
75
|
+
* When true, enables read-only mode for the standalone client.
|
|
76
|
+
*
|
|
77
|
+
* In read-only mode:
|
|
78
|
+
* - The client skips primary node detection (INFO REPLICATION command)
|
|
79
|
+
* - All connected nodes are treated as valid read targets
|
|
80
|
+
* - Write commands are blocked and will return an error
|
|
81
|
+
* - The default ReadFrom strategy becomes PreferReplica if not explicitly set
|
|
82
|
+
*
|
|
83
|
+
* This is useful for connecting to replica-only deployments or when you want to
|
|
84
|
+
* prevent accidental write operations.
|
|
85
|
+
*
|
|
86
|
+
* Note: read-only mode is not compatible with AZAffinity or AZAffinityReplicasAndPrimary
|
|
87
|
+
* read strategies.
|
|
88
|
+
*
|
|
89
|
+
* Defaults to false.
|
|
90
|
+
*/
|
|
91
|
+
readOnly?: boolean;
|
|
74
92
|
};
|
|
75
93
|
/**
|
|
76
94
|
* Represents advanced configuration settings for creating a {@link GlideClient | GlideClient} used in {@link GlideClientConfiguration | GlideClientConfiguration}.
|
|
@@ -91,7 +109,7 @@ export type AdvancedGlideClientConfiguration = AdvancedBaseClientConfiguration &
|
|
|
91
109
|
* Client used for connection to standalone servers.
|
|
92
110
|
* Use {@link createClient} to request a client.
|
|
93
111
|
*
|
|
94
|
-
* @see For full documentation refer to {@link https://
|
|
112
|
+
* @see For full documentation refer to {@link https://glide.valkey.io/how-to/client-initialization/#standalone | Valkey GLIDE Documentation}.
|
|
95
113
|
*/
|
|
96
114
|
export declare class GlideClient extends BaseClient {
|
|
97
115
|
/**
|
|
@@ -152,7 +170,7 @@ export declare class GlideClient extends BaseClient {
|
|
|
152
170
|
* **Notes:**
|
|
153
171
|
* - **Atomic Batches - Transactions:** If the transaction fails due to a `WATCH` command, `EXEC` will return `null`.
|
|
154
172
|
*
|
|
155
|
-
* @see {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#transaction|Valkey
|
|
173
|
+
* @see {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#transaction|Valkey GLIDE Documentation} for details on Valkey Transactions.
|
|
156
174
|
*
|
|
157
175
|
* @param batch - A {@link Batch} object containing a list of commands to be executed.
|
|
158
176
|
* @param raiseOnError - Determines how errors are handled within the batch response.
|
|
@@ -199,7 +217,7 @@ export declare class GlideClient extends BaseClient {
|
|
|
199
217
|
*
|
|
200
218
|
* Note: An error will occur if the string decoder is used with commands that return only bytes as a response.
|
|
201
219
|
*
|
|
202
|
-
* @see {@link https://
|
|
220
|
+
* @see {@link https://glide.valkey.io/concepts/client-features/custom-commands/|Valkey GLIDE Documentation} for details on the restrictions and limitations of the custom command API.
|
|
203
221
|
*
|
|
204
222
|
* @param args - A list including the command name and arguments for the custom command.
|
|
205
223
|
* @param options - (Optional) See {@link DecoderOption}.
|
|
@@ -674,7 +692,7 @@ export declare class GlideClient extends BaseClient {
|
|
|
674
692
|
* Flushes all the previously watched keys for a transaction. Executing a transaction will
|
|
675
693
|
* automatically flush all previously watched keys.
|
|
676
694
|
*
|
|
677
|
-
* @see {@link https://valkey.io/commands/unwatch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey
|
|
695
|
+
* @see {@link https://valkey.io/commands/unwatch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey GLIDE Documentation} for more details.
|
|
678
696
|
*
|
|
679
697
|
* @returns A simple `"OK"` response.
|
|
680
698
|
*
|
package/build-ts/GlideClient.js
CHANGED
|
@@ -29,7 +29,7 @@ var GlideClientConfiguration;
|
|
|
29
29
|
* Client used for connection to standalone servers.
|
|
30
30
|
* Use {@link createClient} to request a client.
|
|
31
31
|
*
|
|
32
|
-
* @see For full documentation refer to {@link https://
|
|
32
|
+
* @see For full documentation refer to {@link https://glide.valkey.io/how-to/client-initialization/#standalone | Valkey GLIDE Documentation}.
|
|
33
33
|
*/
|
|
34
34
|
class GlideClient extends BaseClient_1.BaseClient {
|
|
35
35
|
/**
|
|
@@ -41,6 +41,10 @@ class GlideClient extends BaseClient_1.BaseClient {
|
|
|
41
41
|
if (options.advancedConfiguration) {
|
|
42
42
|
this.configureAdvancedConfigurationBase(options.advancedConfiguration, configuration);
|
|
43
43
|
}
|
|
44
|
+
// Set read-only mode if specified
|
|
45
|
+
if (options.readOnly !== undefined) {
|
|
46
|
+
configuration.readOnly = options.readOnly;
|
|
47
|
+
}
|
|
44
48
|
return configuration;
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
@@ -109,7 +113,7 @@ class GlideClient extends BaseClient_1.BaseClient {
|
|
|
109
113
|
* **Notes:**
|
|
110
114
|
* - **Atomic Batches - Transactions:** If the transaction fails due to a `WATCH` command, `EXEC` will return `null`.
|
|
111
115
|
*
|
|
112
|
-
* @see {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#transaction|Valkey
|
|
116
|
+
* @see {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#transaction|Valkey GLIDE Documentation} for details on Valkey Transactions.
|
|
113
117
|
*
|
|
114
118
|
* @param batch - A {@link Batch} object containing a list of commands to be executed.
|
|
115
119
|
* @param raiseOnError - Determines how errors are handled within the batch response.
|
|
@@ -158,7 +162,7 @@ class GlideClient extends BaseClient_1.BaseClient {
|
|
|
158
162
|
*
|
|
159
163
|
* Note: An error will occur if the string decoder is used with commands that return only bytes as a response.
|
|
160
164
|
*
|
|
161
|
-
* @see {@link https://
|
|
165
|
+
* @see {@link https://glide.valkey.io/concepts/client-features/custom-commands/|Valkey GLIDE Documentation} for details on the restrictions and limitations of the custom command API.
|
|
162
166
|
*
|
|
163
167
|
* @param args - A list including the command name and arguments for the custom command.
|
|
164
168
|
* @param options - (Optional) See {@link DecoderOption}.
|
|
@@ -707,7 +711,7 @@ class GlideClient extends BaseClient_1.BaseClient {
|
|
|
707
711
|
* Flushes all the previously watched keys for a transaction. Executing a transaction will
|
|
708
712
|
* automatically flush all previously watched keys.
|
|
709
713
|
*
|
|
710
|
-
* @see {@link https://valkey.io/commands/unwatch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey
|
|
714
|
+
* @see {@link https://valkey.io/commands/unwatch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey GLIDE Documentation} for more details.
|
|
711
715
|
*
|
|
712
716
|
* @returns A simple `"OK"` response.
|
|
713
717
|
*
|
|
@@ -405,7 +405,7 @@ export type SingleNodeRoute =
|
|
|
405
405
|
* Client used for connection to cluster servers.
|
|
406
406
|
* Use {@link createClient} to request a client.
|
|
407
407
|
*
|
|
408
|
-
* @see For full documentation refer to {@link https://
|
|
408
|
+
* @see For full documentation refer to {@link https://glide.valkey.io/how-to/client-initialization/#cluster | Valkey GLIDE Documentation}.
|
|
409
409
|
*/
|
|
410
410
|
export declare class GlideClusterClient extends BaseClient {
|
|
411
411
|
/**
|
|
@@ -476,7 +476,7 @@ export declare class GlideClusterClient extends BaseClient {
|
|
|
476
476
|
* Using the same cursor object for multiple iterations may result in unexpected behavior.
|
|
477
477
|
*
|
|
478
478
|
* For more information about the Cluster Scan implementation, see
|
|
479
|
-
* {@link https://
|
|
479
|
+
* {@link https://glide.valkey.io/concepts/client-features/cluster-scan/ | Cluster Scan}.
|
|
480
480
|
*
|
|
481
481
|
* This method can iterate over all keys in the database from the start of the scan until it ends.
|
|
482
482
|
* The same key may be returned in multiple scan iterations.
|
|
@@ -535,7 +535,7 @@ export declare class GlideClusterClient extends BaseClient {
|
|
|
535
535
|
*
|
|
536
536
|
* Note: An error will occur if the string decoder is used with commands that return only bytes as a response.
|
|
537
537
|
*
|
|
538
|
-
* @see {@link https://
|
|
538
|
+
* @see {@link https://glide.valkey.io/concepts/client-features/custom-commands/|Glide for Valkey Wiki} for details on the restrictions and limitations of the custom command API.
|
|
539
539
|
*
|
|
540
540
|
* @param args - A list including the command name and arguments for the custom command.
|
|
541
541
|
* @param options - (Optional) See {@link RouteOption} and {@link DecoderOption}
|
|
@@ -563,7 +563,7 @@ export declare class GlideClusterClient extends BaseClient {
|
|
|
563
563
|
*
|
|
564
564
|
* - **Atomic Batches (Transactions):** All key-based commands must map to the same hash slot. If keys span different slots, the transaction will fail. If the transaction fails due to a `WATCH` command, `exec` will return `null`.
|
|
565
565
|
*
|
|
566
|
-
* @see {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#transaction|Valkey
|
|
566
|
+
* @see {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#transaction|Valkey GLIDE Documentation} for details on Valkey Transactions.
|
|
567
567
|
*
|
|
568
568
|
* **Retry and Redirection:**
|
|
569
569
|
*
|
|
@@ -1289,7 +1289,7 @@ export declare class GlideClusterClient extends BaseClient {
|
|
|
1289
1289
|
*
|
|
1290
1290
|
* The command will be routed to all primary nodes, unless `route` is provided
|
|
1291
1291
|
*
|
|
1292
|
-
* @see {@link https://valkey.io/commands/unwatch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey
|
|
1292
|
+
* @see {@link https://valkey.io/commands/unwatch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey GLIDE Documentation} for more details.
|
|
1293
1293
|
*
|
|
1294
1294
|
* @param options - (Optional) See {@link RouteOption}.
|
|
1295
1295
|
* @returns A simple `"OK"` response.
|
|
@@ -54,7 +54,7 @@ function convertClusterGlideRecord(res, isRoutedToSingleNodeByDefault, route) {
|
|
|
54
54
|
* Client used for connection to cluster servers.
|
|
55
55
|
* Use {@link createClient} to request a client.
|
|
56
56
|
*
|
|
57
|
-
* @see For full documentation refer to {@link https://
|
|
57
|
+
* @see For full documentation refer to {@link https://glide.valkey.io/how-to/client-initialization/#cluster | Valkey GLIDE Documentation}.
|
|
58
58
|
*/
|
|
59
59
|
class GlideClusterClient extends BaseClient_1.BaseClient {
|
|
60
60
|
/**
|
|
@@ -220,7 +220,7 @@ class GlideClusterClient extends BaseClient_1.BaseClient {
|
|
|
220
220
|
* Using the same cursor object for multiple iterations may result in unexpected behavior.
|
|
221
221
|
*
|
|
222
222
|
* For more information about the Cluster Scan implementation, see
|
|
223
|
-
* {@link https://
|
|
223
|
+
* {@link https://glide.valkey.io/concepts/client-features/cluster-scan/ | Cluster Scan}.
|
|
224
224
|
*
|
|
225
225
|
* This method can iterate over all keys in the database from the start of the scan until it ends.
|
|
226
226
|
* The same key may be returned in multiple scan iterations.
|
|
@@ -281,7 +281,7 @@ class GlideClusterClient extends BaseClient_1.BaseClient {
|
|
|
281
281
|
*
|
|
282
282
|
* Note: An error will occur if the string decoder is used with commands that return only bytes as a response.
|
|
283
283
|
*
|
|
284
|
-
* @see {@link https://
|
|
284
|
+
* @see {@link https://glide.valkey.io/concepts/client-features/custom-commands/|Glide for Valkey Wiki} for details on the restrictions and limitations of the custom command API.
|
|
285
285
|
*
|
|
286
286
|
* @param args - A list including the command name and arguments for the custom command.
|
|
287
287
|
* @param options - (Optional) See {@link RouteOption} and {@link DecoderOption}
|
|
@@ -312,7 +312,7 @@ class GlideClusterClient extends BaseClient_1.BaseClient {
|
|
|
312
312
|
*
|
|
313
313
|
* - **Atomic Batches (Transactions):** All key-based commands must map to the same hash slot. If keys span different slots, the transaction will fail. If the transaction fails due to a `WATCH` command, `exec` will return `null`.
|
|
314
314
|
*
|
|
315
|
-
* @see {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#transaction|Valkey
|
|
315
|
+
* @see {@link https://github.com/valkey-io/valkey-glide/wiki/NodeJS-wrapper#transaction|Valkey GLIDE Documentation} for details on Valkey Transactions.
|
|
316
316
|
*
|
|
317
317
|
* **Retry and Redirection:**
|
|
318
318
|
*
|
|
@@ -1111,7 +1111,7 @@ class GlideClusterClient extends BaseClient_1.BaseClient {
|
|
|
1111
1111
|
*
|
|
1112
1112
|
* The command will be routed to all primary nodes, unless `route` is provided
|
|
1113
1113
|
*
|
|
1114
|
-
* @see {@link https://valkey.io/commands/unwatch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey
|
|
1114
|
+
* @see {@link https://valkey.io/commands/unwatch/|valkey.io} and {@link https://valkey.io/topics/transactions/#cas|Valkey GLIDE Documentation} for more details.
|
|
1115
1115
|
*
|
|
1116
1116
|
* @param options - (Optional) See {@link RouteOption}.
|
|
1117
1117
|
* @returns A simple `"OK"` response.
|
|
@@ -2,12 +2,66 @@
|
|
|
2
2
|
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
|
|
3
3
|
*/
|
|
4
4
|
import { OpenTelemetryConfig } from ".";
|
|
5
|
+
/**
|
|
6
|
+
* Extended OpenTelemetry configuration that includes JS-side options
|
|
7
|
+
* not representable in the native (NAPI) config.
|
|
8
|
+
*
|
|
9
|
+
* Pass this to {@link OpenTelemetry.init} instead of the plain `OpenTelemetryConfig`.
|
|
10
|
+
*/
|
|
11
|
+
export interface GlideOpenTelemetryConfig extends OpenTelemetryConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Optional callback that returns the active parent span context for each command.
|
|
14
|
+
*
|
|
15
|
+
* When a {@link GlideSpanContext} is returned, the GLIDE command span will be created
|
|
16
|
+
* as a child of that context, enabling end-to-end distributed tracing.
|
|
17
|
+
*
|
|
18
|
+
* The callback is invoked synchronously before each sampled command. Keep the
|
|
19
|
+
* implementation lightweight — avoid I/O, async work, or expensive computation.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { trace } from "@opentelemetry/api";
|
|
24
|
+
*
|
|
25
|
+
* OpenTelemetry.init({
|
|
26
|
+
* traces: { endpoint: "http://localhost:4318/v1/traces" },
|
|
27
|
+
* parentSpanContextProvider: () => {
|
|
28
|
+
* const span = trace.getActiveSpan();
|
|
29
|
+
* if (!span) return undefined;
|
|
30
|
+
* const ctx = span.spanContext();
|
|
31
|
+
* return {
|
|
32
|
+
* traceId: ctx.traceId,
|
|
33
|
+
* spanId: ctx.spanId,
|
|
34
|
+
* traceFlags: ctx.traceFlags,
|
|
35
|
+
* traceState: ctx.traceState?.toString(),
|
|
36
|
+
* };
|
|
37
|
+
* },
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
parentSpanContextProvider?: () => GlideSpanContext | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Represents the trace context of a remote span, used for parent span context propagation.
|
|
45
|
+
*
|
|
46
|
+
* When a user's application has an active OTel span (e.g., from an HTTP request handler),
|
|
47
|
+
* this context allows GLIDE command spans to appear as children of that span in tracing UIs.
|
|
48
|
+
*/
|
|
49
|
+
export interface GlideSpanContext {
|
|
50
|
+
/** The trace ID as a 32-character lowercase hex string. */
|
|
51
|
+
traceId: string;
|
|
52
|
+
/** The span ID as a 16-character lowercase hex string. */
|
|
53
|
+
spanId: string;
|
|
54
|
+
/** Trace flags (e.g., 1 for sampled). */
|
|
55
|
+
traceFlags: number;
|
|
56
|
+
/** Optional W3C trace state (e.g., "vendorname1=opaqueValue1,vendorname2=opaqueValue2"). */
|
|
57
|
+
traceState?: string;
|
|
58
|
+
}
|
|
5
59
|
/**
|
|
6
60
|
* ⚠️ OpenTelemetry can only be initialized once per process. Calling `OpenTelemetry.init()` more than once will be ignored.
|
|
7
61
|
* If you need to change configuration, restart the process with new settings.
|
|
8
62
|
* ### OpenTelemetry
|
|
9
63
|
*
|
|
10
|
-
* - **openTelemetryConfig**: Use
|
|
64
|
+
* - **openTelemetryConfig**: Use {@link GlideOpenTelemetryConfig} to configure OpenTelemetry exporters and options.
|
|
11
65
|
* - **traces**: (optional) Configure trace exporting.
|
|
12
66
|
* - **endpoint**: The collector endpoint for traces. Supported protocols:
|
|
13
67
|
* - `http://` or `https://` for HTTP/HTTPS
|
|
@@ -19,6 +73,7 @@ import { OpenTelemetryConfig } from ".";
|
|
|
19
73
|
* - **metrics**: (optional) Configure metrics exporting.
|
|
20
74
|
* - **endpoint**: The collector endpoint for metrics. Same protocol rules as above.
|
|
21
75
|
* - **flushIntervalMs**: (optional) Interval in milliseconds for flushing data to the collector. Must be a positive integer. Defaults to 5000ms if not specified.
|
|
76
|
+
* - **parentSpanContextProvider**: (optional) Callback returning the active parent span context. See {@link GlideOpenTelemetryConfig.parentSpanContextProvider}.
|
|
22
77
|
*
|
|
23
78
|
* #### File Exporter Details
|
|
24
79
|
* - For `file://` endpoints:
|
|
@@ -37,6 +92,9 @@ import { OpenTelemetryConfig } from ".";
|
|
|
37
92
|
export declare class OpenTelemetry {
|
|
38
93
|
private static _instance;
|
|
39
94
|
private static openTelemetryConfig;
|
|
95
|
+
private static spanContextFn;
|
|
96
|
+
private static readonly TRACE_ID_REGEX;
|
|
97
|
+
private static readonly SPAN_ID_REGEX;
|
|
40
98
|
/**
|
|
41
99
|
* Singleton class for managing OpenTelemetry configuration and operations.
|
|
42
100
|
* This class provides a centralized way to initialize OpenTelemetry and control
|
|
@@ -44,23 +102,26 @@ export declare class OpenTelemetry {
|
|
|
44
102
|
*
|
|
45
103
|
* Example usage:
|
|
46
104
|
* ```typescript
|
|
47
|
-
* import { OpenTelemetry,
|
|
105
|
+
* import { OpenTelemetry, GlideOpenTelemetryConfig } from "@valkey/valkey-glide";
|
|
106
|
+
* import { trace } from "@opentelemetry/api";
|
|
48
107
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
108
|
+
* const config: GlideOpenTelemetryConfig = {
|
|
109
|
+
* traces: {
|
|
110
|
+
* endpoint: "http://localhost:4318/v1/traces",
|
|
111
|
+
* samplePercentage: 10,
|
|
112
|
+
* },
|
|
113
|
+
* metrics: {
|
|
114
|
+
* endpoint: "http://localhost:4318/v1/metrics",
|
|
115
|
+
* },
|
|
116
|
+
* flushIntervalMs: 1000,
|
|
117
|
+
* parentSpanContextProvider: () => {
|
|
118
|
+
* const span = trace.getActiveSpan();
|
|
119
|
+
* if (!span) return undefined;
|
|
120
|
+
* const ctx = span.spanContext();
|
|
121
|
+
* return { traceId: ctx.traceId, spanId: ctx.spanId, traceFlags: ctx.traceFlags };
|
|
122
|
+
* },
|
|
61
123
|
* };
|
|
62
124
|
* OpenTelemetry.init(config);
|
|
63
|
-
*
|
|
64
125
|
* ```
|
|
65
126
|
*
|
|
66
127
|
* @remarks
|
|
@@ -71,7 +132,7 @@ export declare class OpenTelemetry {
|
|
|
71
132
|
* Initialize the OpenTelemetry instance
|
|
72
133
|
* @param openTelemetryConfig - The OpenTelemetry configuration
|
|
73
134
|
*/
|
|
74
|
-
static init(openTelemetryConfig:
|
|
135
|
+
static init(openTelemetryConfig: GlideOpenTelemetryConfig): void;
|
|
75
136
|
private static internalInit;
|
|
76
137
|
/**
|
|
77
138
|
* Check if the OpenTelemetry instance is initialized
|
|
@@ -98,4 +159,31 @@ export declare class OpenTelemetry {
|
|
|
98
159
|
* This method can be called at runtime to change the sampling percentage without reinitializing OpenTelemetry.
|
|
99
160
|
*/
|
|
100
161
|
static setSamplePercentage(percentage: number): void;
|
|
162
|
+
/**
|
|
163
|
+
* Register or replace the callback that returns the active parent span context.
|
|
164
|
+
*
|
|
165
|
+
* This allows changing the provider at runtime (e.g., switching tracing contexts
|
|
166
|
+
* in a multi-tenant application). The initial provider can also be set via
|
|
167
|
+
* {@link GlideOpenTelemetryConfig.parentSpanContextProvider} in `init()`.
|
|
168
|
+
*
|
|
169
|
+
* @param fn - A function returning a `GlideSpanContext` or `undefined`, or `null` to clear.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* import { trace } from "@opentelemetry/api";
|
|
174
|
+
*
|
|
175
|
+
* OpenTelemetry.setParentSpanContextProvider(() => {
|
|
176
|
+
* const span = trace.getActiveSpan();
|
|
177
|
+
* if (!span) return undefined;
|
|
178
|
+
* const ctx = span.spanContext();
|
|
179
|
+
* return {
|
|
180
|
+
* traceId: ctx.traceId,
|
|
181
|
+
* spanId: ctx.spanId,
|
|
182
|
+
* traceFlags: ctx.traceFlags,
|
|
183
|
+
* traceState: ctx.traceState?.toString(),
|
|
184
|
+
* };
|
|
185
|
+
* });
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
static setParentSpanContextProvider(fn: (() => GlideSpanContext | undefined) | null): void;
|
|
101
189
|
}
|