Skip to content

feat: add ForEachMaster method to rueidiscompat Cmdable interface#982

Merged
rueian merged 2 commits intoredis:mainfrom
SoulPancake:feat/for-each-master
Apr 15, 2026
Merged

feat: add ForEachMaster method to rueidiscompat Cmdable interface#982
rueian merged 2 commits intoredis:mainfrom
SoulPancake:feat/for-each-master

Conversation

@SoulPancake
Copy link
Copy Markdown
Contributor

@SoulPancake SoulPancake commented Apr 12, 2026

Add ForEachMaster to the Cmdable interface and implement it on Compat. It concurrently calls a function on each master node in the cluster, delegating to the existing doPrimaries method.


Note

Medium Risk
Public interface expansion can be breaking for any external Cmdable implementations and introduces a new concurrent execution entrypoint whose error/role handling must remain correct across cluster nodes.

Overview
Adds a new Cmdable.ForEachMaster(ctx, fn) API to run a callback concurrently against each master node in a Redis cluster, returning the first error encountered.

Implements ForEachMaster on Compat by delegating to existing doPrimaries and passing a per-node Cmdable wrapper into the callback; Pipeline now satisfies the expanded interface with a stub that panics. Adds comprehensive unit tests covering master filtering, error propagation, empty/no-master cases, and ensuring the callback receives a working wrapped client.

Reviewed by Cursor Bugbot for commit 46f1c8f. Bugbot is set up for automated code reviews on this repo. Configure here.

Add ForEachMaster to the Cmdable interface and implement it on Compat.
It concurrently calls a function on each master node in the cluster,
delegating to the existing doPrimaries method. Includes comprehensive
unit tests covering master/replica filtering, error handling, empty
nodes, and Cmdable wrapping.

Agent-Logs-Url: https://github.com/SoulPancake/rueidis/sessions/dc7821d0-d23a-4637-8634-0fc80e4aae45

Co-authored-by: SoulPancake <70265851+SoulPancake@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@rueian rueian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are build failures and please remove the rueidiscompat.test

@SoulPancake SoulPancake requested a review from rueian April 14, 2026 08:56
@rueian rueian merged commit 6110040 into redis:main Apr 15, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants