作者:手机用户2502891053 | 来源:互联网 | 2023-02-06 10:32
来自服务器的传出RPC通过隐式绑定到触发它们的传入请求io.grpc.Context
。如果您要进行的RPC甚至在传入的RPC完成后仍继续进行,则应使用context.fork()
:
Context forked = Context.current().fork();
Context old = forked.attach();
try {
// RPCs at this point can continue after the incoming RPC completes
futureClient.call(...);
} finally {
forked.detach(old);
}
Context.run(Runnable)
还是直接使用附加/分离的便捷替代方法。
1> Eric Anderso..:
来自服务器的传出RPC通过隐式绑定到触发它们的传入请求io.grpc.Context
。如果您要进行的RPC甚至在传入的RPC完成后仍继续进行,则应使用context.fork()
:
Context forked = Context.current().fork();
Context old = forked.attach();
try {
// RPCs at this point can continue after the incoming RPC completes
futureClient.call(...);
} finally {
forked.detach(old);
}
Context.run(Runnable)
还是直接使用附加/分离的便捷替代方法。