[英]Can I pass the result of a Publisher down to a Reactor Context?
I have a io.grpc.Context
that comes from a Publisher.我有一个来自发布者的io.grpc.Context
。 Can I pass write that into the Reactor Context?我可以将 write 传递到 Reactor Context 中吗?
Mono.just(io.grpc.Context.current())
.contextWrite(grpcContext ->
reactor.util.context.Context.of(MY_KEY, grpcContext))
Is something like that possible?这样的事情可能吗? The reason is because I have a OnNextOperator hook that I want to listen for this change in grpc.Context原因是因为我有一个 OnNextOperator 钩子,我想在 grpc.Context 中监听这个变化
Is something like that possible?这样的事情可能吗?
Not if you want to access the context downstream - context injection is part of the subscription signal, which flows upstream from bottom to top.如果您想访问下游的上下文,则不是 - 上下文注入是订阅信号的一部分,它从底部到顶部向上游流动。 This is in contrast to the other reactive signals ( next
, error
) which flow downstream from top to bottom.这与从上到下向下游流动的其他反应信号( next
, error
)形成对比。
Your only sensible option if you want to read a value like this downstream is to include it as part of the element itself - usually by using zip()
, zipWith()
or similar.如果您想在下游读取这样的值,您唯一明智的选择是将其作为元素本身的一部分包含在内 - 通常使用zip()
、 zipWith()
或类似方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.