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.
|
default String |
bucket()
Returns the name of the bucket this request is scoped to, or null if not scoped to a bucket.
|
default void |
cancel(CancellationReason reason)
Cancels this request.
|
void |
cancel(CancellationReason reason,
Function<Throwable,Throwable> exceptionTranslator)
Cancels this request, allowing the caller to customize the exception.
|
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.
|
default String |
name()
The unique name of the request, usually related to the type but not necessarily.
|
default String |
operationId()
Returns a potentially non-unique identifier that is useful for tracing output.
|
RequestSpan |
requestSpan()
Holds the internal span for this request.
|
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.
|
default NodeIdentifier |
target()
Returns the node that should service this request, or null to let the service locator decide.
|
Duration |
timeout()
Returns the timeout for this request.
|
boolean |
timeoutElapsed()
Returns true if the timeout elapsed.
|
void |
timeoutRegistration(com.couchbase.client.core.deps.io.netty.util.Timeout registration)
Sets the timeout registration used to cancel when complete.
|
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.default void cancel(CancellationReason reason)
void cancel(CancellationReason reason, Function<Throwable,Throwable> exceptionTranslator)
exceptionTranslator
- A typical function might create a new
custom exception using the argument as the cause.void timeoutRegistration(com.couchbase.client.core.deps.io.netty.util.Timeout registration)
registration
- the registration for the timeout timer.RequestContext context()
Duration timeout()
boolean timeoutElapsed()
boolean completed()
boolean succeeded()
boolean failed()
boolean cancelled()
CancellationReason cancellationReason()
cancelled()
, this returns the reason why.@Nullable ServiceType serviceType()
Can be null if this is a 'virtual service' (e.g. transactions), which don't map 1:1 to a particular cluster service, but need to integrate into various codepaths that are built around ServiceType such as ThresholdLoggingTracer. Virtual requests must not be sent into core at present, as there is limited support for them.
default String bucket()
default NodeIdentifier target()
Map<String,Object> serviceContext()
RetryStrategy retryStrategy()
RequestSpan requestSpan()
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).
default String name()
The default implementation is derived from the class name (i.e. FooRequest returns foo), but if that does not match up it should be overridden in the actual class.
Copyright © 2024 Couchbase, Inc.. All rights reserved.