From 2d1b3c3d1a1a1481541eec5ca89cdaa3e348ea73 Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Sun, 4 Aug 2024 15:29:13 -0400 Subject: [PATCH] debug statements --- pkg/gordio/nexus/nexus.go | 8 +++++++- pkg/gordio/nexus/websocket.go | 2 ++ pkg/gordio/sinks/nexus.go | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/gordio/nexus/nexus.go b/pkg/gordio/nexus/nexus.go index 07cb640..97d15b9 100644 --- a/pkg/gordio/nexus/nexus.go +++ b/pkg/gordio/nexus/nexus.go @@ -5,6 +5,8 @@ import ( "dynatron.me/x/stillbox/pkg/gordio/calls" "dynatron.me/x/stillbox/pkg/pb" + + "github.com/rs/zerolog/log" ) type Nexus struct { @@ -38,10 +40,12 @@ func (n *Nexus) Go(done <-chan struct{}) { for { select { case call, ok := <-n.callCh: + log.Debug().Msg("call received from ch") if !ok { return } + log.Debug().Msg("broadcasting call") n.broadcastCallToClients(call) case <-done: return @@ -51,6 +55,7 @@ func (n *Nexus) Go(done <-chan struct{}) { func (n *Nexus) BroadcastCall(call *calls.Call) { n.callCh <- call + log.Debug().Msg("call sent to ch") } func (n *Nexus) broadcastCallToClients(call *calls.Call) { @@ -61,7 +66,9 @@ func (n *Nexus) broadcastCallToClients(call *calls.Call) { defer n.Unlock() for cl, _ := range n.clients { + log.Debug().Msg("sending") if cl.Send(message) { + log.Debug().Msg("channel was closed") // we already hold the lock, and the channel is closed anyway delete(n.clients, cl) } @@ -80,6 +87,5 @@ func (n *Nexus) Unregister(c Client) { defer n.Unlock() cl := c.(*client) - cl.Connection.CloseCh() delete(n.clients, cl) } diff --git a/pkg/gordio/nexus/websocket.go b/pkg/gordio/nexus/websocket.go index 21c344b..16e1507 100644 --- a/pkg/gordio/nexus/websocket.go +++ b/pkg/gordio/nexus/websocket.go @@ -40,8 +40,10 @@ type wsConn struct { } func (w *wsConn) Send(msg *pb.Message) (closed bool) { + log.Debug().Msg("sending wsc") select { case w.out <- msg: + log.Debug().Str("msg", msg.String()).Msg("sent wsc") default: close(w.out) return true diff --git a/pkg/gordio/sinks/nexus.go b/pkg/gordio/sinks/nexus.go index 789eabd..bd397e4 100644 --- a/pkg/gordio/sinks/nexus.go +++ b/pkg/gordio/sinks/nexus.go @@ -5,6 +5,8 @@ import ( "dynatron.me/x/stillbox/pkg/gordio/calls" "dynatron.me/x/stillbox/pkg/gordio/nexus" + + "github.com/rs/zerolog/log" ) type NexusSink struct { @@ -24,6 +26,7 @@ func (ns *NexusSink) SinkType() string { } func (ns *NexusSink) Call(ctx context.Context, call *calls.Call) error { + log.Debug().Msg("nexus Call()") ns.nexus.BroadcastCall(call) return nil }