-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[8.x] Introduce scoped instances #37521
Conversation
If there's any chance of having the reset of Http instances within the framework itself it would be awesome because we get to use this outside of Octane e.g. within a long-lived Http Kernel in AWS Lambda with Bref. I already have a use case that would benefit from the worker reset |
@deleugpn you can call |
So is the main goal for this PR to allow packages to define bindings that should be flushed before handling another "task"? |
@taylorotwell yes. And also allow app developers to choose between |
Instead of injecting a closure into the queue system, I wonder if the |
@taylorotwell I noticed we don't use listeners in core ServiceProviders. I think it's because tracking those listeners won't be easy when you're browsing the code and try to debug stuff. If it's ok to use a listener in a service provider then yes I think we can do that in the QueueServiceProvider. |
@themsaid is there any way to refresh the scoped instances after flushing in other services where they are injected as dependency? |
@Brenneisen I'm afraid not. You'll need to make those other services scoped as well. |
@themsaid |
@hubertnnn coroutine support requires a lot of work and changes. When it's time we tackle it we'll have multiple scopes. |
Scoped instances are singletons that must be flushed while switching the application context. e.g.
1- On a new Octane request.
2- Before processing a new queued job.
In this PR, I only reset the scope before processing queued jobs. I original reset the scope inside
HttpKernel::handle()
but I figured the scope needs resetting earlier than that when handling an HTTP request. So if this request was merged, I'll add the scope resetting to Octane once the sandbox instance is cloned.