Class WebsocketKeyValueClient
java.lang.Object
io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
io.fluxcapacitor.javaclient.persisting.keyvalue.client.WebsocketKeyValueClient
- All Implemented Interfaces:
KeyValueClient
,AutoCloseable
WebSocket-based implementation of the
KeyValueClient
interface for interacting with the Flux Platform.
This client is responsible for storing, retrieving, and deleting binary key-value data over a WebSocket connection. It sends encoded requests to the platform'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 Flux clients 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 io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
AbstractWebsocketClient.PingRegistration, AbstractWebsocketClient.WebSocketRequest
-
Field Summary
Fields inherited from class io.fluxcapacitor.javaclient.common.websocket.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 theData
object 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 io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
abort, close, close, handleResult, metricsMetadata, onClose, onError, onMessage, onOpen, onPong, retryOutstandingRequests, schedulePing, send, sendAndWait, sendCommand, sendPing, toString, tryPublishMetrics
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.javaclient.persisting.keyvalue.client.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:KeyValueClient
Adds or replaces the given value in the key value store.- Specified by:
putValue
in 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:KeyValueClient
Adds the given value in the key value store if the key is not already mapped to a value.- Specified by:
putValueIfAbsent
in 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:KeyValueClient
Returns theData
object associated with the given key. Returnsnull
if there is no associated value.- Specified by:
getValue
in interfaceKeyValueClient
- Parameters:
key
- The key associated with the value- Returns:
- the value for the given key or null
-
deleteValue
Description copied from interface:KeyValueClient
Deletes the value associated with the given key.- Specified by:
deleteValue
in 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
-