douqianrou9079 2017-06-22 12:30
浏览 85

我应该将新的还是旧的Context对象发送到自己的gRPC服务器中的第三方gRPC API?

We have a gRPC server written in golang. For one of the RPCs, we request data from the Google Maps gRPC API. Once we receive a response from the Google Maps RPC, we do some calculations and return a response to the enclosing RPC (defined by our server).

Naturally, we receive a Context object when the RPC is called on our server.

My question is: Should we pass this same Context object to the Google Maps RPC? Or, should we instead create a new Context object (using context.Background()), and then pass this to the Google Maps API?

  • 写回答

2条回答 默认 最新

  • dongquepao8653 2017-06-27 23:04

    The context you received contains the cancellation and timeout, so it would be good to use the same context to make the new RPC. Otherwise you need to manually pass these signals.

    A side on the metadata, metadata in the received context will not be automatically forwarded to the new RPC, see:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 咨询一下有关于王者荣耀赢藏战绩
  • ¥100 求购一套带接口实现实习自动签到打卡
  • ¥50 MacOS 使用虚拟机安装k8s
  • ¥500 亚马逊 COOKIE我如何才能实现 登录一个亚马逊账户 下发新 COOKIE ..我使用下发新COOKIE 导入ADS 指纹浏览器登录,我把账户密码 修改过后,原来下发新COOKIE 不会失效的方式
  • ¥20 玩游戏gpu和cpu利用率特别低,玩游戏卡顿
  • ¥25 oracle中的正则匹配
  • ¥15 关于#vscode#的问题:把软件卸载不会再出现蓝屏
  • ¥15 vimplus出现的错误
  • ¥15 usb无线网卡转typec口
  • ¥30 怎么使用AVL fire ESE软件自带的优化模式来优化设计Soot和NOx?