What problem does it solve?
The Skill addresses the need for scoped resolution of injectable types within dynamic provider contexts, ensuring that dependencies are resolved in a safe and efficient manner without bypassing the singleton cache.
Core Features & Use Cases
- Scoped Resolution: Allows for the safe resolution of injectable or external types within
DynProvider::with_ctx closures.
- Singleton Cache Utilization: Ensures that singleton dependencies are resolved within their intended scope, avoiding cache bypassing.
- Use Case: When a dynamic provider factory needs to resolve other injectable types without affecting the singleton cache,
FactoryCtx is a useful tool.
Quick Start
To utilize FactoryCtx, include the following in your Skill code:
let container = Container::builder()
.register(DynProvider::with_ctx(|ctx| async move {
// Resolve AppConfig via FactoryCtx
let cfg: Inject<AppConfig> = ctx.extract().await?;
// Further operations...
}))
.build().await?;