Skip to content

feat: transparent leader hint reconnect on consume#2

Merged
vieiralucas merged 3 commits intomainfrom
feat/leader-hint-reconnect
Mar 24, 2026
Merged

feat: transparent leader hint reconnect on consume#2
vieiralucas merged 3 commits intomainfrom
feat/leader-hint-reconnect

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Mar 22, 2026

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).

Written for commit 04a421f. Summary will update on new commits.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/main/java/dev/faisca/fila/FilaClient.java">

<violation number="1" location="src/main/java/dev/faisca/fila/FilaClient.java:122">
P1: Validate and constrain `x-fila-leader-addr` before redirecting; the current code can forward authenticated consume requests (including API key auth) to an arbitrary address from server metadata.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/main/java/dev/faisca/fila/FilaClient.java
@vieiralucas vieiralucas force-pushed the feat/leader-hint-reconnect branch from 97b4767 to 8f9f2c1 Compare March 24, 2026 02:02
@vieiralucas vieiralucas merged commit 9cb82aa into main Mar 24, 2026
2 checks passed
@vieiralucas vieiralucas deleted the feat/leader-hint-reconnect branch March 24, 2026 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant