feat: replace gRPC transport with FIBP binary protocol

Merged
VI
8mo ago
+1414-1017

Summary

  • Replaces the gRPC/protobuf transport with FIBP (Fila Binary Protocol) over raw TCP/TLS
  • Removes all gRPC and protobuf dependencies from build.gradle (no runtime dependencies remain)
  • Adds FibpConnection β€” TCP socket with length-prefixed framing, handshake, correlation-ID multiplexing via ConcurrentHashMap + CompletableFuture, heartbeat scheduler, and optional TLS via SSLSocket
  • Adds FibpCodec β€” wire encoding/decoding matching fila-core/src/fibp/wire.rs exactly (enqueue, consume push batch, ack, nack, error frames)
  • Keeps the public FilaClient API identical: enqueue, enqueueMany, consume, ack, nack, close, Builder with all TLS/auth/batch options preserved
  • Batcher groups messages by queue before sending (one FIBP enqueue frame per queue name, since the frame-level field is per-queue)
  • RpcException.Code replaces io.grpc.Status.Code; error classification uses keyword matching on plain-text error payloads (matching the Rust SDK pattern)
  • AUTH uses raw key bytes in OP_AUTH frame (no length prefix, matching server protocol)
  • Consume push frames decoded as batches (msg_count:u16 | messages...)
  • FibpAdminClient added to test package with hand-rolled minimal protobuf for CreateQueueRequest (avoids a test protobuf dependency)
  • Integration tests (FilaClientTest, BatchClientTest, TlsAuthClientTest) guarded by @EnabledIf("serverAvailable") and skip cleanly when no binary is present; unit tests all pass

Test plan

  • All 21 unit tests pass (./gradlew test)
  • spotlessCheck passes (formatting enforced by Google Java Format)
  • CI integration tests pass against downloaded fila-server binary
  • TLS tests: verify withTls(), withTlsCaCert(), withTlsClientCert() (mTLS) all connect
  • Auth tests: verify withApiKey() sends AUTH frame and server accepts/rejects correctly

πŸ€– Generated with Claude Code


Summary by cubic

Replaced the gRPC/protobuf transport with FIBP (Fila Binary Protocol) over raw TCP/TLS while keeping the public FilaClient API the same. This removes all gRPC/protobuf deps, adds a single-socket multiplexed connection with heartbeat and AUTH, and includes stability/validation fixes.

  • New Features

    • Added FibpConnection: framing, handshake, correlation IDs, heartbeat scheduler, optional TLS, and AUTH via OP_AUTH.
    • Added FibpCodec: encode/decode for enqueue, batched consume push, ack/nack, and error frames; validates header count (<=255) and str16 length (<=65535).
    • Public FilaClient API unchanged; batcher groups messages by queue and sends one enqueue frame per queue; enqueueMany enforces a single target queue.
    • Replaced gRPC status with RpcException.Code; errors mapped from server error text.
    • Robustness: remove pending futures on consume timeout/interrupt; guard push handler exceptions to keep the reader thread alive; map batch timeouts to UNAVAILABLE; add a fallback catch in the batcher to resolve futures with INTERNAL on unexpected exceptions.
    • Tests use FibpAdminClient for queue creation (supports TLS/mTLS); README updated; version bumped to 0.3.0.
  • Migration

    • Update dependency to dev.faisca:fila-client:0.3.0.
    • Replace any uses of gRPC Status.Code with RpcException.Code.
    • build() now opens a connection; tests that constructed clients without a running server should guard or defer client creation.
    • Consume handlers run on the FIBP reader thread; avoid heavy or blocking work in the callback.
    • enqueueMany should target a single queue per call.