feat: transparent leader hint reconnect on consume
Merged
VI
7mo ago+121+121+012345678901234567890123456789-25-25-01234567890123456789
Summary
- When
consumereceives gRPCUNAVAILABLEwithx-fila-leader-addrtrailing metadata, the client transparently reconnects to the leader address and retries once - Applies to both sync
Clientand asyncAsyncClient - Connection parameters (TLS certs, API key) are stored and reused when creating the redirected channel
- Max 1 redirect per consume call to prevent infinite loops
Test plan
- Verify existing integration tests still pass (no behavior change for non-cluster setups)
- Test with a multi-node cluster where consumer connects to a follower node
- Verify UNAVAILABLE without leader hint metadata still raises
RPCError - Verify second UNAVAILABLE after redirect raises
RPCError(no infinite loop)
š¤ Generated with Claude Code
Summary by cubic
Automatically reconnects to the hinted leader and retry once when a consume call hits a follower. Works for both sync Client and AsyncClient, reuses TLS/mTLS credentials and API key, and closes the old channel before reconnecting.
-
New Features
- Detects gRPC UNAVAILABLE with
x-fila-leader-addrand retries consume against the leader once. - Reuses stored TLS CA and optional client cert/key plus API key when creating the new channel.
- If no leader hint is present, or the retry fails, the client raises the mapped
RPCError.
- Detects gRPC UNAVAILABLE with
-
Bug Fixes
- Closes the previous gRPC channel before reconnecting to avoid leaked connections.
- Resolves mypy no-any-return issues by adding return types and channel factory helpers (no behavior change).