Add parsing of multiple URLs for cluster mode in redis #1923
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does
This PR adds a new function,
ParseClusterURLs
, which takes an array of strings and turns it into the array of addresses used for redis in cluster mode along with configurations passed in.How it works
It is very similar to the
ParseURL
function, except for this function loops through an array of URLs. It will get the username and password for the cluster as well as configurations sent in through the query parameters.Since the connection to the cluster can only have one username and password, if it differs between URLs in the array, the function will fail. Additionally, if the schemes differ, it will fail. I did not implement checks on the query parameters differing. If we want this done, I definitely could do it, but with the defaults and the init function it starts getting a bit uglier to check for all of those. If the query parameters do differ, it will use the last one in the array.
Example of arrays that will succeed:
Example of arrays that will fail: