Class WebsocketKeyValueClient

java.lang.Object
io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
io.fluxcapacitor.javaclient.persisting.keyvalue.client.WebsocketKeyValueClient
All Implemented Interfaces:
KeyValueClient, AutoCloseable

public class WebsocketKeyValueClient extends AbstractWebsocketClient implements KeyValueClient
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:

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:
  • Constructor Details

    • WebsocketKeyValueClient

      public WebsocketKeyValueClient(String endPointUrl, WebSocketClient client)
      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 to
      client - the WebSocketClient instance used for managing the WebSocket connection
    • WebsocketKeyValueClient

      public WebsocketKeyValueClient(URI endpointUri, WebSocketClient client)
      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 to
      client - the WebSocketClient instance used to manage the connection
    • WebsocketKeyValueClient

      public WebsocketKeyValueClient(URI endpointUri, WebSocketClient client, boolean sendMetrics)
      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

      public CompletableFuture<Void> putValue(String key, Data<byte[]> value, Guarantee guarantee)
      Description copied from interface: KeyValueClient
      Adds or replaces the given value in the key value store.
      Specified by:
      putValue in interface KeyValueClient
      Parameters:
      key - The key associated with this value
      value - The value to store
      guarantee - The guarantee for storing
      Returns:
      a handle that enables clients to wait until the value was sent or stored depending on the guarantee
    • putValueIfAbsent

      public CompletableFuture<Boolean> putValueIfAbsent(String key, Data<byte[]> value)
      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 interface KeyValueClient
      Parameters:
      key - The key associated with this value
      value - The value to store
      Returns:
      a handle that enables clients to wait until the value was sent or stored depending on the guarantee
    • getValue

      public Data<byte[]> getValue(String key)
      Description copied from interface: KeyValueClient
      Returns the Data object associated with the given key. Returns null if there is no associated value.
      Specified by:
      getValue in interface KeyValueClient
      Parameters:
      key - The key associated with the value
      Returns:
      the value for the given key or null
    • deleteValue

      public CompletableFuture<Void> deleteValue(String key, Guarantee guarantee)
      Description copied from interface: KeyValueClient
      Deletes the value associated with the given key.
      Specified by:
      deleteValue in interface KeyValueClient
      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