pubsub: add ClientSetName method to PubSub#3727
Merged
Merged
Conversation
Adds ClientSetName(ctx, name string) error to *PubSub, allowing callers to label the underlying connection via CLIENT SETNAME. The name appears in CLIENT LIST output, useful for identifying PubSub connections when debugging. Follows the same pattern as Ping() — acquires mutex, gets conn, writes command, releases conn. Note: if the connection drops and reconnects, the name will be lost and must be set again. Closes redis#3708
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
Member
|
Thank you @Flack74, I think this should work for addressing the feature request. |
ndyakov
approved these changes
Mar 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3708
What
Adds
ClientSetName(ctx context.Context, name string) errorto*PubSub,allowing callers to label the underlying connection using
CLIENT SETNAME.Why
Currently there is no way to name a PubSub connection, making it
impossible to identify it in
CLIENT LISToutput. This is usefulfor debugging environments with many concurrent connections.
How
Follows the same pattern as
Ping()— acquires the mutex, gets theconnection, writes the command, releases the connection.
Known Limitation
If the connection drops and reconnects, the name will be lost and
must be set again by the caller. A future improvement could store
the name in the
PubSubstruct and re-apply it inresubscribe().Note
Low Risk
Low risk: adds a small, mutex-protected helper that issues
CLIENT SETNAMEand a single integration test; no changes to message handling or reconnect logic.Overview
Adds
(*PubSub).ClientSetName(ctx, name)to label the underlying PubSub connection via RedisCLIENT SETNAME, following the existingPing()write/lock/release pattern.Adds a new test that subscribes, calls
ClientSetName, and asserts the name appears inCLIENT LISToutput.Written by Cursor Bugbot for commit 20a9ab8. This will update automatically on new commits. Configure here.