public final class QueueSphereClientDecorator extends SphereClientDecorator implements SphereClient
SphereClient
to limit the amount of parallel requests which await an answer.
If maxParallelRequests
are waiting for a response every further request will be added to an unbound queue.
Then the next answer will cause that the first request in the queue will be executed.Modifier and Type | Method and Description |
---|---|
void |
close()
Shuts down the client to save resources like connections and threads.
|
<T> CompletionStage<T> |
execute(SphereRequest<T> sphereRequest)
Executes asynchronously a request to Composable Commerce.
|
static SphereClient |
of(SphereClient delegate,
int maxParallelRequests) |
static SphereClient |
of(SphereClient delegate,
int maxParallelRequests,
boolean closeUnderlyingClient) |
getConfig
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getConfig, of, of
public <T> CompletionStage<T> execute(SphereRequest<T> sphereRequest)
SphereClient
execute
in interface SphereClient
execute
in class SphereClientDecorator
T
- type of the result for the requestsphereRequest
- request to Composable Commerce to performpublic void close()
SphereClient
close
in interface SphereClient
close
in interface AutoCloseable
close
in class SphereClientDecorator
public static SphereClient of(SphereClient delegate, int maxParallelRequests, boolean closeUnderlyingClient)
public static SphereClient of(SphereClient delegate, int maxParallelRequests)