5.16.0 — 2026-10-18¶
← 5.16.1 | 5.15.0 → | ↑ 5.x series
Added¶
Adapters - SQLAlchemy¶
- Several databases of the same type - Session managers are keyed by configuration, so two adapters built with
different configs no longer share the first one's engine.
- The same config still returns the same manager.
sqlalchemy_atomicand the*_sqlalchemy_atomicshortcuts take an optionalregistry.- Every registry subclass has its own manager slots, so a subclass of a concrete registry can hold another database of the same type.
Adapters - Keycloak¶
archipy.adapters.keycloak.auth-fastapi_authandgrpc_authare plain functions with__all__.fastapi_authreturns an always-async dependency that works fordefandasync defendpoints;grpc_authdetectsasync defservicer methods.fastapi_authalso setsAuthContextManagerfor the request and clears it when the request ends.set_auth_contextreturns a token andclear_auth_contextaccepts it, so a nested guard restores the outer caller.AuthenticatedUserDTOgainstoken_info.
Helpers - gRPC¶
- Rate-limit counter store -
RateLimitStoreandAsyncRateLimitStoreprotocols and astoreargument on the rate-limit interceptors, plusstore_errorsfor failures of a caller's backend. Without them the Redis default is built lazily as before.
Helpers - OpenTelemetry¶
- Configurable SDK -
OpentelemetryConfiggainsTRACES_SAMPLER,PROPAGATORS(includingb3andb3multi),OTLP_COMPRESSION,SPAN_BATCH_*,LOG_BATCH_*,SERVICE_VERSION,SERVICE_INSTANCE_ID,RESOURCE_DETECTORSandMETRICS_DURATION_BUCKETS_S.- Service instance id, host and os are detected by default;
processis opt-in because it records the command line. Explicit resource settings override detected attributes. - With
USE_STANDARD_ENV, the standardOTEL_*variables fill in the settings the config leaves unset; an explicitly set field wins, and invalid values are logged and ignored.OTEL_SDK_DISABLED=truekeeps the SDK off. - Defaults are queue 4096, batch 512 and compression
none. A batch size left unset follows a lowered queue.
- Service instance id, host and os are detected by default;
- B3 propagation -
opentelemetry-propagator-b3ships inarchipy[otel]. OtelRuntime- The provider state lives on runtime instances;OtelUtilsis a typed facade over a default one, withruntime()andset_runtime().- Decorator attributes - Spans record
code.function.nameand, for a failed call,error.type; themeasure_durationandcount_callsinstruments adderror.typeto a call that ends in error or cancelled.
Models - DTOs¶
RpcInstrumentsDTO- Frozen DTO for the gRPC metric instruments.
Changed¶
Behavior¶
- gRPC server metrics (breaking) - The histogram is now
rpc.server.call.duration(wasrpc.server.request.duration) withrpc.system.name, the fully qualifiedrpc.method,rpc.response.status_codeanderror.typefor server-failure codes. A handler that raises without a status is recorded asUNKNOWN.rpc.server.active_requestsstays on the same attributes. Update dashboards and alerts. fastapi_authis always async - It works for both endpoint kinds, soasync_fastapi_authandasync_grpc_authare deprecated aliases.- Type strictness -
JWTUtilsraisesInvalidTokenErrorfor a non-stringsubor an invalidexpclaim. Helpers, interceptors, errors and decorators replaceAnywith precise types, ParamSpec and Protocols.
Layout¶
- Enforced layer order -
models ← configs ← helpers ← adaptersis checked by an import-linter contract inmake lintand pre-commit. Models read settings througharchipy.models.runtime_settings, and the Persian digit table isarchipy.models.types.PersianDigitType. - Atomic decorators moved - They live in
archipy.adapters.base.sqlalchemy.atomic. - OTel internals split -
OtelUtilsinternals moved into the privatearchipy.helpers.utils._otelpackage.
Deprecated¶
All removed in 6.0.0; each warning names the replacement.
archipy.helpers.decoratorsatomic names (sqlalchemy_atomicand the*_sqlalchemy_atomicshortcuts) - usearchipy.adapters.base.sqlalchemy.atomic.archipy.helpers.utils.keycloak_utilsandKeycloakUtils- usearchipy.adapters.keycloak.auth.KeycloakUtils.async_fastapi_authandasync_grpc_auth- usefastapi_authandgrpc_auth.- Reading
request.state.user_info,token_info,actor_chainanduser_roles- read them fromAuthContextManager.
Removed¶
otel-fastapiextra (breaking) - Installarchipy[otel,fastapi].
Tests¶
- New
otel_configuration.feature, trace propagation through FastAPI, gRPC (sync and aio) and httpx in B3 and W3C formats, gRPC compression measured on the wire, SQLite multi-database scenarios, FastAPI auth context scenarios against a real ASGI app, and rate-limit scenarios with caller stores.
Chore¶
- Docs - Layer order, observability, decorators, utils and FAQ pages updated, including the 6.0.0 removal notes.
Dependencies¶
- Lower bounds of every requirement raised to the locked versions.