Conversation
Signed-off-by: monkey92t <golang@88.com>
|
/cc @vmihailenco @elena-kolevska @chayim @SoulPancake Are you interested? You can share your opinions. 😊 |
|
This is a simple usage example: func TestRedisPlugin(t *testing.T) {
client := redis.NewClient(&redis.Options{
Addr: "127.0.0.1:6379",
})
ctx := context.Background()
client.RegistryPostInitConnPlugin(func(ctx context.Context, conn *redis.Conn) error {
conn.ClientSetName(ctx, "test-client")
return nil
})
client.RegistryInitConnPlugin(func(ctx context.Context, conn *redis.Conn) error {
username, auth := awsAuth(token)
return conn.AuthACL(ctx, username, auth).Err()
})
t.Log(client.Ping(ctx).Err())
}In this example, the issue described in #2537 has been addressed. The Redis authentication process has been customized by dynamically retrieving AWS authentication information. |
|
Based off of this, |
|
We treat them as special API, distinct from regular commands. |
|
Hello @monkey92t , do you plan to work on this or we can close it? I am trying to clean up the PRs and the issues. |
|
I assume this can be closed for now. @monkey92t let me know if you would like to continue the work, I would suggest a new branch based of the current state of master. Thank you! |
This PR added the plugin functionality for network connection. Currently, it supports three plugin hook points: PreInitConnPlugin, InitConnPlugin, and PostInitConnPlugin.
Its functions are as follows:
Currently, only the basic functionalities have been implemented, and there is no support for client features like cluster/sentinel/ring. Testing and documentation have not been added either. After receiving feedback from everyone, further improvements will be made.
Additionally, this may be influenced by #2586.