Package io.grpc
Class Context.Storage
java.lang.Object
io.grpc.Context.Storage
- Enclosing class:
Context
Defines the mechanisms for attaching and detaching the "current" context. The constructor for
extending classes must not trigger any activity that can use Context, which includes
logging, otherwise it can trigger an infinite initialization loop. Extending classes must not
assume that only one instance will be created; Context guarantees it will only use one
instance, but it may create multiple and then throw away all but one.
The default implementation will put the current context in a ThreadLocal
. If an
alternative implementation named io.grpc.override.ContextStorageOverride
exists in the
classpath, it will be used instead of the default implementation.
This API is experimental and subject to change.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Context
current()
ImplementsContext.current()
.abstract void
ImplementsContext.detach(io.grpc.Context)
.abstract Context
ImplementsContext.attach()
.
-
Constructor Details
-
Storage
public Storage()
-
-
Method Details
-
doAttach
ImplementsContext.attach()
.Caution:
Context.attach()
interprets a return value ofnull
to mean the same thing asContext.ROOT
.See also:
current()
.- Parameters:
toAttach
- the context to be attached- Returns:
- A
Context
that should be passed back intodetach(Context, Context)
as thetoRestore
parameter.null
is a valid return value, but see caution note.
-
detach
ImplementsContext.detach(io.grpc.Context)
.- Parameters:
toDetach
- the context to be detached. Should be, or be equivalent to, the current context of the current scopetoRestore
- the context to be the current. Should be, or be equivalent to, the context of the outer scope
-
current
ImplementsContext.current()
.Caution:
Context
interprets a return value ofnull
to mean the same thing asContext.ROOT
.See also
doAttach(Context)
.- Returns:
- The context of the current scope.
null
is a valid return value, but see caution note.
-