Class UmaDbClientImpl

java.lang.Object
io.umadb.client.grpc.UmaDbClientImpl
All Implemented Interfaces:
UmaDbClient

public final class UmaDbClientImpl extends Object implements UmaDbClient
Internal gRPC-based implementation of UmaDbClient.

This class is responsible for:

  • Establishing and managing the gRPC channel
  • Configuring TLS and API key authentication
  • Mapping gRPC responses and errors to client-facing domain objects
  • Translating server error responses into UmaDbExceptions

This class is not intended to be used directly by client code. Clients should construct instances via UmaDbClientBuilder.

  • Constructor Details

    • UmaDbClientImpl

      public UmaDbClientImpl(String host, int port, boolean tlsEnabled, String caFilePath, String apiKey)
      Creates a new client implementation.
      Parameters:
      host - UmaDB server host
      port - UmaDB server port
      tlsEnabled - indicates whether an encrypted communication (TLS) is to be used
      caFilePath - optional path to a CA certificate for TLS
      apiKey - optional API key (requires TLS)
      Throws:
      IllegalArgumentException - if arguments are invalid or insecure
    • UmaDbClientImpl

      public UmaDbClientImpl(String host, int port, boolean tlsEnabled, String caFilePath, String apiKey, Executor executor)
      Creates a new client implementation dispatching gRPC callbacks on the given executor.
      Parameters:
      host - UmaDB server host
      port - UmaDB server port
      tlsEnabled - indicates whether an encrypted communication (TLS) is to be used
      caFilePath - optional path to a CA certificate for TLS
      apiKey - optional API key (requires TLS)
      executor - optional executor for gRPC callbacks; null uses the gRPC default
      Throws:
      IllegalArgumentException - if arguments are invalid or insecure
  • Method Details

    • connect

      public void connect()
      Description copied from interface: UmaDbClient
      Establishes a connection to the UmaDb server.

      This method must be called before performing any operations such as appending or reading events.

      Specified by:
      connect in interface UmaDbClient
    • handle

      public AppendResponse handle(AppendRequest appendRequest)
      Description copied from interface: UmaDbClient
      Handles an append request, writing events to the event store.

      The AppendRequest may include optional AppendConditions that enforce conditional appends. Returns an AppendResponse containing the position of the last appended event.

      Specified by:
      handle in interface UmaDbClient
      Parameters:
      appendRequest - the request describing the events to append
      Returns:
      the response containing the position of the last appended event
    • handle

      public Iterator<ReadResponse> handle(ReadRequest readRequest)
      Description copied from interface: UmaDbClient
      Handles a read request, returning an iterator over ReadResponse objects.

      Each ReadResponse contains a batch of sequenced events and optionally the head position of the event stream at the time of the response. The iterator is exhausted once the head position captured at request time has been reached; to keep receiving events as they are appended, use UmaDbClient.subscribe(SubscribeRequest) instead.

      Specified by:
      handle in interface UmaDbClient
      Parameters:
      readRequest - the request describing which events to read
      Returns:
      an iterator over ReadResponse batches
    • subscribe

      public Iterator<SubscribeResponse> subscribe(SubscribeRequest subscribeRequest)
      Description copied from interface: UmaDbClient
      Opens a continuous subscription, returning an iterator over SubscribeResponse batches.

      The subscription first replays already-recorded events matching the request and then blocks, yielding further batches as new events are appended. The iterator does not terminate on its own; call UmaDbClient.shutdown() to end the stream.

      Specified by:
      subscribe in interface UmaDbClient
      Parameters:
      subscribeRequest - the request describing which events to subscribe to
      Returns:
      an iterator over SubscribeResponse batches
    • getTrackingInfo

      public Optional<Long> getTrackingInfo(String source)
      Description copied from interface: UmaDbClient
      Returns the last recorded position for a named source.

      Sources are checkpointed by attaching TrackingInfo to an AppendRequest.

      Specified by:
      getTrackingInfo in interface UmaDbClient
      Parameters:
      source - the unique identifier of the consumer or projection
      Returns:
      the position the source has processed up to, or Optional.empty() if no tracking info exists for it
    • getHeadPosition

      public long getHeadPosition()
      Description copied from interface: UmaDbClient
      Returns the position of the most recent event in the event store.

      This value can be used for optimistic concurrency control, checkpointing, or as a reference point for subsequent reads.

      Specified by:
      getHeadPosition in interface UmaDbClient
      Returns:
      the sequence number of the latest event
    • shutdown

      public void shutdown()
      Description copied from interface: UmaDbClient
      Shuts down the client, closing any active connections and releasing resources.

      After calling this method, the client should not be used for any further operations.

      Specified by:
      shutdown in interface UmaDbClient