Interface Client
- All Superinterfaces:
Namespaced<Client>
- All Known Implementing Classes:
AbstractClient, LocalClient, WebSocketClient
FluxzeroBuilder to construct a
Fluxzero instance.
Application developers must provide an implementation of this interface to the
FluxzeroBuilder.build(Client) method. This allows for flexible configuration, enabling either an
in-memory setup (useful for testing and local development) or a connected (WebSocket-based) client that integrates
with the Fluxzero Runtime.
Client Implementations
Common implementations include:LocalClient— for local, standalone useWebSocketClient— connects to the Fluxzero Runtime using WebSockets
Responsibilities
AClient implementation is responsible for:
- Providing access to gateway and tracking subsystems via
GatewayClientandTrackingClient - Managing subsystems for event storage, scheduling, key-value access, and search
- Handling client shutdown via
shutDown()and shutdown hooks - Optionally monitoring dispatches via
monitorDispatch(ClientDispatchMonitor, MessageType...)
Usage
Client client = LocalClient.newInstance();
Fluxzero fluxzero = FluxzeroBuilder.newInstance().build(client);
-
Method Summary
Modifier and TypeMethodDescriptionReturns the application ID under which this client instance is registered.beforeShutdown(Runnable task) Registers a shutdown hook that will be called before this client shuts down.Returns theEventStoreClientassociated with this client for querying event logs.default GatewayClientgetGatewayClient(MessageType messageType) Returns aGatewayClientfor the given message type using the default topic (typicallynull).getGatewayClient(MessageType messageType, String topic) Returns aGatewayClientfor the given message type and topic.Returns theKeyValueClientfor key-value store interactions.Returns theSchedulingClientused to interact with the Fluxzero scheduling subsystem.Returns theSearchClientthat provides access to document and search APIs.default TrackingClientgetTrackingClient(MessageType messageType) Returns aTrackingClientfor the given message type using the default topic.getTrackingClient(MessageType messageType, String topic) Returns aTrackingClientfor the given message type and topic.id()Returns the unique identifier of this client instance.monitorDispatch(ClientDispatchMonitor monitor, MessageType... messageTypes) Registers aClientDispatchMonitorto receive hooks and diagnostics when messages of the givenMessageTypes are dispatched from this client.name()Returns the name of this client as defined in its configuration.Returns the namespace associated with this client instance.voidshutDown()Shuts down this client instance, releasing any underlying resources.default Clientunwrap()Returns the underlyingClientimplementation.Methods inherited from interface Namespaced
forDefaultNamespace, forNamespace
-
Method Details
-
name
String name()Returns the name of this client as defined in its configuration. -
id
String id()Returns the unique identifier of this client instance. This id may be randomly generated. -
applicationId
String applicationId()Returns the application ID under which this client instance is registered. -
namespace
String namespace()Returns the namespace associated with this client instance. -
getGatewayClient
Returns aGatewayClientfor the given message type using the default topic (typicallynull).For
MessageType.DOCUMENTorMessageType.CUSTOM, this method is not supported and will throw anUnsupportedOperationException, as these require a topic.- Parameters:
messageType- the type of message gateway- Returns:
- the associated
GatewayClient - Throws:
UnsupportedOperationException- if the message type requires a topic
-
getGatewayClient
Returns aGatewayClientfor the given message type and topic.- Parameters:
messageType- the type of message (e.g. COMMAND, EVENT, etc.)topic- the topic to publish messages to (may benullfor default)
-
monitorDispatch
Registers aClientDispatchMonitorto receive hooks and diagnostics when messages of the givenMessageTypes are dispatched from this client.- Parameters:
monitor- the dispatch monitor to registermessageTypes- the message types to monitor- Returns:
- a
Registrationhandle to remove the monitor
-
getTrackingClient
Returns aTrackingClientfor the given message type using the default topic.For
MessageType.DOCUMENTorMessageType.CUSTOM, this method is not supported and will throw anUnsupportedOperationException.- Parameters:
messageType- the type of message to track- Returns:
- the associated
TrackingClient - Throws:
UnsupportedOperationException- if the message type requires a topic
-
getTrackingClient
Returns aTrackingClientfor the given message type and topic.- Parameters:
messageType- the type of message to track (e.g. COMMAND, EVENT, QUERY)topic- the topic to track messages from (may benullfor default)
-
getEventStoreClient
EventStoreClient getEventStoreClient()Returns theEventStoreClientassociated with this client for querying event logs. -
getSchedulingClient
SchedulingClient getSchedulingClient()Returns theSchedulingClientused to interact with the Fluxzero scheduling subsystem. -
getKeyValueClient
KeyValueClient getKeyValueClient()Returns theKeyValueClientfor key-value store interactions.This is mostly deprecated and maintained for backward compatibility.
-
getSearchClient
SearchClient getSearchClient()Returns theSearchClientthat provides access to document and search APIs. -
shutDown
void shutDown()Shuts down this client instance, releasing any underlying resources.This includes closing websocket sessions, stopping tracking, and executing registered shutdown hooks.
-
beforeShutdown
Registers a shutdown hook that will be called before this client shuts down.- Parameters:
task- the action to invoke before shutdown- Returns:
- a
Registrationto remove the task
-
unwrap
Returns the underlyingClientimplementation. This is a convenience method to allow clients to explicitly unwrap proxies or decorators.- Returns:
- the concrete
Clientinstance (oftenthisitself)
-