Class UmaDbClientImpl
- All Implemented Interfaces:
UmaDbClient
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 Summary
ConstructorsConstructorDescriptionUmaDbClientImpl(String host, int port, boolean tlsEnabled, String caFilePath, String apiKey) Creates a new client implementation.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. -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()Establishes a connection to the UmaDb server.longReturns the position of the most recent event in the event store.getTrackingInfo(String source) Returns the last recorded position for a named source.handle(AppendRequest appendRequest) Handles an append request, writing events to the event store.handle(ReadRequest readRequest) Handles a read request, returning an iterator overReadResponseobjects.voidshutdown()Shuts down the client, closing any active connections and releasing resources.subscribe(SubscribeRequest subscribeRequest) Opens a continuous subscription, returning an iterator overSubscribeResponsebatches.
-
Constructor Details
-
UmaDbClientImpl
Creates a new client implementation.- Parameters:
host- UmaDB server hostport- UmaDB server porttlsEnabled- indicates whether an encrypted communication (TLS) is to be usedcaFilePath- optional path to a CA certificate for TLSapiKey- 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 hostport- UmaDB server porttlsEnabled- indicates whether an encrypted communication (TLS) is to be usedcaFilePath- optional path to a CA certificate for TLSapiKey- optional API key (requires TLS)executor- optional executor for gRPC callbacks;nulluses the gRPC default- Throws:
IllegalArgumentException- if arguments are invalid or insecure
-
-
Method Details
-
connect
public void connect()Description copied from interface:UmaDbClientEstablishes a connection to the UmaDb server.This method must be called before performing any operations such as appending or reading events.
- Specified by:
connectin interfaceUmaDbClient
-
handle
Description copied from interface:UmaDbClientHandles an append request, writing events to the event store.The
AppendRequestmay include optionalAppendConditions that enforce conditional appends. Returns anAppendResponsecontaining the position of the last appended event.- Specified by:
handlein interfaceUmaDbClient- Parameters:
appendRequest- the request describing the events to append- Returns:
- the response containing the position of the last appended event
-
handle
Description copied from interface:UmaDbClientHandles a read request, returning an iterator overReadResponseobjects.Each
ReadResponsecontains 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, useUmaDbClient.subscribe(SubscribeRequest)instead.- Specified by:
handlein interfaceUmaDbClient- Parameters:
readRequest- the request describing which events to read- Returns:
- an iterator over
ReadResponsebatches
-
subscribe
Description copied from interface:UmaDbClientOpens a continuous subscription, returning an iterator overSubscribeResponsebatches.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:
subscribein interfaceUmaDbClient- Parameters:
subscribeRequest- the request describing which events to subscribe to- Returns:
- an iterator over
SubscribeResponsebatches
-
getTrackingInfo
Description copied from interface:UmaDbClientReturns the last recorded position for a named source.Sources are checkpointed by attaching
TrackingInfoto anAppendRequest.- Specified by:
getTrackingInfoin interfaceUmaDbClient- 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:UmaDbClientReturns 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:
getHeadPositionin interfaceUmaDbClient- Returns:
- the sequence number of the latest event
-
shutdown
public void shutdown()Description copied from interface:UmaDbClientShuts 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:
shutdownin interfaceUmaDbClient
-