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, wait
bucket, cancel, idempotent, name, operationId, serviceType, target
public 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()
Request
public void succeed(R result)
Request
public void fail(Throwable error)
Request
public void cancel(CancellationReason reason, Function<Throwable,Throwable> exceptionTranslator)
Request
public void timeoutRegistration(com.couchbase.client.core.deps.io.netty.util.Timeout registration)
Request
timeoutRegistration
in interface Request<R extends Response>
registration
- the registration for the timeout timer.public boolean completed()
Request
public boolean succeeded()
Request
public boolean failed()
Request
public boolean cancelled()
Request
public CancellationReason cancellationReason()
Request
Request.cancelled()
, this returns the reason why.cancellationReason
in interface Request<R extends Response>
public RequestContext context()
Request
public Duration timeout()
Request
public boolean timeoutElapsed()
Request
timeoutElapsed
in interface Request<R extends Response>
public long absoluteTimeout()
Request
absoluteTimeout
in interface Request<R extends Response>
public long id()
Request
public RetryStrategy retryStrategy()
Request
retryStrategy
in interface Request<R extends Response>
public Map<String,Object> serviceContext()
Request
serviceContext
in interface Request<R extends Response>
public long createdAt()
Request
public RequestSpan requestSpan()
Request
requestSpan
in interface Request<R extends Response>
Copyright © 2024 Couchbase, Inc.. All rights reserved.