Engine
The engine module serves as the functional core of the fastapi-deprecation package. It contains the primary configuration model (DeprecationConfig) and the agnostic evaluation logic (evaluate_deprecation) used by both decorators and middlewares.
DeprecationConfig
DeprecationConfig is the universal data structure that holds all metadata for a deprecation lifecycle. Whether you define your deprecations via the @deprecated decorator or the DeprecationMiddleware, they are all internally normalized into DeprecationConfig definitions.
It also contains the centralized telemetry dispatch mechanisms unifying logging events across the framework.
DeprecationConfig
dataclass
Configuration for deprecation.
Attributes:
| Name | Type | Description |
|---|---|---|
deprecation_date |
Optional[datetime]
|
The date when the endpoint is deprecated. |
sunset_date |
Optional[datetime]
|
The date when the endpoint is sunset. |
brownouts |
List[Tuple[datetime, datetime]]
|
List of brownout periods. |
alternative |
Optional[str]
|
The alternative endpoint to redirect to. |
link |
Optional[str]
|
The link to the deprecation information (policy or migration guide). |
links |
Optional[dict[str, str]]
|
Additional links for deprecation information (newer versions, etc.). |
detail |
Optional[str]
|
Additional detail about the deprecation. |
response |
Optional[Callable[[], Response] | Response]
|
Custom response to return. |
inject_cache_control |
bool
|
Whether to inject cache control headers. |
cache_tag |
Optional[str]
|
Cache tag for the deprecation. |
brownout_probability |
float
|
Probability of a brownout. |
progressive_brownout |
bool
|
Whether to use progressive brownout. |
Source code in src/fastapi_deprecation/engine.py
ActionType
DeprecationResult
dataclass
set_deprecation_callback(callback)
Set a global callback for telemetry.