smallnest / rpcx

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it! 𝐉𝐚𝐯𝐚有𝐝𝐮𝐛𝐛𝐨, 𝐆𝐨𝐥𝐚𝐧𝐠有𝐫𝐩𝐜𝐱! build for cloud!
https://rpcx.io
Other
8.08k stars 1.16k forks source link

官方文檔中的「异步调用 Service 」範例會阻塞 #835

Closed MechanicZhang closed 8 months ago

MechanicZhang commented 8 months ago

官方文檔中的「异步调用 Service 」範例會阻塞

call, err := xclient.Go(context.Background(), "Mul", args, reply, nil)
if err != nil {
    log.Fatalf("failed to call: %v", err)
}

replyCall := <-call.Done // <- block here

查看源碼後發現在 Client.Go 函數中相關的代碼被註解掉了

// // we allow done is nil
    // if done == nil {
    //  done = make(chan *Call, 10) // buffered.
    // } else {
    //  // If caller passes done != nil, it must arrange that
    //  // done has enough buffer for the number of simultaneous
    //  // RPCs that will be using that channel. If the channel
    //  // is totally unbuffered, it's best not to run at all.
    //  if cap(done) == 0 {
    //      log.Panic("rpc: done channel is unbuffered")
    //  }
    // }

請問是預期行為嗎?謝謝~

smallnest commented 8 months ago

这是个bug, 已修改,请升级到v1.8.22。 谢谢