feat: transparent leader hint reconnect on consume

Merged
VI
8mo ago
+127-13

Summary

  • When consume() receives gRPC UNAVAILABLE with x-fila-leader-addr trailing metadata, the SDK transparently creates a new connection to the leader address and retries the consume call once
  • Stores TLS/auth configuration in the client to build redirect channels with the same security settings
  • Max 1 redirect per consume call to prevent infinite loops

Test plan

  • Verify compilation passes (./gradlew compileJava)
  • Verify existing tests still pass (./gradlew test)
  • Manual test with a multi-node cluster: consume on a follower node should redirect to the leader
  • Verify UNAVAILABLE errors without x-fila-leader-addr metadata are still raised as RpcException

Summary by cubic

Adds transparent leader redirect for consume() when a follower returns gRPC UNAVAILABLE with x-fila-leader-addr. Retries once against the hinted leader, reusing TLS and API key settings.

  • New Features

    • On UNAVAILABLE with x-fila-leader-addr, reconnects to the leader and resumes the stream once.
    • Reuses configured TLS (CA, client cert/key) and ApiKeyInterceptor on the redirected channel; extracts channel-building helpers and makes Builder.parseHost/parsePort reusable.
    • UNAVAILABLE without a leader hint still throws the mapped RpcException; CANCELLED exits quietly.
  • Bug Fixes

    • Validates leader address hints before redirecting (must be host:port, numeric port 1–65535); invalid hints fail fast.
    • Applied spotless formatting (no behavior change).