Class WebsocketKeyValueClient
java.lang.Object
io.fluxzero.sdk.common.websocket.AbstractWebsocketClient
io.fluxzero.sdk.persisting.keyvalue.client.WebsocketKeyValueClient
- All Implemented Interfaces:
KeyValueClient, AutoCloseable
WebSocket-based implementation of the
KeyValueClient interface for interacting with the Fluxzero Runtime.
This client is responsible for storing, retrieving, and deleting binary key-value data over a WebSocket connection. It sends encoded requests to the Runtime's key-value gateway endpoint, which persists and manages the data on the server-side.
Operations supported:
putValue(String, Data, Guarantee)- Store a value with a given guarantee.putValueIfAbsent(String, Data)- Conditionally store a value only if the key is not yet present.getValue(String)- Retrieve a previously stored value.deleteValue(String, Guarantee)- Remove a value associated with a given key.
This class is typically used internally by the Fluxzero Java SDK and not accessed directly by most applications.
Higher-level abstractions like KeyValueStore are preferred.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractWebsocketClient
AbstractWebsocketClient.PingRegistration, AbstractWebsocketClient.WebSocketRequest -
Field Summary
Fields inherited from class AbstractWebsocketClient
defaultObjectMapper, defaultWebSocketContainer -
Constructor Summary
ConstructorsConstructorDescriptionWebsocketKeyValueClient(String endPointUrl, WebSocketClient client) Constructs a WebsocketKeyValueClient instance using the specified endpoint URL and WebSocket client.WebsocketKeyValueClient(URI endpointUri, WebSocketClient client) Constructs a WebsocketKeyValueClient instance with the provided WebSocket endpoint URI and client.WebsocketKeyValueClient(URI endpointUri, WebSocketClient client, boolean sendMetrics) Constructs a new WebsocketKeyValueClient instance. -
Method Summary
Modifier and TypeMethodDescriptiondeleteValue(String key, Guarantee guarantee) Deletes the value associated with the given key.Data<byte[]> Returns theDataobject associated with the given key.Adds or replaces the given value in the key value store.putValueIfAbsent(String key, Data<byte[]> value) Adds the given value in the key value store if the key is not already mapped to a value.Methods inherited from class AbstractWebsocketClient
abort, close, close, handleResult, metricsMetadata, onClose, onError, onMessage, onOpen, onPong, retryOutstandingRequests, schedulePing, send, sendAndWait, sendCommand, sendPing, toString, tryPublishMetricsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface KeyValueClient
close, deleteValue
-
Constructor Details
-
WebsocketKeyValueClient
Constructs a WebsocketKeyValueClient instance using the specified endpoint URL and WebSocket client. Sending of metrics is enabled by default.- Parameters:
endPointUrl- the WebSocket endpoint URL to connect toclient- the WebSocketClient instance used for managing the WebSocket connection
-
WebsocketKeyValueClient
Constructs a WebsocketKeyValueClient instance with the provided WebSocket endpoint URI and client. Sending of metrics is enabled by default.- Parameters:
endpointUri- the URI of the WebSocket endpoint to connect toclient- the WebSocketClient instance used to manage the connection
-
WebsocketKeyValueClient
Constructs a new WebsocketKeyValueClient instance.- Parameters:
endpointUri- the URI of the WebSocket server endpoint to connect to.client- the WebSocketClient instance used for handling the WebSocket connection.sendMetrics- a flag indicating whether to enable metrics collection for this client. If true, metrics will be sent.
-
-
Method Details
-
putValue
Description copied from interface:KeyValueClientAdds or replaces the given value in the key value store.- Specified by:
putValuein interfaceKeyValueClient- Parameters:
key- The key associated with this valuevalue- The value to storeguarantee- The guarantee for storing- Returns:
- a handle that enables clients to wait until the value was sent or stored depending on the guarantee
-
putValueIfAbsent
Description copied from interface:KeyValueClientAdds the given value in the key value store if the key is not already mapped to a value.- Specified by:
putValueIfAbsentin interfaceKeyValueClient- Parameters:
key- The key associated with this valuevalue- The value to store- Returns:
- a handle that enables clients to wait until the value was sent or stored depending on the guarantee
-
getValue
Description copied from interface:KeyValueClientReturns theDataobject associated with the given key. Returnsnullif there is no associated value.- Specified by:
getValuein interfaceKeyValueClient- Parameters:
key- The key associated with the value- Returns:
- the value for the given key or null
-
deleteValue
Description copied from interface:KeyValueClientDeletes the value associated with the given key.- Specified by:
deleteValuein interfaceKeyValueClient- Parameters:
key- The key associated with this value- Returns:
- a handle that enables clients to wait until the command was safely sent to the store
-