Loading...
Loading...
Designs and reviews Forze dependency keys, Deps containers, routed/plain registrations, lifecycle steps, and custom DepsModule implementations. Use when authoring adapters, adding integration modules, or debugging dependency resolution and StrEnum route wiring.
npx skill4agent add morzecrew/forze forze-deps-modulesforze-wiringStrEnumforze-specs-infrastructureDeps| Mode | Shape | Use when |
|---|---|---|
| one provider per key | shared clients, secrets, idempotency defaults |
| one provider per key + route | specs resolved by |
| same provider for many routes | one backend supports several logical resources |
Deps.merge(...)CoreErrorK: str | StrEnumStrEnumfrom enum import StrEnum
from typing import Mapping, final
import attrs
from forze.application.contracts.base import DepKey
from forze.application.execution import Deps, DepsModule
WidgetClientDepKey = DepKey[WidgetClientPort]("widget_client")
WidgetDepKey = DepKey[WidgetDepPort]("widget")
@final
@attrs.define(slots=True, frozen=True, kw_only=True)
class WidgetDepsModule[K: str | StrEnum](DepsModule[K]):
client: WidgetClientPort
widgets: Mapping[K, WidgetConfig] | None = None
def __call__(self) -> Deps[K]:
plain = Deps[K].plain({WidgetClientDepKey: self.client})
routed = Deps[K]()
if self.widgets:
routed = Deps[K].routed(
{
WidgetDepKey: {
name: ConfigurableWidget(config=config)
for name, config in self.widgets.items()
}
}
)
return plain.merge(routed)def __call__(self, ctx: ExecutionContext, spec: WidgetSpec) -> WidgetPort:
return WidgetAdapter(client=ctx.deps.provide(WidgetClientDepKey), spec=spec, config=self.config)route=spec.name(ctx, spec)ExecutionContextDepsModule.__call__LifecycleSteppostgres_lifecycle_stepredis_lifecycle_steps3_lifecycle_stepintrospector_cache_partition_keyK: str | StrEnum__call__spec.namesrc/forze/application/execution/deps.pysrc/forze/application/contracts/base/deps.pysrc/forze_postgres/execution/deps/module.pysrc/forze_redis/execution/deps/module.py