What problem does it solve?
DynProvider Skill simplifies the registration and management of external types within the dependency injection framework, allowing for more flexible and dynamic dependencies.
Core Features & Use Cases
- External Type Registration: Dynamically register external types (sync, async, with-context, from-value) using a token string for each registration.
- Token-Based Providers: Differentiate between multiple providers of the same type using distinct tokens (e.g., "primary"/"replica" pools).
- Use Case: In a microservices architecture, use DynProvider to register different database pools for primary and replica services, managing their lifecycles and configurations separately.
Quick Start
Register a sync DynProvider with a default token:
use injectable::prelude::*;
Container::builder()
.register("", DynProvider::sync(|| {
Ok(reqwest::Client::new())
}))
.build().await?;