Skip to content

[CAE-342] Initial sentinel issues fix #2912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
203 changes: 176 additions & 27 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@
"tsx": "^4.7.0",
"typedoc": "^0.25.7",
"typescript": "^5.3.3"
},
"dependencies": {
"ts-node": "^10.9.2"
}
}
17 changes: 17 additions & 0 deletions packages/client/lib/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ export default class RedisClient<
#monitorCallback?: MonitorCallback<TYPE_MAPPING>;
private _self = this;
private _commandOptions?: CommandOptions<TYPE_MAPPING>;
// flag used to annotate that the client
// was in a watch transaction when
// a topology change occured
#dirtyWatch?: string;
#epoch: number;
#watchEpoch?: number;
Expand All @@ -325,6 +328,20 @@ export default class RedisClient<
return this._self.#watchEpoch !== undefined;
}

/**
* Indicates whether the client's WATCH command has been invalidated by a topology change.
* When this returns true, any transaction using WATCH will fail with a WatchError.
* @returns true if the watched keys have been modified, false otherwise
*/
get isDirtyWatch(): boolean {
return this._self.#dirtyWatch !== undefined
}

/**
* Marks the client's WATCH command as invalidated due to a topology change.
* This will cause any subsequent EXEC in a transaction to fail with a WatchError.
* @param msg - The error message explaining why the WATCH is dirty
*/
setDirtyWatch(msg: string) {
this._self.#dirtyWatch = msg;
}
Expand Down
Loading
Loading