feat: add a Redis-backed driver API load balancer - #18
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThe driver-location API now supports Redis-backed shared state, readiness checks, optional instance IDs, and NGINX load balancing. Docker Compose runs the gateway, Redis, and API services. CI validates replica routing, shared state, and resilience after one replica stops. ChangesLoad-balanced driver-location API
Possibly related issues
Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant CI
participant NGINX
participant APIReplica
participant Redis
CI->>NGINX: Poll gateway readiness
NGINX->>APIReplica: Proxy readiness request
APIReplica->>Redis: Check Redis readiness
Redis-->>APIReplica: Return ping status
APIReplica-->>NGINX: Return readiness response
NGINX-->>CI: Return gateway status
CI->>NGINX: Send driver-location requests
NGINX->>APIReplica: Route requests across replicas
APIReplica->>Redis: Read shared driver state
Redis-->>APIReplica: Return driver data
APIReplica-->>NGINX: Return response with instance ID
NGINX-->>CI: Return routed response
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
Implements issue #17 and retains the dated tracking entry in
Dailylog.md.8000) and makes API replicas internal.Files changed
nginx/driver-location-load-balancer.conf— least-connections upstream, forwarded-request headers, and safe retry policy for liveness/readiness.docker-compose.yml— adds Redis, removes direct API host exposure, and adds NGINX as the only public API endpoint.location_store.py— adds the Redis store and explicit store factory while preservingDriverLocationStorefor local development.main.py— selects the shared store fromDRIVER_LOCATION_REDIS_URLand provides a test-only opt-in replica header.api_router.py— adds/driver-location/readywithout changing the existing liveness endpoint.test_redis_driver_location_store.py— behavioral round-trip and readiness coverage using an injected fake Redis client..github/workflows/ci.yml— validates NGINX syntax and runs the three-replica gateway integration check.README.md— documents public gateway ownership, scaling, probes, and test scope.Dailylog.md— preserves the dated record and links enhancement: add a gateway load balancer for horizontally scaled APIs #17.Validation performed
main: 9 files changed, branch is 9 commits ahead and 0 behind.api-gatewaypublishes port8000; API replicas use Redis state.The connected GitHub workspace cannot execute Docker or Python locally; the new CI job is the authoritative runtime validation and this PR remains draft until it reports.
Risks
Follow-up recommendations
CI follow-up
The initial run failed only at
mypyduring theType checkstep. The Redis-store constructor now narrows the optional URL before callingredis.Redis.from_url; the runtime behavior and gateway assertions are unchanged. CI run #160 completed successfully: format, lint, type check, tests, benchmark harness, broker integration, and driver API load-balancer integration all passed.Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests