Make Closing marker working with providers that contains a resource as argument
See original GitHub issueHi!
Is it possible to make the Closing marker work with all types providers that contain a resource inside? For example, in the following code, the Closing marker does not work:
# handlers
@inject
async def create_project(
request: web.Request,
project_repository: ProjectRepository = Closing[Provide[Container.project_repository]],
) -> web.Response:
....
# di
class Container(containers.DeclarativeContainer):
db_session = providers.Resource(get_session, database=db)
project_repository = providers.Factory(
ProjectRepository,
session=db_session
)
At this moment it will work if we add a separate resource argument to handler:
@inject
async def create_project(
request: web.Request,
project_repository: Session = Closing[Provide[Container.db_session]],
project_repository: ProjectRepository = Closing[Provide[Container.project_repository]],
) -> web.Response:
....
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Resource provider - Dependency Injector
Resource provider provides a component with initialization and shutdown. It works well for configuring logging, event loop, thread or process pool, etc.
Read more >Resource leak: 'in' is never closed - java - Stack Overflow
above line will invoke Constructor of Scanner class with argument System.in, and will return a reference to newly constructed object. It is connected...
Read more >The Resource provider Meta-Argument - HashiCorp Developer
The provider meta-argument specifies the provider configuration Terraform should use for a resource, overriding Terraform's default behavior.
Read more >Marker | Maps JavaScript API - Google Developers
Creates a marker with the options specified. If a map is specified, the marker is added to the map upon construction. Note that...
Read more >6. Resources - Spring
The Resource abstraction is used extensively in Spring itself, as an argument type in many method signatures when a resource is needed.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kiriharu until it’s merged, it can be monkey patched with the following code
Amazing feature! Thanks to everybody involved and special thanks to @StummeJ for the PR!