mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-13 08:52:02 +00:00
Reworks the redis-client, connect, resolve and testing crates, adds python-compat json loads and TTL seconds, replaces the redis-store memory tier with a DualCache plus a shared failure log, and gives the Python side the Redis timeout log throttle and a request OTEL parent span for service events Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
3.1 KiB
3.1 KiB
- Keep this crate a thin composition layer: mount endpoint routers and serve the supplied listener
- Server lifecycle and shared inbound middleware belong here, including client authentication, rate limiting, and request logging
- Endpoint paths, request handling, model resolution, and response encoding belong to the mounted crates. Provider execution belongs to the
inference-<fmt>crates andllms - Inject shared state and infrastructure. Avoid global runtimes, duplicate client pools, and abstractions for hypothetical endpoint groups
- Test mounting and server lifecycle through public HTTP behavior. Test endpoint semantics in the owning crate
Redis
build_redisbuilds the Redis clients once at boot (src/redis/mod.rs). Components get a clone as a field, never a per-request extractor or a pool. redis-rs multiplexes one connection per node, so there is no connection pool and pool settings likemax_connectionsare accepted and ignored- Which Redis backs which role mirrors the proxy: coordination is
general_settings.coordination_redis, else thecache_paramsRedis whencache: trueandtype: redis, elseREDIS_*env. The transaction buffer reuses coordination, else env whenuse_redis_transaction_bufferis on. The response cache gets its own client so large values never queue in front of coordination commands src/redis/layers.rsis the Rust copy of_merge_redis_kwargsinlitellm/_redis.py, which only this host needs because the Python host merges in Python. It puts the configured kwargs over theirREDIS_*values and fills theget_secretfallbacks from theSETTINGSrows inredis-resolve, under the same conditions Python reads them, then hands the result tolitellm_redis_resolve::interpret. Values come from aSecretSnapshotfilled once at boot, read likeget_secret(secret manager, then environment, withtrueandfalseread as bools), and the only straight environment read is Azure'sREDIS_USERNAME- A surface is a
ConfiguredRedisconstructor:coordinationforgeneral_settings.coordination_redis, which rejects a malformedportlike the proxy'sCoordinationRedisParamspydantic model,cache_paramsforlitellm_settings.cache_params, which drops the cache-only keys and reads theredis_startup_nodesalias, andredis_cache_kwargsfor aRedisCache.redis_kwargsdict in the contract tests. A new surface is a new constructor, never a flag - Nulls depend on the surface.
coordination_redisdrops every null likemodel_dump(exclude_none=True),cache_paramskeeps a null as an explicitNonethat hides theREDIS_*value unlessCacheorRedisCachenames that parameter, andRedisCache.redis_kwargskeeps every null. A missingos.environ/reference is a null, asload_configresolves it - A setting the Rust client cannot honor warns and is dropped, and only a security check it cannot enforce fails boot, per
redis-resolve/AGENTS.md - Boot never waits for a configured Redis (clients connect lazily). Only the env-only coordination fallback is pinged, for 2s, and treated as absent when unreachable, as in Python
/health/readinessnever touches Redis, matching the proxy