Skip to content
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

Ping dependencies #198

Open
Tishka17 opened this issue Aug 4, 2024 · 2 comments
Open

Ping dependencies #198

Tishka17 opened this issue Aug 4, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Tishka17
Copy link
Collaborator

Tishka17 commented Aug 4, 2024

Add separate decorator to provide ping functionality. It has no scope during declaration and can be used to run specific code declated in providers:

Declaration:

class Provider:
   @ping
   def foo(self) -> None:
         print("PING")
   @ping
   def bar(self, session: Session) -> None:
         session.execute(select(1))
         print("PING SESSION")

Usage:

container.ping()

That call will find all pings declared with current and parent scopes and request them

Discuss: should we unify this technic?

@Tishka17 Tishka17 added the enhancement New feature or request label Aug 4, 2024
@Tishka17
Copy link
Collaborator Author

Tishka17 commented Aug 4, 2024

Discuss: auto calculation of scope based on dependencies vs explicit scope

@Forceres
Copy link

Discuss: auto calculation of scope based on dependencies vs explicit scope

Good discussion point, there is a boundary between code readability and developer experience. Auto calculation can be good convenient option (NestJS DI System has it), but it can be difficult to read dependency source from a lot of nested providers (modules)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants