Class RequestContext.ContextScope
java.lang.Object
com.loomcache.server.context.RequestContext.ContextScope
- Enclosing class:
RequestContext
Fluent builder for creating a scoped context.
Usage:
var context = RequestContext.newScope()
.correlationId(123L)
.nodeId("node-1");
context.run(() -> {
// context is bound here
String node = RequestContext.nodeId();
});
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TExecute a supplier within this scoped context and return its result.clientAddress(@Nullable String value) Set client address.Set client ID.correlationId(@Nullable Long value) Set correlation ID.messageType(@Nullable String value) Set message type.Set node ID.voidExecute a runnable within this scoped context.
-
Constructor Details
-
ContextScope
public ContextScope()
-
-
Method Details
-
correlationId
Set correlation ID.- Parameters:
value- the correlation ID- Returns:
- this builder for chaining
-
nodeId
Set node ID.- Parameters:
value- the node ID- Returns:
- this builder for chaining
-
clientAddress
Set client address.- Parameters:
value- the client address- Returns:
- this builder for chaining
-
messageType
Set message type.- Parameters:
value- the message type- Returns:
- this builder for chaining
-
clientId
Set client ID.- Parameters:
value- the client ID- Returns:
- this builder for chaining
-
run
Execute a runnable within this scoped context.- Parameters:
runnable- the code to execute with context bound
-
call
Execute a supplier within this scoped context and return its result.- Type Parameters:
T- the return type- Parameters:
supplier- the code to execute with context bound- Returns:
- the result of the supplier
-