miroir/crates/miroir-proxy
jedarden 3dd63fdc67 P4.1 Rebalancer background worker with advisory lock
Implements plan §4 "Rebalancer" background task:
- Advisory lock via leader_lease (only one pod runs the rebalancer)
- Reacts to topology change events (node add/drain/fail/recover)
- Computes affected shards using the Phase 1 router
- Drives the migration state machine for each affected shard
- Updates Prometheus metrics (plan §10)
- Progress persistence via jobs table for resumability

Key features:
- Per-index leader lease scope (rebalance:<index>)
- Per-shard migration state machine with 7 phases
- Concurrency bound via max_concurrent_migrations config
- Cancellation support (pause/resume in-progress rebalancing)
- Metrics: miroir_rebalance_in_progress, documents_migrated_total, duration_seconds

Integration:
- Admin API endpoints (POST /_miroir/nodes, drain, remove) send events to worker
- Health checker syncs rebalancer metrics to Prometheus
- Worker loads persisted jobs on startup for crash recovery

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 10:51:27 -04:00
..
src P4.1 Rebalancer background worker with advisory lock 2026-05-05 10:51:27 -04:00
static Phase 5: Add Advanced Capabilities verification and UI static assets 2026-05-03 19:01:22 -04:00
tests P3: Add Phase 3 integration tests and finalize Task Registry + Persistence 2026-05-02 18:09:44 -04:00
Cargo.toml Phase 3: Task Registry + Persistence (SQLite schema, Redis mirror) 2026-05-03 20:39:58 -04:00