What is svcs?
mainsvcs (pronounced services) is a dependency container for Python designed to implement Inversion of Control (IoC) via dependency injection or service location. It provides a central registry for service factories, allowing you to acquire instances of specific types/interfaces with automatic cleanup and built-in health checks.
Key features include:
- Automatic Cleanup: Services are managed via context managers, ensuring they are cleaned up automatically when the acquisition context ends.
- Static Type Safety: It provides full support for static type checkers (like mypy or pyright) by forwarding requested types, though it does not perform runtime type checking.
- Loose Coupling: Simplifies testing by decoupling service acquisition from implementation.
- Monitoring: Supports live introspection and monitoring through health checks.
- No Global State: Avoids the use of global state, decorators, or function signature mangling.