-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
A Generic Host encapsulates Dependency Injection, Logging, and Configuration in a nice, easy package.
Our current setup seems to want to achieve this but does this in a sort of homebrew way.
Changes to make to implement this:
- Rewrite
Program.csto use a generic host - Services will be injected and hosted as either a singleton or in a scoped context.
- Service and module dependencies will be injected (automatically) into the constructor.
Benefits of using a Generic Host:
- Error handling is more intuitive
- Scoped services can be created and destroyed as needed, proving some light scaling.
- Resources are injected through the constructor, meaning they're easily available
- Scoped
ILogger<TService>instances - Configurations constructed from multiple sources, such as json configs, environment variables, or command line arguments, and injected as an
IOptions<TConfiguration>object. - Easy implementation of libraries to assist the bot with growth, such as MediatR.
If this is something we might be interested in, I would be happy to build a PR with all of the necessary tests.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels