[6.x] Normalize scheme in Redis connections#33892
Merged
taylorotwell merged 2 commits intolaravel:6.xfrom Aug 17, 2020
Merged
Conversation
Member
|
@sebdesign this seems to have broken some things. See #34018 & #34017 Can you please take a look at this? |
Contributor
Author
|
@driesvints I'll look into it right now. |
This was referenced Aug 27, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR attempts to improve the consistency between
PredisandPhpRedisdrivers regarding the configuration of thescheme.Current behavior
By default both drivers are connecting to the Redis server using
tcp. It is possible to configure the scheme but each driver requires a different setup:schemekey in the$parametersarray of its constructor. E.g.'scheme' => 'tls'.$hoststring of its constructor. E.g.tls://127.0.0.1.In Laravel that means we have to use different configurations in
database.php:Since #33800 was merged, it is possible to define the scheme using the
urlkey forphpredis. Theurlbeing parsed transforms thehostin the correct format astls://127.0.0.1:But using the
urlkey for the predis driver results in a connection error, because thehostis again formatted astls://127.0.0.1but the client has its scheme astcpinternally, so it tries to connect totcp://tls://127.0.0.1:6379which is invalid.Proposed changes
With this PR, it is possible to use the
schemekey as well as theurlkey for both drivers, thus improving the consistency in the configuration and allowing to switch drivers more easily:Instead of formatting the
hostinRedisManagerlike the aforementioned PR does, it assigns theschemekey in the configuration, which will be handled in the connectors: ThePredisConnectorwill pass it to the client's constructor, and thePhpRedisConnectorwill format thehostusing theschemeif it was defined in the configuration or parsed from theurl.This change has no breaking changes, as it follows the functionality of the previous PR, allowing
redis://protocols as well astcp://andtls://in theurlkey. It's also compatible with the existing functionality regarding theschemekey for the predis driver.Summary
schemein theurlkey forpredisschemekey forphpredisschemein theurlkey forphpredisremains the sameschemekey forpredisremains the sameclustersschemeorurlConfigurationUrlParserreturns the correctdriverfor Redis URLs with scheme