[12.x] LostConnectionDetector and ConcurrencyErrorDetector #56493
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.
Currently there is no way to extend logic of DetectsLostConnections and DetectsConcurrencyErrors traits. The existing list of exception strings does not cover the list of all possible exceptions that may indicate a connection loss.
For example, we had an error
Predis\Connection\ConnectionException
with the textConnection timed out [tcp://1.2.3.4:6379]
when working with predis and it did not resolved new addresses after redis node restart. Of course, traits do not provide exceptions for custom database and queues drivers. Therefore, the ability to extend their behavior may be required, but this is impossible while the logic is in the trait.In this MR, the logic is transferred from traits to separate contracts and classes, which can then be extended by application users.
Changes are expected to be backward compatible with current version.
As far as this traits are used as a part of databaseManager, that can be used outside of laravel with Capsule, it tries to take detector from container, with fallback to default implementation