-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Allow reseting of env vars loaded by EnvVarLoaderInterface implementations #54627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like a good idea to me. Up for a PR? |
Yes, I can try. Thanks. |
Would that work in the end? symfony/src/Symfony/Component/DependencyInjection/Container.php Lines 339 to 372 in 5ae5791
|
Indeed, those would need to be reset as well, thanks I had missed that. |
Description
Services tagged with
container.env_var_loader
are loaded by EnvVarProcessor to load env vars dynamically. Right now there is no way to reset such env vars once they're loaded mainly because they're cached in memory once loaded . This seems by design to improve performance, however, it limits the usage of EnvVarLoader in messenger context say with a multi-tenant app where a single worker can handle messages from various tenants.This slack thread might give a bit more context https://symfony-devs.slack.com/archives/C8WHX21K7/p1713264333709759
Possible solution:
EnvVarProcessor
can possibly implement reset interface and allow reseting some env vars (maybe via a config option?), especially the ones which are loaded byEnvVarLoaderInterface
implementations, since the env vars loaded by EnvVarLoaderInterface aren't actual env vars and are dynamic (or runtime) by definition to begin with, it makes sense to allow resetting them.This would allow using symfony messenger easily in a multi-tenant app where env vars are loaded based on tenant id.
Example
No response
The text was updated successfully, but these errors were encountered: