dongliaojing0554 2016-04-22 08:21
浏览 325

通过HTTP回调进行异步RPC

I am in the process of designing an SDK (in Golang) with blocking functionality, which should be run asynchronously with the result being returned via a callback.

I have been playing with the Gorilla Toolkit RPC library which is great but I don't see a way of returning values of async calls.

Perhaps I am missing something and the RPC model does not support async calls, by that I mean all calls are blocking, even for a long time. If that is the case, i'm assuming there is no HTTP timeout then?

How can I implement async RPC calls with a return value being returned via a callback.

For clarification: I cannot use the typical Go Channel method for callbacks as I will be calling the RPC from another language over HTTP. So my question is, is there a way to implement callbacks over HTTP when doing RPC or should the calls just block, even for a long time until a value is ready to be returned?

  • 写回答

2条回答 默认 最新

  • doulianxing4015 2016-04-22 10:26
    关注

    I don't know about Gorilla, but in the net/rpc package of the standard library of Go you'll find this method net/rpc/Go. It makes a RPC call asynchronously, you give it a channel as parameter so you can retrieve the RPC reply when the Remote Procedure Call is finished.

    net/rpc/Call also makes a RPC call but it is blocking until the call is finished. If you know how to use channels I'm sure you'll get what you want with the Go method.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度