Package com.couchbase.client.core.msg
Interface Request<R extends Response>
-
- All Known Subinterfaces:
HttpRequest<H,ROW,T,R>,KeyValueRequest<R>,ManagerRequest<R>,NonChunkedHttpRequest<R>
- All Known Implementing Classes:
AnalyticsPingRequest,AnalyticsRequest,AppendRequest,BaseKeyValueRequest,BaseManagerRequest,BaseRequest,BucketConfigRequest,BucketConfigStreamingRequest,CarrierBucketConfigRequest,CarrierGlobalConfigRequest,DecrementRequest,GenericAnalyticsRequest,GenericManagerRequest,GenericSearchRequest,GenericViewRequest,GetAndLockRequest,GetAndTouchRequest,GetCollectionIdRequest,GetCollectionManifestRequest,GetMetaRequest,GetRequest,IncrementRequest,InsertRequest,KvPingRequest,MultiObserveViaCasRequest,NoopRequest,ObserveViaCasRequest,ObserveViaSeqnoRequest,PrependRequest,QueryPingRequest,QueryRequest,RemoveRequest,ReplaceRequest,ReplicaGetRequest,SearchPingRequest,SearchRequest,SubdocGetRequest,SubdocMutateRequest,TouchRequest,UnlockRequest,UpsertRequest,ViewPingRequest,ViewRequest
public interface Request<R extends Response>Represents aRequestflowing through the client.- Since:
- 2.0.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description longabsoluteTimeout()The absolute timestamp when the request should time out.voidcancel(CancellationReason reason)Cancels this request.CancellationReasoncancellationReason()If the request iscancelled(), this returns the reason why.booleancancelled()Allows to check if this request has been cancelled before it got a chance to be either failed or succeeded.booleancompleted()Allows to check if this request is completed already.RequestContextcontext()If attached, returns the context for this request.longcreatedAt()Holds the nanoTime when the request got created.voidfail(Throwable error)Fails 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.default booleanidempotent()Returns if the given request is idempotent or not.InternalSpaninternalSpan()Holds the internal span for this request.default StringoperationId()Returns a potentially non-unique identifier that is useful for tracing output.CompletableFuture<R>response()Holds the response which eventually completes.RetryStrategyretryStrategy()The retry strategy for this particular request.Map<String,Object>serviceContext()Returns contextual information for each individual service.ServiceTypeserviceType()The service type of this request.voidsucceed(R result)Completes this request successfully.booleansucceeded()Allows to check if this request has been successfully completed.Durationtimeout()Returns the timeout for this request.booleantimeoutElapsed()Returns true if the timeout elapsed.
-
-
-
Method Detail
-
id
long id()
Holds a unique ID for each request that is assigned automatically.- Returns:
- the unique request ID.
-
response
CompletableFuture<R> response()
Holds the response which eventually completes.- Returns:
- the future containing the response, eventually.
-
succeed
void succeed(R result)
Completes this request successfully.- Parameters:
result- the result to complete with.
-
fail
void fail(Throwable error)
Fails this request and completes it.- Parameters:
error- the error to fail this request with.
-
cancel
void cancel(CancellationReason reason)
Cancels this request.
-
context
RequestContext context()
If attached, returns the context for this request.- Returns:
- the request context if attached.
-
timeout
Duration timeout()
Returns the timeout for this request.- Returns:
- the timeout for this request.
-
timeoutElapsed
boolean timeoutElapsed()
Returns true if the timeout elapsed.
-
completed
boolean completed()
Allows to check if this request is completed already.- Returns:
- true if completed, failed or cancelled.
-
succeeded
boolean succeeded()
Allows to check if this request has been successfully completed.- Returns:
- true if succeeded, false otherwise.
-
failed
boolean failed()
Allows to check if this request has been completed but with an exception.- Returns:
- true if failed, false otherwise.
-
cancelled
boolean cancelled()
Allows to check if this request has been cancelled before it got a chance to be either failed or succeeded.- Returns:
- true if cancelled, false otherwise.
-
cancellationReason
CancellationReason cancellationReason()
If the request iscancelled(), this returns the reason why.- Returns:
- the cancellation reason if cancelled, null otherwise.
-
serviceType
ServiceType serviceType()
The service type of this request.- Returns:
- the service type for this request.
-
serviceContext
Map<String,Object> serviceContext()
Returns contextual information for each individual service.- Returns:
- the service context.
-
retryStrategy
RetryStrategy retryStrategy()
The retry strategy for this particular request.- Returns:
- the retry strategy for this request.
-
internalSpan
InternalSpan internalSpan()
Holds the internal span for this request.- Returns:
- the internal span used for the request.
-
createdAt
long createdAt()
Holds the nanoTime when the request got created.- Returns:
- the time when the request got created.
-
absoluteTimeout
long absoluteTimeout()
The absolute timestamp when the request should time out.- Returns:
- the absolute timeout in nanoseconds.
-
idempotent
default boolean idempotent()
Returns if the given request is idempotent or not.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!
- Returns:
- true if idempotent.
-
operationId
default String operationId()
Returns a potentially non-unique identifier that is useful for tracing output.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).
- Returns:
- if present, the operation id. Null otherwise.
-
-