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 Contextcurrent()ImplementsContext.current().abstract voidImplementsContext.detach(io.grpc.Context).abstract ContextImplementsContext.attach().
-
Constructor Details
-
Storage
public Storage()
-
-
Method Details
-
doAttach
ImplementsContext.attach().Caution:
Context.attach()interprets a return value ofnullto mean the same thing asContext.ROOT.See also:
current().- Parameters:
toAttach- the context to be attached- Returns:
- A
Contextthat should be passed back intodetach(Context, Context)as thetoRestoreparameter.nullis 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:
Contextinterprets a return value ofnullto mean the same thing asContext.ROOT.See also
doAttach(Context).- Returns:
- The context of the current scope.
nullis a valid return value, but see caution note.
-