Are there channel state API implementations in Go? As mentioned in grpc doc
https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md#channel-state-api
All gRPC libraries will expose a channel-level API method to poll the current state of a channel. In C++, this method is called GetCurrentState and returns an enum for one of the four legal states.
All libraries should also expose an API that enables the application (user of the gRPC API) to be notified when the channel state changes.
But I can't seem to find such APIs in grpc-go package
There were. But I removed them recently because they are undefined when a grpc.ClientConn may contain multiple underlying network connections (https://github.com/grpc/grpc-go/issues/691). They are also undefined in this case for other languages too. I do not want to leave broken/undefined API when we are approaching GA. So far I do not have plan to revive them. FYI, these API are always racy -- the info you get from them may or may not be out of date already when you start to use them. The only valid use case I have seen is that when users want to hold the 1st rpc until the network connection is established. But this has been achieved by grpc.WithBlock() in gRPC-Go.
Thanks for the info. It makes sense and I'm closing this.
@iamqizhao This is an issue for me. What is the intended method of determining when a client has disconnected? In my project I can determine when specific clients connect by implementing a custom TransportCredentials and looking at the certificate details but I've been unable to find a reliable way to be notified when these clients disconnect.
My use case is long-term client connections using TLS and I need to track when each client connects/disconnects to form an accurate picture of all currently active clients. Is it intended that I implement my own client heartbeat mechanism... this seems a little silly considering that the information is already known internally to gRPC and it's removeConn() server method.
Is there something I'm missing?
Most helpful comment
@iamqizhao This is an issue for me. What is the intended method of determining when a client has disconnected? In my project I can determine when specific clients connect by implementing a custom TransportCredentials and looking at the certificate details but I've been unable to find a reliable way to be notified when these clients disconnect.
My use case is long-term client connections using TLS and I need to track when each client connects/disconnects to form an accurate picture of all currently active clients. Is it intended that I implement my own client heartbeat mechanism... this seems a little silly considering that the information is already known internally to gRPC and it's removeConn() server method.
Is there something I'm missing?