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,
InternalSpan 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)
Cancels this request.
|
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.
|
InternalSpan |
internalSpan()
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
idempotent, operationId, serviceType
public BaseRequest(Duration timeout, CoreContext ctx, RetryStrategy retryStrategy)
public BaseRequest(Duration timeout, CoreContext ctx, RetryStrategy retryStrategy, InternalSpan 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)
Request
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 InternalSpan internalSpan()
Request
internalSpan
in interface Request<R extends Response>
Copyright © 2020 Couchbase, Inc.. All rights reserved.