Skip to content

pubsub: add ClientSetName method to PubSub#3727

Merged
ndyakov merged 1 commit into
redis:masterfrom
Flack74:feature/pubsub-client-setname
Mar 9, 2026
Merged

pubsub: add ClientSetName method to PubSub#3727
ndyakov merged 1 commit into
redis:masterfrom
Flack74:feature/pubsub-client-setname

Conversation

@Flack74

@Flack74 Flack74 commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #3708

What

Adds ClientSetName(ctx context.Context, name string) error to *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 LIST output. This is useful
for debugging environments with many concurrent connections.

How

Follows the same pattern as Ping() — acquires the mutex, gets the
connection, 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 PubSub struct and re-apply it in resubscribe().


Note

Low Risk
Low risk: adds a small, mutex-protected helper that issues CLIENT SETNAME and 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 Redis CLIENT SETNAME, following the existing Ping() write/lock/release pattern.

Adds a new test that subscribes, calls ClientSetName, and asserts the name appears in CLIENT LIST output.

Written by Cursor Bugbot for commit 20a9ab8. This will update automatically on new commits. Configure here.

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
@jit-ci

jit-ci Bot commented Mar 2, 2026

Copy link
Copy Markdown

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.

@ndyakov

ndyakov commented Mar 4, 2026

Copy link
Copy Markdown
Member

Thank you @Flack74, I think this should work for addressing the feature request.

@ndyakov ndyakov added the feature label Mar 4, 2026
@ndyakov ndyakov self-requested a review March 4, 2026 10:58
@ndyakov ndyakov merged commit 78ae5e5 into redis:master Mar 9, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A way to CLIENT SETNAME when using pubsub

2 participants