Skip to content

Closing callback for a node client in ClusterClient #2800

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

Closed
lzakharov opened this issue Nov 16, 2023 · 2 comments
Closed

Closing callback for a node client in ClusterClient #2800

lzakharov opened this issue Nov 16, 2023 · 2 comments
Labels

Comments

@lzakharov
Copy link
Contributor

lzakharov commented Nov 16, 2023

Good day!

Is there any option to set the closing callback for a node client in ClusterClient?

Use Case
I want to start metrics collection process on every new node client creation and stop it when the node client is removed for some reason. To stop the process I have to provide a callback somehow. To start the process I can use ClusterClient.OnNewNode.

Ideas
One solution that comes to my mind is to add a callback to the return function that the ClusterClient.OnNewNode accepts:

func (c *ClusterClient) OnNewNode(fn func(rdb *Client) func()) {
	...
}

This callback should be added to the clusterNode and called inside it's Close method.

However, to avoid breaking backward compatibility, it's possible to add a separate method for ClusterClient, such as OnNewNodeWithClose.

Another idea is to expand the redis.Hook interface to provide additional CloseHook method.

Thanks for any feedback in advance.

@lzakharov
Copy link
Contributor Author

Another option is to make the baseClient.onClose configurable.

Copy link

This issue is marked stale. It will be closed in 30 days if it is not updated.

@github-actions github-actions bot added the Stale label Apr 15, 2025
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant