-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] add LazyString
for lazy computation of string values injected into services
#34013
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
Conversation
should we support lazy-loading a service reference in a |
6bce16d
to
aebd082
Compare
good idea, updated |
aebd082
to
ea7db68
Compare
ea7db68
to
516d9a9
Compare
(fabbot failure is false positive) |
516d9a9
to
bd260dd
Compare
Could we do something similar, yet different, for string formatting? Some languages / libraries offer a string interpolation / formatting function which is lazily evaluated. An example use case is constructing a log message, which may or not be evaluated depending on the log level. |
@Devristo I feel like that's what this provides already: |
bd260dd
to
dd413c8
Compare
dd413c8
to
ccb0365
Compare
Thank you @nicolas-grekas. |
…alues injected into services (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [DI] add `LazyString` for lazy computation of string values injected into services | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - This is an idea I should have had years ago :) By wrapping any callable into a `LazyString`, we allow resolving the corresponding string value lazily (eg because the value comes from a remote server). The tricky parts are memoization and error handling, which are both dealt with in the class. This is currently part of #33997 Commits ------- ccb0365 [DI] add `LazyString` for lazy computation of string values injected into services
…s-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [EventDispatcher] handle lazy-callable invokable | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Extracted from #34013, for consistency mostly. Commits ------- 9df4c7d [EventDispatcher] handle lazy-callable invokable
This is an idea I should have had years ago :)
By wrapping any callable into a
LazyString
, we allow resolving the corresponding string value lazily (eg because the value comes from a remote server).The tricky parts are memoization and error handling, which are both dealt with in the class.
This is currently part of #33997