public abstract class BaseRequest<R extends Response> extends Object implements Request<R>
Requests.| Constructor and Description |
|---|
BaseRequest(Duration timeout,
CoreContext ctx,
RetryStrategy retryStrategy) |
BaseRequest(Duration timeout,
CoreContext ctx,
RetryStrategy retryStrategy,
RequestSpan requestSpan)
Creates a basic request that has all the required properties to be
executed in general.
|
| Modifier and Type | Method and Description |
|---|---|
long |
absoluteTimeout()
The absolute timestamp when the request should time out.
|
void |
cancel(CancellationReason reason,
Function<Throwable,Throwable> exceptionTranslator)
Cancels this request, allowing the caller to customize the exception.
|
CancellationReason |
cancellationReason()
If the request is
Request.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.
|
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.
|
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.
|
void |
timeoutRegistration(com.couchbase.client.core.deps.io.netty.util.Timeout registration)
Sets the timeout registration used to cancel when complete.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbucket, cancel, idempotent, name, operationId, serviceType, targetpublic BaseRequest(Duration timeout, CoreContext ctx, RetryStrategy retryStrategy)
public BaseRequest(Duration timeout, CoreContext ctx, RetryStrategy retryStrategy, RequestSpan requestSpan)
timeout - the timeout of the request.ctx - the context if provided.public CompletableFuture<R> response()
Requestpublic void succeed(R result)
Requestpublic void fail(Throwable error)
Requestpublic void cancel(CancellationReason reason, Function<Throwable,Throwable> exceptionTranslator)
Requestpublic void timeoutRegistration(com.couchbase.client.core.deps.io.netty.util.Timeout registration)
RequesttimeoutRegistration in interface Request<R extends Response>registration - the registration for the timeout timer.public boolean completed()
Requestpublic boolean succeeded()
Requestpublic boolean failed()
Requestpublic boolean cancelled()
Requestpublic CancellationReason cancellationReason()
RequestRequest.cancelled(), this returns the reason why.cancellationReason in interface Request<R extends Response>public RequestContext context()
Requestpublic Duration timeout()
Requestpublic boolean timeoutElapsed()
RequesttimeoutElapsed in interface Request<R extends Response>public long absoluteTimeout()
RequestabsoluteTimeout in interface Request<R extends Response>public long id()
Requestpublic RetryStrategy retryStrategy()
RequestretryStrategy in interface Request<R extends Response>public Map<String,Object> serviceContext()
RequestserviceContext in interface Request<R extends Response>public long createdAt()
Requestpublic RequestSpan requestSpan()
RequestrequestSpan in interface Request<R extends Response>Copyright © 2024 Couchbase, Inc.. All rights reserved.