From 799f934d736104b602df40ea4bb8bcc8186071cc Mon Sep 17 00:00:00 2001 From: Daniel Botros Date: Fri, 5 Sep 2025 11:56:11 -0400 Subject: [PATCH 1/2] Extend ClientConn inteface to include GetState and handle webrtc case --- rpc/dialer.go | 6 ++++++ rpc/wrtc_client_channel.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/rpc/dialer.go b/rpc/dialer.go index 5d842b16..6c891312 100644 --- a/rpc/dialer.go +++ b/rpc/dialer.go @@ -23,6 +23,7 @@ import ( "golang.org/x/net/proxy" "google.golang.org/grpc" "google.golang.org/grpc/codes" + "google.golang.org/grpc/connectivity" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/keepalive" @@ -61,6 +62,9 @@ type Dialer interface { Close() error } +// Unknown is an unknown connectivity state. +const Unknown connectivity.State = 5 + // A ClientConn is a wrapper around the gRPC client connection interface but ensures // there is a way to close the connection. type ClientConn interface { @@ -70,6 +74,8 @@ type ClientConn interface { // a PeerConnection. PeerConn() *webrtc.PeerConnection Close() error + + GetState() connectivity.State } // A ClientConnAuthenticator supports instructing a connection to authenticate now. diff --git a/rpc/wrtc_client_channel.go b/rpc/wrtc_client_channel.go index 087b0ffd..0393c6db 100644 --- a/rpc/wrtc_client_channel.go +++ b/rpc/wrtc_client_channel.go @@ -10,6 +10,7 @@ import ( grpc_logging "github.com/grpc-ecosystem/go-grpc-middleware/logging" "github.com/viamrobotics/webrtc/v3" "google.golang.org/grpc" + "google.golang.org/grpc/connectivity" "google.golang.org/grpc/metadata" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" @@ -333,6 +334,11 @@ func (ch *webrtcClientChannel) writeReset(stream *webrtcpb.Stream) error { }) } +// GetState returns the current connectivity state of the channel. +func (ch *webrtcClientChannel) GetState() connectivity.State { + return Unknown +} + func newClientLoggerFields(fullMethodString string) []any { service := path.Dir(fullMethodString)[1:] method := path.Base(fullMethodString) From 09a9f219256965b7fba1485ce7f6f4ea68a81fa8 Mon Sep 17 00:00:00 2001 From: Daniel Botros <93689852+danielbotros@users.noreply.github.com> Date: Fri, 5 Sep 2025 12:43:27 -0400 Subject: [PATCH 2/2] Change comment verb Co-authored-by: Cheuk <90270663+cheukt@users.noreply.github.com> --- rpc/dialer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/dialer.go b/rpc/dialer.go index 6c891312..a48fe667 100644 --- a/rpc/dialer.go +++ b/rpc/dialer.go @@ -62,7 +62,7 @@ type Dialer interface { Close() error } -// Unknown is an unknown connectivity state. +// Unknown indicates an unknown connectivity state. const Unknown connectivity.State = 5 // A ClientConn is a wrapper around the gRPC client connection interface but ensures