@valkey/valkey-glide 2.4.2 → 2.5.0-rc2
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/build-ts/BaseClient.d.ts +101 -1
- package/build-ts/BaseClient.js +108 -2
- package/build-ts/Batch.d.ts +43 -1
- package/build-ts/Batch.js +48 -0
- package/build-ts/ClientSideCache.d.ts +16 -0
- package/build-ts/ClientSideCache.js +6 -0
- package/build-ts/Commands.d.ts +179 -0
- package/build-ts/Commands.js +311 -1
- package/build-ts/Errors.d.ts +2 -0
- package/build-ts/Errors.js +4 -1
- package/build-ts/GlideClient.d.ts +313 -1
- package/build-ts/GlideClient.js +373 -0
- package/build-ts/GlideClusterClient.d.ts +278 -1
- package/build-ts/GlideClusterClient.js +380 -6
- package/build-ts/GlideMonitorClient.d.ts +36 -0
- package/build-ts/GlideMonitorClient.js +103 -0
- package/build-ts/ProtobufMessage.d.ts +113 -1
- package/build-ts/ProtobufMessage.js +261 -0
- package/build-ts/index.d.ts +1 -0
- package/build-ts/index.js +1 -0
- package/build-ts/native.d.ts +12 -0
- package/build-ts/native.js +5 -1
- package/package.json +20 -11
package/build-ts/Commands.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { GlideString, HashDataType, ObjectType } from "./BaseClient";
|
|
5
5
|
import { SingleNodeRoute } from "./GlideClusterClient";
|
|
6
|
+
import { command_request } from "../build-ts/ProtobufMessage";
|
|
6
7
|
/**
|
|
7
8
|
* @test
|
|
8
9
|
*/
|
|
@@ -131,6 +132,18 @@ export declare enum InfoOptions {
|
|
|
131
132
|
*/
|
|
132
133
|
Everything = "everything"
|
|
133
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Defines the pause mode for {@link GlideClient.clientPause} and
|
|
137
|
+
* {@link GlideClusterClient.clientPause} commands.
|
|
138
|
+
*
|
|
139
|
+
* @see {@link https://valkey.io/commands/client-pause/|valkey.io} for details.
|
|
140
|
+
*/
|
|
141
|
+
export declare enum ClientPauseMode {
|
|
142
|
+
/** Pause all client commands. */
|
|
143
|
+
ALL = "ALL",
|
|
144
|
+
/** Pause client write commands. */
|
|
145
|
+
WRITE = "WRITE"
|
|
146
|
+
}
|
|
134
147
|
/**
|
|
135
148
|
* This function converts an input from {@link HashDataType} or `Record` types to `HashDataType`.
|
|
136
149
|
*
|
|
@@ -737,6 +750,20 @@ export interface LolwutOptions {
|
|
|
737
750
|
*/
|
|
738
751
|
parameters?: number[];
|
|
739
752
|
}
|
|
753
|
+
/**
|
|
754
|
+
* Optional arguments for the {@link BaseClient.migrate} command.
|
|
755
|
+
*/
|
|
756
|
+
export interface MigrateOptions {
|
|
757
|
+
/** If true, do not remove the key from the source instance. */
|
|
758
|
+
copy?: boolean;
|
|
759
|
+
/** If true, replace the existing key on the destination instance. */
|
|
760
|
+
replace?: boolean;
|
|
761
|
+
/** Authentication password for the destination instance. */
|
|
762
|
+
password?: string;
|
|
763
|
+
/** Authentication username for the destination instance (requires password). */
|
|
764
|
+
username?: string;
|
|
765
|
+
}
|
|
766
|
+
export declare function createMigrate(host: string, port: number, key: GlideString | GlideString[], destinationDB: number, timeout: number, options?: MigrateOptions): command_request.Command;
|
|
740
767
|
/**
|
|
741
768
|
* Optional arguments for `RESTORE` command.
|
|
742
769
|
*
|
|
@@ -1129,6 +1156,46 @@ export interface Limit {
|
|
|
1129
1156
|
/** The maximum number of elements to include in the range. A negative count returns all elements from the offset. */
|
|
1130
1157
|
count: number;
|
|
1131
1158
|
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Represents the time and latency for a latency spike.
|
|
1161
|
+
*/
|
|
1162
|
+
export declare class LatencyEntry {
|
|
1163
|
+
/** The time of the latency spike, as a Unix timestamp in seconds. */
|
|
1164
|
+
readonly time: number;
|
|
1165
|
+
/** The duration of the latency spike, in milliseconds. */
|
|
1166
|
+
readonly latency: number;
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Represents information about an event's latency spike time series.
|
|
1170
|
+
*/
|
|
1171
|
+
export declare class LatencyEventInfo {
|
|
1172
|
+
/** The name of the event. */
|
|
1173
|
+
readonly eventName: string;
|
|
1174
|
+
/** The time of the latest latency spike, as a Unix timestamp in seconds. */
|
|
1175
|
+
readonly latestTime: number;
|
|
1176
|
+
/** The duration of the latest latency spike, in milliseconds. */
|
|
1177
|
+
readonly latestDuration: number;
|
|
1178
|
+
/** The all-time maximum duration of a latency spike, in milliseconds. */
|
|
1179
|
+
readonly maxDuration: number;
|
|
1180
|
+
/** The sum of all latency spike durations in the event's time series, in milliseconds. Only populated for Valkey 8.1+. */
|
|
1181
|
+
readonly sum?: number;
|
|
1182
|
+
/** The number of latency spikes recorded in the event's time series. Only populated for Valkey 8.1+. */
|
|
1183
|
+
readonly count?: number;
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Represents a `CLIENT TRACKINGINFO` response.
|
|
1187
|
+
*
|
|
1188
|
+
* @see {@link https://valkey.io/commands/client-trackinginfo/|valkey.io} for details.
|
|
1189
|
+
*/
|
|
1190
|
+
export declare class ClientTrackingInfo {
|
|
1191
|
+
/** Set of tracking flags. */
|
|
1192
|
+
readonly flags: Set<string>;
|
|
1193
|
+
/** Client ID receiving invalidation messages, or -1 if not redirecting. */
|
|
1194
|
+
readonly redirect: number;
|
|
1195
|
+
/** Set of key prefixes monitored for invalidation. */
|
|
1196
|
+
readonly prefixes: Set<string>;
|
|
1197
|
+
constructor(flags: Set<string>, redirect: number, prefixes: Set<string>);
|
|
1198
|
+
}
|
|
1132
1199
|
/**
|
|
1133
1200
|
* This base class represents the common set of optional arguments for the SCAN family of commands.
|
|
1134
1201
|
* Concrete implementations of this class are tied to specific SCAN commands (`SCAN`, `SSCAN`).
|
|
@@ -1216,6 +1283,22 @@ export declare enum TimeUnit {
|
|
|
1216
1283
|
*/
|
|
1217
1284
|
UnixMilliseconds = "PXAT"
|
|
1218
1285
|
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Options for the FAILOVER command.
|
|
1288
|
+
* @see {@link https://valkey.io/commands/failover/|valkey.io} for details.
|
|
1289
|
+
*/
|
|
1290
|
+
export interface FailoverOptions {
|
|
1291
|
+
/** Target replica to failover to. If `force` is true, forces failover after timeout. */
|
|
1292
|
+
to?: {
|
|
1293
|
+
host: string;
|
|
1294
|
+
port: number;
|
|
1295
|
+
force?: boolean;
|
|
1296
|
+
};
|
|
1297
|
+
/** Abort an ongoing failover. */
|
|
1298
|
+
abort?: boolean;
|
|
1299
|
+
/** Timeout in milliseconds. */
|
|
1300
|
+
timeoutMs?: number;
|
|
1301
|
+
}
|
|
1219
1302
|
/**
|
|
1220
1303
|
* Base options settings class for sending a batch request. Shared settings for standalone and
|
|
1221
1304
|
* cluster batch requests.
|
|
@@ -1390,4 +1473,100 @@ export interface ClusterBatchRetryStrategy {
|
|
|
1390
1473
|
*/
|
|
1391
1474
|
retryConnectionError: boolean;
|
|
1392
1475
|
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Database memory overhead statistics from MEMORY STATS.
|
|
1478
|
+
*/
|
|
1479
|
+
export interface MemoryStatsDb {
|
|
1480
|
+
/** Overhead of the expires dictionary hashtable. */
|
|
1481
|
+
overheadHashtableExpires: number;
|
|
1482
|
+
/** Overhead of the main dictionary hashtable. */
|
|
1483
|
+
overheadHashtableMain: number;
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Represents a MEMORY STATS response.
|
|
1487
|
+
*/
|
|
1488
|
+
export interface MemoryStats {
|
|
1489
|
+
/** Per-database overhead keyed by database index. */
|
|
1490
|
+
db: Record<number, MemoryStatsDb>;
|
|
1491
|
+
/** Bytes active (in use) by the allocator. */
|
|
1492
|
+
allocatorActive: number;
|
|
1493
|
+
/** Bytes allocated by the allocator. */
|
|
1494
|
+
allocatorAllocated: number;
|
|
1495
|
+
/** Bytes of allocator fragmentation. */
|
|
1496
|
+
allocatorFragmentationBytes: number;
|
|
1497
|
+
/** Bytes resident (RSS) by the allocator. */
|
|
1498
|
+
allocatorResident: number;
|
|
1499
|
+
/** Bytes of allocator RSS overhead. */
|
|
1500
|
+
allocatorRssBytes: number;
|
|
1501
|
+
/** Memory used for AOF buffer in bytes. */
|
|
1502
|
+
aofBuffer: number;
|
|
1503
|
+
/** Memory used by normal clients in bytes. */
|
|
1504
|
+
clientsNormal: number;
|
|
1505
|
+
/** Memory used by replica clients in bytes. */
|
|
1506
|
+
clientsSlaves: number;
|
|
1507
|
+
/** Memory used to store dataset in bytes. */
|
|
1508
|
+
datasetBytes: number;
|
|
1509
|
+
/** Bytes of overall fragmentation. */
|
|
1510
|
+
fragmentationBytes: number;
|
|
1511
|
+
/** Average bytes per key. */
|
|
1512
|
+
keysBytesPerKey: number;
|
|
1513
|
+
/** Total number of keys across all databases. */
|
|
1514
|
+
keysCount: number;
|
|
1515
|
+
/** Memory used by Lua caches in bytes. */
|
|
1516
|
+
luaCaches: number;
|
|
1517
|
+
/** Total memory overhead in bytes. */
|
|
1518
|
+
overheadTotal: number;
|
|
1519
|
+
/** Peak memory consumed by the server in bytes. */
|
|
1520
|
+
peakAllocated: number;
|
|
1521
|
+
/** Memory used for replication backlog in bytes. */
|
|
1522
|
+
replicationBacklog: number;
|
|
1523
|
+
/** Bytes of RSS overhead. */
|
|
1524
|
+
rssOverheadBytes: number;
|
|
1525
|
+
/** Memory consumed at startup in bytes. */
|
|
1526
|
+
startupAllocated: number;
|
|
1527
|
+
/** Total bytes allocated by the server. */
|
|
1528
|
+
totalAllocated: number;
|
|
1529
|
+
/** Ratio of allocator fragmentation. */
|
|
1530
|
+
allocatorFragmentationRatio: number;
|
|
1531
|
+
/** Ratio of allocator RSS overhead. */
|
|
1532
|
+
allocatorRssRatio: number;
|
|
1533
|
+
/** Percentage of net memory used for dataset. */
|
|
1534
|
+
datasetPercentage: number;
|
|
1535
|
+
/** Overall memory fragmentation ratio. */
|
|
1536
|
+
fragmentation: number;
|
|
1537
|
+
/** Percentage of peak.allocated out of total.allocated. */
|
|
1538
|
+
peakPercentage: number;
|
|
1539
|
+
/** Ratio of RSS overhead. */
|
|
1540
|
+
rssOverheadRatio: number;
|
|
1541
|
+
/**
|
|
1542
|
+
* Memory used by cluster links in bytes.
|
|
1543
|
+
* @remarks Redis 7.0+ only.
|
|
1544
|
+
*/
|
|
1545
|
+
clusterLinks?: number;
|
|
1546
|
+
/**
|
|
1547
|
+
* Memory used by functions caches in bytes.
|
|
1548
|
+
* @remarks Redis 7.0+ only.
|
|
1549
|
+
*/
|
|
1550
|
+
functionsCaches?: number;
|
|
1551
|
+
/**
|
|
1552
|
+
* Memory used by allocator muzzy pages in bytes.
|
|
1553
|
+
* @remarks Valkey 8.0+ only.
|
|
1554
|
+
*/
|
|
1555
|
+
allocatorMuzzy?: number;
|
|
1556
|
+
/**
|
|
1557
|
+
* Count of db dictionaries currently rehashing.
|
|
1558
|
+
* @remarks Valkey 8.0+ only.
|
|
1559
|
+
*/
|
|
1560
|
+
dbDictRehashingCount?: number;
|
|
1561
|
+
/**
|
|
1562
|
+
* Overhead of db hashtable LUT in bytes.
|
|
1563
|
+
* @remarks Valkey 8.0+ only.
|
|
1564
|
+
*/
|
|
1565
|
+
overheadDbHashtableLut?: number;
|
|
1566
|
+
/**
|
|
1567
|
+
* Overhead of db hashtable rehashing in bytes.
|
|
1568
|
+
* @remarks Valkey 8.0+ only.
|
|
1569
|
+
*/
|
|
1570
|
+
overheadDbHashtableRehashing?: number;
|
|
1571
|
+
}
|
|
1393
1572
|
export {};
|
package/build-ts/Commands.js
CHANGED
|
@@ -6,7 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.TimeUnit = exports.ScoreFilter = exports.SortOrder = exports.GeoUnit = exports.HashExpirationCondition = exports.HashFieldConditionalChange = exports.ConditionalChange = exports.FlushMode = exports.BitmapIndexType = exports.FunctionRestorePolicy = exports.InsertPosition = exports.InfBoundary = exports.UpdateByScore = exports.ExpireOptions = exports.ListDirection = exports.BitFieldOverflow = exports.BitOverflowControl = exports.BitFieldIncrBy = exports.BitFieldSet = exports.BitFieldGet = exports.BitOffsetMultiplier = exports.BitOffset = exports.UnsignedEncoding = exports.SignedEncoding = exports.BitwiseOperation = exports.InfoOptions = void 0;
|
|
9
|
+
exports.TimeUnit = exports.ClientTrackingInfo = exports.LatencyEventInfo = exports.LatencyEntry = exports.ScoreFilter = exports.SortOrder = exports.GeoUnit = exports.HashExpirationCondition = exports.HashFieldConditionalChange = exports.ConditionalChange = exports.FlushMode = exports.BitmapIndexType = exports.FunctionRestorePolicy = exports.InsertPosition = exports.InfBoundary = exports.UpdateByScore = exports.ExpireOptions = exports.ListDirection = exports.BitFieldOverflow = exports.BitOverflowControl = exports.BitFieldIncrBy = exports.BitFieldSet = exports.BitFieldGet = exports.BitOffsetMultiplier = exports.BitOffset = exports.UnsignedEncoding = exports.SignedEncoding = exports.BitwiseOperation = exports.ClientPauseMode = exports.InfoOptions = void 0;
|
|
10
10
|
exports.parseInfoResponse = parseInfoResponse;
|
|
11
11
|
exports.createGet = createGet;
|
|
12
12
|
exports.createGetDel = createGetDel;
|
|
@@ -17,6 +17,7 @@ exports.createInfo = createInfo;
|
|
|
17
17
|
exports.createDel = createDel;
|
|
18
18
|
exports.createSelect = createSelect;
|
|
19
19
|
exports.createClientGetName = createClientGetName;
|
|
20
|
+
exports.createReset = createReset;
|
|
20
21
|
exports.createConfigRewrite = createConfigRewrite;
|
|
21
22
|
exports.createConfigResetStat = createConfigResetStat;
|
|
22
23
|
exports.createMGet = createMGet;
|
|
@@ -26,6 +27,8 @@ exports.createIncr = createIncr;
|
|
|
26
27
|
exports.createIncrBy = createIncrBy;
|
|
27
28
|
exports.createIncrByFloat = createIncrByFloat;
|
|
28
29
|
exports.createClientId = createClientId;
|
|
30
|
+
exports.createClientPause = createClientPause;
|
|
31
|
+
exports.createClientUnpause = createClientUnpause;
|
|
29
32
|
exports.createConfigGet = createConfigGet;
|
|
30
33
|
exports.createConfigSet = createConfigSet;
|
|
31
34
|
exports.createHGet = createHGet;
|
|
@@ -179,6 +182,7 @@ exports.createLolwut = createLolwut;
|
|
|
179
182
|
exports.createFlushAll = createFlushAll;
|
|
180
183
|
exports.createFlushDB = createFlushDB;
|
|
181
184
|
exports.createCopy = createCopy;
|
|
185
|
+
exports.createMigrate = createMigrate;
|
|
182
186
|
exports.createMove = createMove;
|
|
183
187
|
exports.createDump = createDump;
|
|
184
188
|
exports.createRestore = createRestore;
|
|
@@ -202,6 +206,18 @@ exports.createHRandField = createHRandField;
|
|
|
202
206
|
exports.createHScan = createHScan;
|
|
203
207
|
exports.createZRandMember = createZRandMember;
|
|
204
208
|
exports.createLastSave = createLastSave;
|
|
209
|
+
exports.createSave = createSave;
|
|
210
|
+
exports.createBgSave = createBgSave;
|
|
211
|
+
exports.createBgRewriteAof = createBgRewriteAof;
|
|
212
|
+
exports.createLatencyHistory = createLatencyHistory;
|
|
213
|
+
exports.createLatencyLatest = createLatencyLatest;
|
|
214
|
+
exports.createLatencyReset = createLatencyReset;
|
|
215
|
+
exports.createClientTrackingInfo = createClientTrackingInfo;
|
|
216
|
+
exports.parseClientTrackingInfoResponse = parseClientTrackingInfoResponse;
|
|
217
|
+
exports.createMemoryDoctor = createMemoryDoctor;
|
|
218
|
+
exports.createMemoryMallocStats = createMemoryMallocStats;
|
|
219
|
+
exports.createMemoryPurge = createMemoryPurge;
|
|
220
|
+
exports.createMemoryStats = createMemoryStats;
|
|
205
221
|
exports.createLCS = createLCS;
|
|
206
222
|
exports.createTouch = createTouch;
|
|
207
223
|
exports.createRandomKey = createRandomKey;
|
|
@@ -240,6 +256,12 @@ exports.createXGroupSetid = createXGroupSetid;
|
|
|
240
256
|
exports.createScriptExists = createScriptExists;
|
|
241
257
|
exports.createScriptFlush = createScriptFlush;
|
|
242
258
|
exports.createScriptKill = createScriptKill;
|
|
259
|
+
exports.createFailover = createFailover;
|
|
260
|
+
exports.createReplicaOf = createReplicaOf;
|
|
261
|
+
exports.createReplicaOfNoOne = createReplicaOfNoOne;
|
|
262
|
+
exports.parseMemoryStatsResponse = parseMemoryStatsResponse;
|
|
263
|
+
exports.parseLatencyHistoryResponse = parseLatencyHistoryResponse;
|
|
264
|
+
exports.parseLatencyLatestResponse = parseLatencyLatestResponse;
|
|
243
265
|
/**
|
|
244
266
|
* Note: 'eslint-disable-line @typescript-eslint/no-unused-vars' is used intentionally
|
|
245
267
|
* to suppress unused import errors for types referenced only in JSDoc.
|
|
@@ -473,6 +495,12 @@ function createSelect(index) {
|
|
|
473
495
|
function createClientGetName() {
|
|
474
496
|
return createCommand(RequestType.ClientGetName, []);
|
|
475
497
|
}
|
|
498
|
+
/**
|
|
499
|
+
* @internal
|
|
500
|
+
*/
|
|
501
|
+
function createReset() {
|
|
502
|
+
return createCommand(RequestType.Reset, []);
|
|
503
|
+
}
|
|
476
504
|
/**
|
|
477
505
|
* @internal
|
|
478
506
|
*/
|
|
@@ -527,6 +555,35 @@ function createIncrByFloat(key, amount) {
|
|
|
527
555
|
function createClientId() {
|
|
528
556
|
return createCommand(RequestType.ClientId, []);
|
|
529
557
|
}
|
|
558
|
+
/**
|
|
559
|
+
* Defines the pause mode for {@link GlideClient.clientPause} and
|
|
560
|
+
* {@link GlideClusterClient.clientPause} commands.
|
|
561
|
+
*
|
|
562
|
+
* @see {@link https://valkey.io/commands/client-pause/|valkey.io} for details.
|
|
563
|
+
*/
|
|
564
|
+
var ClientPauseMode;
|
|
565
|
+
(function (ClientPauseMode) {
|
|
566
|
+
/** Pause all client commands. */
|
|
567
|
+
ClientPauseMode["ALL"] = "ALL";
|
|
568
|
+
/** Pause client write commands. */
|
|
569
|
+
ClientPauseMode["WRITE"] = "WRITE";
|
|
570
|
+
})(ClientPauseMode || (exports.ClientPauseMode = ClientPauseMode = {}));
|
|
571
|
+
/**
|
|
572
|
+
* @internal
|
|
573
|
+
*/
|
|
574
|
+
function createClientPause(timeout, mode) {
|
|
575
|
+
const args = [timeout.toString()];
|
|
576
|
+
if (mode !== undefined) {
|
|
577
|
+
args.push(mode);
|
|
578
|
+
}
|
|
579
|
+
return createCommand(RequestType.ClientPause, args);
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* @internal
|
|
583
|
+
*/
|
|
584
|
+
function createClientUnpause() {
|
|
585
|
+
return createCommand(RequestType.ClientUnpause, []);
|
|
586
|
+
}
|
|
530
587
|
/**
|
|
531
588
|
* @internal
|
|
532
589
|
*/
|
|
@@ -2367,6 +2424,36 @@ function createCopy(source, destination, options) {
|
|
|
2367
2424
|
}
|
|
2368
2425
|
return createCommand(RequestType.Copy, args);
|
|
2369
2426
|
}
|
|
2427
|
+
function createMigrate(host, port, key, destinationDB, timeout, options) {
|
|
2428
|
+
const isArray = Array.isArray(key);
|
|
2429
|
+
if (isArray && key.length === 0)
|
|
2430
|
+
throw new Error("key must not be an empty array");
|
|
2431
|
+
const args = [
|
|
2432
|
+
host,
|
|
2433
|
+
port.toString(),
|
|
2434
|
+
isArray ? "" : key,
|
|
2435
|
+
destinationDB.toString(),
|
|
2436
|
+
timeout.toString(),
|
|
2437
|
+
];
|
|
2438
|
+
if (options) {
|
|
2439
|
+
if (options.username !== undefined && options.password === undefined) {
|
|
2440
|
+
throw new Error("MigrateOptions: 'username' requires 'password' to be set");
|
|
2441
|
+
}
|
|
2442
|
+
if (options.copy)
|
|
2443
|
+
args.push("COPY");
|
|
2444
|
+
if (options.replace)
|
|
2445
|
+
args.push("REPLACE");
|
|
2446
|
+
if (options.username !== undefined && options.password !== undefined) {
|
|
2447
|
+
args.push("AUTH2", options.username, options.password);
|
|
2448
|
+
}
|
|
2449
|
+
else if (options.password !== undefined) {
|
|
2450
|
+
args.push("AUTH", options.password);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
if (isArray)
|
|
2454
|
+
args.push("KEYS", ...key);
|
|
2455
|
+
return createCommand(RequestType.Migrate, args);
|
|
2456
|
+
}
|
|
2370
2457
|
/**
|
|
2371
2458
|
* @internal
|
|
2372
2459
|
*/
|
|
@@ -2731,6 +2818,118 @@ function createLastSave() {
|
|
|
2731
2818
|
return createCommand(RequestType.LastSave, []);
|
|
2732
2819
|
}
|
|
2733
2820
|
/** @internal */
|
|
2821
|
+
function createSave() {
|
|
2822
|
+
return createCommand(RequestType.Save, []);
|
|
2823
|
+
}
|
|
2824
|
+
/** @internal */
|
|
2825
|
+
function createBgSave(args) {
|
|
2826
|
+
return createCommand(RequestType.BgSave, args ?? []);
|
|
2827
|
+
}
|
|
2828
|
+
/** @internal */
|
|
2829
|
+
function createBgRewriteAof() {
|
|
2830
|
+
return createCommand(RequestType.BgRewriteAof, []);
|
|
2831
|
+
}
|
|
2832
|
+
/**
|
|
2833
|
+
* Represents the time and latency for a latency spike.
|
|
2834
|
+
*/
|
|
2835
|
+
class LatencyEntry {
|
|
2836
|
+
/** The time of the latency spike, as a Unix timestamp in seconds. */
|
|
2837
|
+
time;
|
|
2838
|
+
/** The duration of the latency spike, in milliseconds. */
|
|
2839
|
+
latency;
|
|
2840
|
+
/** @internal */
|
|
2841
|
+
constructor(time, latency) {
|
|
2842
|
+
this.time = time;
|
|
2843
|
+
this.latency = latency;
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
exports.LatencyEntry = LatencyEntry;
|
|
2847
|
+
/**
|
|
2848
|
+
* Represents information about an event's latency spike time series.
|
|
2849
|
+
*/
|
|
2850
|
+
class LatencyEventInfo {
|
|
2851
|
+
/** The name of the event. */
|
|
2852
|
+
eventName;
|
|
2853
|
+
/** The time of the latest latency spike, as a Unix timestamp in seconds. */
|
|
2854
|
+
latestTime;
|
|
2855
|
+
/** The duration of the latest latency spike, in milliseconds. */
|
|
2856
|
+
latestDuration;
|
|
2857
|
+
/** The all-time maximum duration of a latency spike, in milliseconds. */
|
|
2858
|
+
maxDuration;
|
|
2859
|
+
/** The sum of all latency spike durations in the event's time series, in milliseconds. Only populated for Valkey 8.1+. */
|
|
2860
|
+
sum;
|
|
2861
|
+
/** The number of latency spikes recorded in the event's time series. Only populated for Valkey 8.1+. */
|
|
2862
|
+
count;
|
|
2863
|
+
/** @internal */
|
|
2864
|
+
constructor(eventName, latestTime, latestDuration, maxDuration, sum, count) {
|
|
2865
|
+
this.eventName = eventName;
|
|
2866
|
+
this.latestTime = latestTime;
|
|
2867
|
+
this.latestDuration = latestDuration;
|
|
2868
|
+
this.maxDuration = maxDuration;
|
|
2869
|
+
this.sum = sum;
|
|
2870
|
+
this.count = count;
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
exports.LatencyEventInfo = LatencyEventInfo;
|
|
2874
|
+
/** @internal */
|
|
2875
|
+
function createLatencyHistory(event) {
|
|
2876
|
+
return createCommand(RequestType.LatencyHistory, [event]);
|
|
2877
|
+
}
|
|
2878
|
+
/** @internal */
|
|
2879
|
+
function createLatencyLatest() {
|
|
2880
|
+
return createCommand(RequestType.LatencyLatest, []);
|
|
2881
|
+
}
|
|
2882
|
+
/** @internal */
|
|
2883
|
+
function createLatencyReset(events) {
|
|
2884
|
+
return createCommand(RequestType.LatencyReset, events ?? []);
|
|
2885
|
+
}
|
|
2886
|
+
/**
|
|
2887
|
+
* Represents a `CLIENT TRACKINGINFO` response.
|
|
2888
|
+
*
|
|
2889
|
+
* @see {@link https://valkey.io/commands/client-trackinginfo/|valkey.io} for details.
|
|
2890
|
+
*/
|
|
2891
|
+
class ClientTrackingInfo {
|
|
2892
|
+
/** Set of tracking flags. */
|
|
2893
|
+
flags;
|
|
2894
|
+
/** Client ID receiving invalidation messages, or -1 if not redirecting. */
|
|
2895
|
+
redirect;
|
|
2896
|
+
/** Set of key prefixes monitored for invalidation. */
|
|
2897
|
+
prefixes;
|
|
2898
|
+
constructor(flags, redirect, prefixes) {
|
|
2899
|
+
this.flags = flags;
|
|
2900
|
+
this.redirect = redirect;
|
|
2901
|
+
this.prefixes = prefixes;
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
exports.ClientTrackingInfo = ClientTrackingInfo;
|
|
2905
|
+
/** @internal */
|
|
2906
|
+
function createClientTrackingInfo() {
|
|
2907
|
+
return createCommand(RequestType.ClientTrackingInfo, []);
|
|
2908
|
+
}
|
|
2909
|
+
/**
|
|
2910
|
+
* @internal
|
|
2911
|
+
* Parses a `CLIENT TRACKINGINFO` response.
|
|
2912
|
+
*/
|
|
2913
|
+
function parseClientTrackingInfoResponse(response) {
|
|
2914
|
+
return new ClientTrackingInfo(new Set(response["flags"]), response["redirect"], new Set(response["prefixes"]));
|
|
2915
|
+
}
|
|
2916
|
+
/** @internal */
|
|
2917
|
+
function createMemoryDoctor() {
|
|
2918
|
+
return createCommand(RequestType.MemoryDoctor, []);
|
|
2919
|
+
}
|
|
2920
|
+
/** @internal */
|
|
2921
|
+
function createMemoryMallocStats() {
|
|
2922
|
+
return createCommand(RequestType.MemoryMallocStats, []);
|
|
2923
|
+
}
|
|
2924
|
+
/** @internal */
|
|
2925
|
+
function createMemoryPurge() {
|
|
2926
|
+
return createCommand(RequestType.MemoryPurge, []);
|
|
2927
|
+
}
|
|
2928
|
+
/** @internal */
|
|
2929
|
+
function createMemoryStats() {
|
|
2930
|
+
return createCommand(RequestType.MemoryStats, []);
|
|
2931
|
+
}
|
|
2932
|
+
/** @internal */
|
|
2734
2933
|
function createLCS(key1, key2, options) {
|
|
2735
2934
|
const args = [key1, key2];
|
|
2736
2935
|
if (options) {
|
|
@@ -3058,3 +3257,114 @@ function createScriptFlush(mode) {
|
|
|
3058
3257
|
function createScriptKill() {
|
|
3059
3258
|
return createCommand(RequestType.ScriptKill, []);
|
|
3060
3259
|
}
|
|
3260
|
+
/** @internal */
|
|
3261
|
+
function createFailover(options) {
|
|
3262
|
+
const args = [];
|
|
3263
|
+
if (options?.abort) {
|
|
3264
|
+
args.push("ABORT");
|
|
3265
|
+
}
|
|
3266
|
+
else {
|
|
3267
|
+
if (options?.to) {
|
|
3268
|
+
args.push("TO", options.to.host, options.to.port.toString());
|
|
3269
|
+
if (options.to.force) {
|
|
3270
|
+
args.push("FORCE");
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
if (options?.timeoutMs !== undefined) {
|
|
3274
|
+
args.push("TIMEOUT", options.timeoutMs.toString());
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
return createCommand(RequestType.FailOver, args);
|
|
3278
|
+
}
|
|
3279
|
+
/** @internal */
|
|
3280
|
+
function createReplicaOf(host, port) {
|
|
3281
|
+
return createCommand(RequestType.ReplicaOf, [host, port.toString()]);
|
|
3282
|
+
}
|
|
3283
|
+
/** @internal */
|
|
3284
|
+
function createReplicaOfNoOne() {
|
|
3285
|
+
return createCommand(RequestType.ReplicaOf, ["NO", "ONE"]);
|
|
3286
|
+
}
|
|
3287
|
+
/** @internal */
|
|
3288
|
+
const _MEMORY_STATS_DB_PREFIX = "db.";
|
|
3289
|
+
/** @internal */
|
|
3290
|
+
function _parseMemoryStatsDb(raw) {
|
|
3291
|
+
return {
|
|
3292
|
+
overheadHashtableExpires: Number(raw["overhead.hashtable.expires"]),
|
|
3293
|
+
overheadHashtableMain: Number(raw["overhead.hashtable.main"]),
|
|
3294
|
+
};
|
|
3295
|
+
}
|
|
3296
|
+
/** @internal */
|
|
3297
|
+
function parseMemoryStatsResponse(raw) {
|
|
3298
|
+
const db = {};
|
|
3299
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
3300
|
+
if (key.startsWith(_MEMORY_STATS_DB_PREFIX) &&
|
|
3301
|
+
key !== "db.dict.rehashing.count") {
|
|
3302
|
+
const dbIndex = parseInt(key.slice(_MEMORY_STATS_DB_PREFIX.length), 10);
|
|
3303
|
+
db[dbIndex] = _parseMemoryStatsDb(value);
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
return {
|
|
3307
|
+
db,
|
|
3308
|
+
allocatorActive: Number(raw["allocator.active"]),
|
|
3309
|
+
allocatorAllocated: Number(raw["allocator.allocated"]),
|
|
3310
|
+
allocatorFragmentationBytes: Number(raw["allocator-fragmentation.bytes"]),
|
|
3311
|
+
allocatorResident: Number(raw["allocator.resident"]),
|
|
3312
|
+
allocatorRssBytes: Number(raw["allocator-rss.bytes"]),
|
|
3313
|
+
aofBuffer: Number(raw["aof.buffer"]),
|
|
3314
|
+
clientsNormal: Number(raw["clients.normal"]),
|
|
3315
|
+
clientsSlaves: Number(raw["clients.slaves"]),
|
|
3316
|
+
datasetBytes: Number(raw["dataset.bytes"]),
|
|
3317
|
+
fragmentationBytes: Number(raw["fragmentation.bytes"]),
|
|
3318
|
+
keysBytesPerKey: Number(raw["keys.bytes-per-key"]),
|
|
3319
|
+
keysCount: Number(raw["keys.count"]),
|
|
3320
|
+
luaCaches: Number(raw["lua.caches"]),
|
|
3321
|
+
overheadTotal: Number(raw["overhead.total"]),
|
|
3322
|
+
peakAllocated: Number(raw["peak.allocated"]),
|
|
3323
|
+
replicationBacklog: Number(raw["replication.backlog"]),
|
|
3324
|
+
rssOverheadBytes: Number(raw["rss-overhead.bytes"]),
|
|
3325
|
+
startupAllocated: Number(raw["startup.allocated"]),
|
|
3326
|
+
totalAllocated: Number(raw["total.allocated"]),
|
|
3327
|
+
allocatorFragmentationRatio: Number(raw["allocator-fragmentation.ratio"]),
|
|
3328
|
+
allocatorRssRatio: Number(raw["allocator-rss.ratio"]),
|
|
3329
|
+
datasetPercentage: Number(raw["dataset.percentage"]),
|
|
3330
|
+
fragmentation: Number(raw["fragmentation"]),
|
|
3331
|
+
peakPercentage: Number(raw["peak.percentage"]),
|
|
3332
|
+
rssOverheadRatio: Number(raw["rss-overhead.ratio"]),
|
|
3333
|
+
// Optional Redis 7.0+ fields
|
|
3334
|
+
clusterLinks: "cluster.links" in raw ? Number(raw["cluster.links"]) : undefined,
|
|
3335
|
+
functionsCaches: "functions.caches" in raw
|
|
3336
|
+
? Number(raw["functions.caches"])
|
|
3337
|
+
: undefined,
|
|
3338
|
+
// Optional Valkey 8.0+ fields
|
|
3339
|
+
allocatorMuzzy: "allocator.muzzy" in raw
|
|
3340
|
+
? Number(raw["allocator.muzzy"])
|
|
3341
|
+
: undefined,
|
|
3342
|
+
dbDictRehashingCount: "db.dict.rehashing.count" in raw
|
|
3343
|
+
? Number(raw["db.dict.rehashing.count"])
|
|
3344
|
+
: undefined,
|
|
3345
|
+
overheadDbHashtableLut: "overhead.db.hashtable.lut" in raw
|
|
3346
|
+
? Number(raw["overhead.db.hashtable.lut"])
|
|
3347
|
+
: undefined,
|
|
3348
|
+
overheadDbHashtableRehashing: "overhead.db.hashtable.rehashing" in raw
|
|
3349
|
+
? Number(raw["overhead.db.hashtable.rehashing"])
|
|
3350
|
+
: undefined,
|
|
3351
|
+
};
|
|
3352
|
+
}
|
|
3353
|
+
/**
|
|
3354
|
+
* Parses a `LATENCY HISTORY` response.
|
|
3355
|
+
* @internal
|
|
3356
|
+
*/
|
|
3357
|
+
function parseLatencyHistoryResponse(response) {
|
|
3358
|
+
return response.map((entry) => new LatencyEntry(entry[0], entry[1]));
|
|
3359
|
+
}
|
|
3360
|
+
/**
|
|
3361
|
+
* Parses a `LATENCY LATEST` response.
|
|
3362
|
+
* @internal
|
|
3363
|
+
*/
|
|
3364
|
+
function parseLatencyLatestResponse(response) {
|
|
3365
|
+
return response.map((entry) => {
|
|
3366
|
+
const sum = entry.length >= 6 ? entry[4] : undefined;
|
|
3367
|
+
const count = entry.length >= 6 ? entry[5] : undefined;
|
|
3368
|
+
return new LatencyEventInfo(entry[0], entry[1], entry[2], entry[3], sum, count);
|
|
3369
|
+
});
|
|
3370
|
+
}
|
package/build-ts/Errors.d.ts
CHANGED
package/build-ts/Errors.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ConfigurationError = exports.ConnectionError = exports.ExecAbortError = exports.TIMEOUT_ERROR = exports.TimeoutError = exports.RequestError = exports.ClosingError = exports.ValkeyError = void 0;
|
|
6
|
+
exports.CircuitBreakerError = exports.ConfigurationError = exports.ConnectionError = exports.ExecAbortError = exports.TIMEOUT_ERROR = exports.TimeoutError = exports.RequestError = exports.ClosingError = exports.ValkeyError = void 0;
|
|
7
7
|
/// Base class for errors.
|
|
8
8
|
class ValkeyError extends Error {
|
|
9
9
|
message;
|
|
@@ -41,3 +41,6 @@ exports.ConnectionError = ConnectionError;
|
|
|
41
41
|
class ConfigurationError extends RequestError {
|
|
42
42
|
}
|
|
43
43
|
exports.ConfigurationError = ConfigurationError;
|
|
44
|
+
class CircuitBreakerError extends RequestError {
|
|
45
|
+
}
|
|
46
|
+
exports.CircuitBreakerError = CircuitBreakerError;
|