-
Notifications
You must be signed in to change notification settings - Fork 169
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
feature request: adding an option to disable dial on creating client #489
Comments
Hi @mehdipourfar, If redis servers go down after the initialization, rueidis will try reconnection automatically and can work as you want. rueidis has a good reason to return an error at initialization, allowing users to verify whether their config for establishing a Redis connection is correct or not. I generally recommend users to fail fast and fix fast. Indeed, this approach will interrupt service startup if their config is correct but Redis server are not ready. However, there is another purpose of initialization which I think is the true blocker to your request: choosing the correct client implementation. Currently, rueidis will connect to the server to check if it is a Redis cluster. If yes, then the initialization returns a cluster client implementation, otherwise returns a standalone client implementation. If we let this behavior be configurable, then we can return a concrete client implementation instead of a nil even when the initialization has failed. |
Thanks for your reply. What happens if we do not try to |
You will have no chance to know whether your config is wrong or not before sending your first redis request. |
I think we should keep the Dail() even if we make the auto-detection configurable. Users can just ignore the error returned by the initialization if they don't care about it. |
That would solve my problem if we don't return nil as client. |
Hey @rueian, can we clarify the description and expected change of this task for a potential implementation? |
Hi @erdemtuna, The goal is to make the Since we already have the option
|
Thanks @rueian, I will work on the issue and communicate wherever necessary. |
Hi @rueian, I came up with these edits as a basic try however, I cannot make them work in the following scenario:
I seem to be stuck as of now. If someone could guide me, I would appreciate it. Otherwise, I should stop working on the issue. |
Hi @erdemtuna, could you elaborate more on how you are being stuck? |
@erdemtuna Would you like to continue on this otherwise I can pick it up |
When we initialize a redis client with go-redis, it does not return any error. I think this is a very good feature. Imagine I use redis in my web service only as a cache. If it goes down, it is still ok and I can use the main repository for fetching my data. If it goes up during the service runtime, I will use that cache again. But this package returns nil and error if it cannot connect to redis on initialization and I don't want to interrupt my service start up because my redis server is out of reach.
The text was updated successfully, but these errors were encountered: