Interface Request<R extends Response>

Type Parameters:
R - the Response type
All Superinterfaces:
Composable
All Known Implementing Classes:
Delete, DeletePrefix, Get, GetPrefix, Put, Transaction

public interface Request<R extends Response> extends Composable
A Request is the core interface representing the actions we want to take against a key-value store.

There are 5 primitive requests: Get, GetPrefix, Put, Delete, and DeletePrefix; and one complex request, Transaction.

Due to the hierarchical nature of Transactions, Requests are responsible for handling their own Responses. In most cases the in-response handling is implemented as a simple storage mechanism, to be hierarchically read out after the top-level response has been fully handled. The one exception is Transaction, which delegates out its sub-responses as applicable.

Requests are meant to be Composable. As such, requests can be built up very complex from these simple building blocks. It takes care to build them up in a maintainable way. To help provide insight around requests (complex, or not), the requests can be described via describe(). While describe is primarily meant to aid in the development or debugging process around requests, it might be reasonable to pass the described request to a technical user for verification before execution.

Atomicity, as provided via the Transaction construct, is the responsibility of the caller.

Requests are executed through a KVClient.

KVClient implementations are responsible for building their own implementation specific requests, but are not expecting to extend the Request interfaces. The visitor pattern, enabled through traverse(RequestVisitor), provides the logic necessary for implementations to walk the request structure.

  • Method Details

    • getOperations

      default List<? extends Request> getOperations()
      Equivalent to return Collections.singletonList(this);
      Specified by:
      getOperations in interface Composable
    • describe

      String describe()
      An unfiltered description of the Request. Meant to be used for debugging and development purposes.
    • hasResponse

      boolean hasResponse()
      Returns:
      true iff the response has been set
    • getResponse

      R getResponse()
      Should only be called after hasResponse() is true.
      Returns:
      the response
    • traverse

      void traverse(@NotNull @NotNull RequestVisitor visitor)
      Invokes the appropriately typed RequestVisitor method that corresponds to the concrete type of this Request.

      Thus, all implementations are essentially visitor.visit((ConcreteType)this).

      Parameters:
      visitor - the visitor