feat(config): add per-client class override option#760
Open
guillaumedelre wants to merge 2 commits into
Open
Conversation
Add an optional `class` key to the client configuration, allowing users
to specify a custom client class for each client individually.
Previously the only way to override the instantiated class was via a
compiler pass. This change makes it possible through config:
snc_redis:
clients:
default:
type: predis
dsn: redis://localhost
class: App\Redis\CustomPredisClient
The `class` option takes precedence over the global
`snc_redis.class.client` / `snc_redis.class.phpredis_client` settings
and applies to predis, phpredis and relay client types.
Closes snc#729
Signed-off-by: Guillaume Delré <delre.guillaume@gmail.com>
This was referenced May 11, 2026
ostrolucky
requested changes
May 11, 2026
Replace two separate `testPredisCustomClass` / `testPhpRedisCustomClass` methods with a single `@testWith` parametrized test using non-default class names, so the tests actually exercise the override rather than confirming the default. Move the `class` option out of its own docs section and into the Complete configuration example. Signed-off-by: Guillaume Delré <delre.guillaume@gmail.com>
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.
Summary
classkey to the client configuration to allow specifying a custom client class per clientsnc_redis.class.client/snc_redis.class.phpredis_clientsettingspredis,phpredisandrelayclient typesMotivation
Closes #729 — there was no way to override the instantiated class for a specific client without writing a compiler pass. This adds a straightforward config option:
Test plan
testPredisCustomClass— verifies the DI definition uses the configured class for a predis clienttestPhpRedisCustomClass— verifies the DI definition uses the configured class for a phpredis clientSncRedisExtensionTest, same 5 pre-existing failures due to ext-redis unavailable locally)