Skip to content

Question: Create an instance of providers.Singleton at the same time as fastapi starts. #448

Open
@satodaiki

Description

@satodaiki

Hello.

As the title suggests, what should I do with the definition of providers.Singleton that instantiates at the same time as fastapi starts!

I want to generate the following "manager" at the start of fastapi.
(Dependency injection of application_service in manager may be implemented incorrectly.)

class Container(containers.DeclarativeContainer):

    application_service = providers.Factory(
        ApplicationService,
    )

    manager = providers.Singleton(
        Manager,
        application_service=application_service(), # Inject the above application_service dependency.
    )

Do you have any good ideas?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions