Repository navigation
#53 - Load the cache adapters lazily from a service locator indexed by code - #54
Merged
Merged
Conversation
…y code - RegisterAdaptersPass: the services tagged cleverage.cache.adapter with a code attribute are registered in a service locator passed to the AdapterRegistry (new optional constructor argument): an adapter is only instantiated when a task uses it. Duplicate or empty codes fail the container compilation. Without code, the adapter is still registered with addAdapter(), now deprecated (the code will be required in 3.0). - AdapterRegistry: getAdapter() checks that the service implements AdapterInterface and that its getCode() is the code of the tag; new hasAdapter() and getAdapters() (instantiates every adapter), as the client registries of the rest and soap bundles. - New #[AsCacheAdapter(code: '...')] attribute (autoconfiguration), adding the tag with its code. - Require symfony/service-contracts (ServiceProviderInterface). - Docs: code attribute in every example, registration notes. Same model as process-bundle#276 (TransformerRegistry), rest#58 and soap#52. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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
Fixes #53. Same model as process-bundle#276 (
TransformerLocatorCompilerPass/TransformerRegistry), cleverage/rest-process-bundle#59 and cleverage/soap-process-bundle#53.RegisterAdaptersPass: the services taggedcleverage.cache.adapterwith acodeattribute (- { name: cleverage.cache.adapter, code: memory }) are registered in a service locator, passed toAdapterRegistry(new optional constructor argument): an adapter is only instantiated when a task uses it. Duplicate or empty codes fail the container compilation, with the service ids.codeis still registered withAdapterRegistry::addAdapter()(eager), now deprecated since 2.3: thecodewill be required in 3.0.AdapterRegistry::getAdapter()checks that the service implementsAdapterInterfaceand that itsgetCode()returns the code of the tag; newhasAdapter()andgetAdapters()(instantiates every adapter), as the client registries of the rest and soap bundles.#[AsCacheAdapter(code: '...')]attribute (registerAttributeForAutoconfiguration()), adding the tag with its code.AdapterInterfaceitself is not autoconfigured: it would tag twice theMemoryAdapterof the demo (loaded by theApp\resource and redefined in another service), see the issue.symfony/service-contracts(ServiceProviderInterface, already installed through process-bundle).codeattribute in every example, registration notes.Checked in process-bundle-demo (patch applied to the vendor), the 6
demo.cache.*processes:code): same exit codes as onmain(the three failures are expected by these demos), deprecations logged;codeattribute on thememoryadapter: same exit codes, no deprecation,lint:containerOK.Tests with coverage (pcov): 100% lines, no risky test.
The demo declaration will be updated in a demo PR (the
codeattribute is ignored by the previous versions).Requirements
Breaking changes
None: the adapters tagged without
codekeep working, with a deprecation (2.3, removal in 3.0). Behaviour change: the adapters with acodeare no longer instantiated with the registry.🤖 Generated with Claude Code