Package com.couchbase.client.core.msg
Class BaseRequest<R extends Response>
java.lang.Object
com.couchbase.client.core.msg.BaseRequest<R>
- All Implemented Interfaces:
Request<R>
- Direct Known Subclasses:
AnalyticsRequest,BaseKeyValueRequest,BaseManagerRequest,CoreHttpRequest,CoreTransactionRequest,QueryRequest,ServerSearchRequest,ViewRequest
Base class for all
Requests.- Since:
- 2.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionBaseRequest(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. -
Method Summary
Modifier and TypeMethodDescriptionlongThe absolute timestamp when the request should time out.voidcancel(CancellationReason reason, Function<Throwable, Throwable> exceptionTranslator) Cancels this request, allowing the caller to customize the exception.If the request isRequest.cancelled(), this returns the reason why.booleanAllows to check if this request has been cancelled before it got a chance to be either failed or succeeded.booleanAllows to check if this request is completed already.context()If attached, returns the context for this request.longHolds the nanoTime when the request got created.voidFails this request and completes it.booleanfailed()Allows to check if this request has been completed but with an exception.longid()Holds a unique ID for each request that is assigned automatically.Holds the internal span for this request.response()Holds the response which eventually completes.The retry strategy for this particular request.Returns contextual information for each individual service.voidCompletes this request successfully.booleanAllows to check if this request has been successfully completed.timeout()Returns the timeout for this request.booleanReturns true if the timeout elapsed.voidtimeoutRegistration(com.couchbase.client.core.deps.io.netty.util.Timeout registration) Sets the timeout registration used to cancel when complete.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.couchbase.client.core.msg.Request
bucket, cancel, idempotent, name, operationId, serviceTracingId, serviceType, target
-
Constructor Details
-
BaseRequest
-
BaseRequest
public BaseRequest(Duration timeout, CoreContext ctx, RetryStrategy retryStrategy, RequestSpan requestSpan) Creates a basic request that has all the required properties to be executed in general.- Parameters:
timeout- the timeout of the request.ctx- the context if provided.
-
-
Method Details
-
response
Description copied from interface:RequestHolds the response which eventually completes. -
succeed
Description copied from interface:RequestCompletes this request successfully. -
fail
Description copied from interface:RequestFails this request and completes it. -
cancel
Description copied from interface:RequestCancels this request, allowing the caller to customize the exception. -
timeoutRegistration
public void timeoutRegistration(com.couchbase.client.core.deps.io.netty.util.Timeout registration) Description copied from interface:RequestSets the timeout registration used to cancel when complete.- Specified by:
timeoutRegistrationin interfaceRequest<R extends Response>- Parameters:
registration- the registration for the timeout timer.
-
completed
public boolean completed()Description copied from interface:RequestAllows to check if this request is completed already. -
succeeded
public boolean succeeded()Description copied from interface:RequestAllows to check if this request has been successfully completed. -
failed
public boolean failed()Description copied from interface:RequestAllows to check if this request has been completed but with an exception. -
cancelled
public boolean cancelled()Description copied from interface:RequestAllows to check if this request has been cancelled before it got a chance to be either failed or succeeded. -
cancellationReason
Description copied from interface:RequestIf the request isRequest.cancelled(), this returns the reason why.- Specified by:
cancellationReasonin interfaceRequest<R extends Response>- Returns:
- the cancellation reason if cancelled, null otherwise.
-
context
Description copied from interface:RequestIf attached, returns the context for this request. -
timeout
Description copied from interface:RequestReturns the timeout for this request. -
timeoutElapsed
public boolean timeoutElapsed()Description copied from interface:RequestReturns true if the timeout elapsed.- Specified by:
timeoutElapsedin interfaceRequest<R extends Response>
-
absoluteTimeout
public long absoluteTimeout()Description copied from interface:RequestThe absolute timestamp when the request should time out.- Specified by:
absoluteTimeoutin interfaceRequest<R extends Response>- Returns:
- the absolute timeout in nanoseconds.
-
id
public long id()Description copied from interface:RequestHolds a unique ID for each request that is assigned automatically. -
retryStrategy
Description copied from interface:RequestThe retry strategy for this particular request.- Specified by:
retryStrategyin interfaceRequest<R extends Response>- Returns:
- the retry strategy for this request.
-
serviceContext
Description copied from interface:RequestReturns contextual information for each individual service.- Specified by:
serviceContextin interfaceRequest<R extends Response>- Returns:
- the service context.
-
createdAt
public long createdAt()Description copied from interface:RequestHolds the nanoTime when the request got created. -
requestSpan
Description copied from interface:RequestHolds the internal span for this request.- Specified by:
requestSpanin interfaceRequest<R extends Response>- Returns:
- the internal span used for the request.
-