Package com.couchbase.client.core.msg
Class RequestContext
- java.lang.Object
-
- com.couchbase.client.core.cnc.AbstractContext
-
- com.couchbase.client.core.CoreContext
-
- com.couchbase.client.core.msg.RequestContext
-
- All Implemented Interfaces:
Context
public class RequestContext extends CoreContext
Additional context which might be attached to an individualRequest
.- Since:
- 2.0.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.couchbase.client.core.cnc.Context
Context.ExportFormat
-
-
Constructor Summary
Constructors Constructor Description RequestContext(CoreContext ctx, Request<? extends Response> request)
Creates a newRequestContext
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestContext
cancel()
Allows to cancel the attachedRequest
from anywhere in the code.String
dispatchedTo()
RequestContext
dispatchedTo(String dispatchedTo)
long
dispatchLatency()
Returns the duration of the dispatch phase if set.RequestContext
dispatchLatency(long dispatchLatency)
Allows to set the dispatch duration of the request.RequestContext
incrementRetryAttempt()
protected void
injectExportableParams(Map<String,Object> input)
This method needs to be implemented by the actual context implementations to inject the params they need for exporting.Map<String,Object>
payload()
Returns the custom user payload of this request.RequestContext
payload(Map<String,Object> payload)
Allows to set a custom payload for this request.int
retryAttempts()
io.opentracing.Span
span()
RequestContext
span(io.opentracing.Span span)
-
Methods inherited from class com.couchbase.client.core.CoreContext
core, environment, id
-
Methods inherited from class com.couchbase.client.core.cnc.AbstractContext
exportAsString, toString
-
-
-
-
Constructor Detail
-
RequestContext
@Internal public RequestContext(CoreContext ctx, Request<? extends Response> request)
Creates a newRequestContext
.- Parameters:
ctx
- the core context.request
- the linked request.
-
-
Method Detail
-
dispatchLatency
@Volatile public long dispatchLatency()
Returns the duration of the dispatch phase if set.- Returns:
- the duration of the dispatch phase.
-
dispatchLatency
@Internal public RequestContext dispatchLatency(long dispatchLatency)
Allows to set the dispatch duration of the request.- Parameters:
dispatchLatency
- the duration.
-
span
@Internal public RequestContext span(io.opentracing.Span span)
-
span
@Volatile public io.opentracing.Span span()
-
retryAttempts
public int retryAttempts()
-
incrementRetryAttempt
public RequestContext incrementRetryAttempt()
-
dispatchedTo
public String dispatchedTo()
-
dispatchedTo
public RequestContext dispatchedTo(String dispatchedTo)
-
payload
public Map<String,Object> payload()
Returns the custom user payload of this request.- Returns:
- the payload if set.
-
payload
public RequestContext payload(Map<String,Object> payload)
Allows to set a custom payload for this request.- Parameters:
payload
- the payload to set.
-
injectExportableParams
protected void injectExportableParams(Map<String,Object> input)
Description copied from class:AbstractContext
This method needs to be implemented by the actual context implementations to inject the params they need for exporting.- Overrides:
injectExportableParams
in classCoreContext
- Parameters:
input
- pass exportable params in here.
-
cancel
@Uncommitted public RequestContext cancel()
Allows to cancel the attachedRequest
from anywhere in the code.If the operation is already completed (either successfully or failed) this is an operation without side-effect.
-
-