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

Proposal (v2): Injector should implement context.Context #92

Open
diamondburned opened this issue Oct 25, 2024 · 0 comments
Open

Proposal (v2): Injector should implement context.Context #92

diamondburned opened this issue Oct 25, 2024 · 0 comments

Comments

@diamondburned
Copy link

Currently, do provides a Shutdown API for shutting down which can perform I/O or long-running operations, and ShutdownWithContext exists to allow the user to pass their context down to those operations. However, there isn't a Start equivalent for initializing services. As a result, the constructor is the only place to perform service initialization.

A problem arises when the constructor also tries to perform I/O or long-running operations, such as connecting to a database. There isn't a way to pass the user's context to those operations during construction. In my opinion, the easiest solution to this problem would be to:

  1. Make do.Injector also implement context.Context, and
  2. Add func do.InvokeContext[T](context.Context, do.Injector)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant