Skip to content
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

feat: support set hooks option in new client API #2752

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zcong1993
Copy link

#2557 go-redis v9 AddHook API cause data race issue.

This pr allow users set hooks in options for NewClient APIs, this will not cause data race. And IMO in most cases, users only need to set up hooks when initialize the client like grpc Dial(WithUnaryInterceptor()), and not need to add hooks dynamically at runtime with AddHook.

fix #2557

@ofekshenawa
Copy link
Collaborator

@zcong1993 Could you please add tests for this issue? This will allow us to continue monitoring it in the future.

@@ -144,6 +144,9 @@ type Options struct {

// Disable set-lib on connect. Default is false.
DisableIndentity bool

// Hooks are initial hooks in options like AddHook.
Hooks []Hook

Choose a reason for hiding this comment

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

The Hooks array should be validated during initialization to ensure that invalid or nil hooks are not added. This can help prevent runtime issues and maintain the integrity of the client setup.

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.

Race detector checking failed for AddHook API in redis v9
3 participants