本文整理汇总了Java中io.grpc.Context.withValue方法的典型用法代码示例。如果您正苦于以下问题:Java Context.withValue方法的具体用法?Java Context.withValue怎么用?Java Context.withValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.grpc.Context
的用法示例。
在下文中一共展示了Context.withValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import io.grpc.Context; //导入方法依赖的package包/类
/**
* Attaches an empty ambient context to the provided gRPC {@code Context}.
*
* @throws IllegalStateException if an ambient context has already been attached to the
* provided gRPC {@code Context}.
*/
public static Context initialize(Context context) {
checkNotNull(context, "context");
checkState(DATA_KEY.get(context) == null,
"AmbientContext has already been created in the scope of the current context");
return context.withValue(DATA_KEY, new AmbientContext());
}
示例2: filterContext
import io.grpc.Context; //导入方法依赖的package包/类
@Override
public Context filterContext(Context context) {
if (!tagger.empty().equals(parentCtx)) {
return context.withValue(TAG_CONTEXT_KEY, parentCtx);
}
return context;
}
示例3: filterContext
import io.grpc.Context; //导入方法依赖的package包/类
@Override
public Context filterContext(Context context) {
// Access directly the unsafe trace API to create the new Context. This is a safe usage
// because gRPC always creates a new Context for each of the server calls and does not
// inherit from the parent Context.
return context.withValue(CONTEXT_SPAN_KEY, span);
}
示例4: filterContext
import io.grpc.Context; //导入方法依赖的package包/类
@Override
public Context filterContext(Context context) {
Context newCtx = super.filterContext(context);
return newCtx.withValue(SERVER_TRACER_ADDED_KEY, "context added by tracer");
}
示例5: fork
import io.grpc.Context; //导入方法依赖的package包/类
/**
* Similar to {@link #initialize(Context)}, {@code fork()} attaches a shallow clone of this {@code AmbientContext}
* to a provided gRPC {@code Context}. Use {@code fork()} when you want create a temporary context scope.
*
* @param context
* @return
*/
public Context fork(Context context) {
return context.withValue(DATA_KEY, new AmbientContext(this));
}