public interface Request<R extends Response>
Request
flowing through the client.Modifier and Type | Method and Description |
---|---|
long |
absoluteTimeout()
The absolute timestamp when the request should time out.
|
void |
cancel(CancellationReason reason)
Cancels this request.
|
CancellationReason |
cancellationReason()
If the request is
cancelled() , this returns the reason why. |
boolean |
cancelled()
Allows to check if this request has been cancelled before it got a chance
to be either failed or succeeded.
|
boolean |
completed()
Allows to check if this request is completed already.
|
RequestContext |
context()
If attached, returns the context for this request.
|
long |
createdAt()
Holds the nanoTime when the request got created.
|
void |
fail(Throwable error)
Fails this request and completes it.
|
boolean |
failed()
Allows to check if this request has been completed but with an exception.
|
long |
id()
Holds a unique ID for each request that is assigned automatically.
|
default boolean |
idempotent()
Returns if the given request is idempotent or not.
|
InternalSpan |
internalSpan()
Holds the internal span for this request.
|
default String |
operationId()
Returns a potentially non-unique identifier that is useful for tracing output.
|
CompletableFuture<R> |
response()
Holds the response which eventually completes.
|
RetryStrategy |
retryStrategy()
The retry strategy for this particular request.
|
Map<String,Object> |
serviceContext()
Returns contextual information for each individual service.
|
ServiceType |
serviceType()
The service type of this request.
|
void |
succeed(R result)
Completes this request successfully.
|
boolean |
succeeded()
Allows to check if this request has been successfully completed.
|
Duration |
timeout()
Returns the timeout for this request.
|
boolean |
timeoutElapsed()
Returns true if the timeout elapsed.
|
long id()
CompletableFuture<R> response()
void succeed(R result)
result
- the result to complete with.void fail(Throwable error)
error
- the error to fail this request with.void cancel(CancellationReason reason)
RequestContext context()
Duration timeout()
boolean timeoutElapsed()
boolean completed()
boolean succeeded()
boolean failed()
boolean cancelled()
CancellationReason cancellationReason()
cancelled()
, this returns the reason why.ServiceType serviceType()
Map<String,Object> serviceContext()
RetryStrategy retryStrategy()
InternalSpan internalSpan()
long createdAt()
long absoluteTimeout()
default boolean idempotent()
By default, this method always returns false for data consistency reasons. Only specific idempotent operations should override this default since it impacts retry handling quite a bit. DO NOT SET THIS TO TRUE ON MUTATING OPERATIONS!
default String operationId()
Note: might be null! It depends on the type of operation. It is also different from the unqiue operation ID that increments to provide additional context (i.e in query the context uuid, in kv the opaque value).
Copyright © 2020 Couchbase, Inc.. All rights reserved.