1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

V5 bringing RESP3, Sentinel and TypeMapping to node-redis

RESP3 Support
   - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion.
 
Sentinel

TypeMapping

Correctly types Multi commands

Note: some API changes to be further documented in v4-to-v5.md
This commit is contained in:
Shaya Potter
2024-10-15 17:46:52 +03:00
committed by GitHub
parent 2fc79bdfb3
commit b2d35c5286
1174 changed files with 45931 additions and 36274 deletions

View File

@@ -1,84 +1,88 @@
import { RedisCommandRawReply } from './commands';
export class AbortError extends Error {
constructor() {
super('The command was aborted');
}
constructor() {
super('The command was aborted');
}
}
export class WatchError extends Error {
constructor() {
super('One (or more) of the watched keys has been changed');
}
constructor(message = 'One (or more) of the watched keys has been changed') {
super(message);
}
}
export class ConnectionTimeoutError extends Error {
constructor() {
super('Connection timeout');
}
constructor() {
super('Connection timeout');
}
}
export class ClientClosedError extends Error {
constructor() {
super('The client is closed');
}
constructor() {
super('The client is closed');
}
}
export class ClientOfflineError extends Error {
constructor() {
super('The client is offline');
}
constructor() {
super('The client is offline');
}
}
export class DisconnectsClientError extends Error {
constructor() {
super('Disconnects client');
}
constructor() {
super('Disconnects client');
}
}
export class SocketClosedUnexpectedlyError extends Error {
constructor() {
super('Socket closed unexpectedly');
}
constructor() {
super('Socket closed unexpectedly');
}
}
export class RootNodesUnavailableError extends Error {
constructor() {
super('All the root nodes are unavailable');
}
constructor() {
super('All the root nodes are unavailable');
}
}
export class ReconnectStrategyError extends Error {
originalError: Error;
socketError: unknown;
originalError: Error;
socketError: unknown;
constructor(originalError: Error, socketError: unknown) {
super(originalError.message);
this.originalError = originalError;
this.socketError = socketError;
}
constructor(originalError: Error, socketError: unknown) {
super(originalError.message);
this.originalError = originalError;
this.socketError = socketError;
}
}
export class ErrorReply extends Error {
constructor(message: string) {
super(message);
this.stack = undefined;
}
constructor(message: string) {
super(message);
this.stack = undefined;
}
}
export class SimpleError extends ErrorReply {}
export class BlobError extends ErrorReply {}
export class TimeoutError extends Error {}
export class MultiErrorReply extends ErrorReply {
replies;
errorIndexes;
replies: Array<ErrorReply>;
errorIndexes: Array<number>;
constructor(replies: Array<RedisCommandRawReply | ErrorReply>, errorIndexes: Array<number>) {
super(`${errorIndexes.length} commands failed, see .replies and .errorIndexes for more information`);
this.replies = replies;
this.errorIndexes = errorIndexes;
}
constructor(replies: Array<ErrorReply>, errorIndexes: Array<number>) {
super(`${errorIndexes.length} commands failed, see .replies and .errorIndexes for more information`);
this.replies = replies;
this.errorIndexes = errorIndexes;
}
*errors() {
for (const index of this.errorIndexes) {
yield this.replies[index];
}
*errors() {
for (const index of this.errorIndexes) {
yield this.replies[index];
}
}
}