debug statements
This commit is contained in:
parent
3f11a70e8e
commit
2d1b3c3d1a
3 changed files with 12 additions and 1 deletions
|
@ -5,6 +5,8 @@ import (
|
||||||
|
|
||||||
"dynatron.me/x/stillbox/pkg/gordio/calls"
|
"dynatron.me/x/stillbox/pkg/gordio/calls"
|
||||||
"dynatron.me/x/stillbox/pkg/pb"
|
"dynatron.me/x/stillbox/pkg/pb"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Nexus struct {
|
type Nexus struct {
|
||||||
|
@ -38,10 +40,12 @@ func (n *Nexus) Go(done <-chan struct{}) {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case call, ok := <-n.callCh:
|
case call, ok := <-n.callCh:
|
||||||
|
log.Debug().Msg("call received from ch")
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debug().Msg("broadcasting call")
|
||||||
n.broadcastCallToClients(call)
|
n.broadcastCallToClients(call)
|
||||||
case <-done:
|
case <-done:
|
||||||
return
|
return
|
||||||
|
@ -51,6 +55,7 @@ func (n *Nexus) Go(done <-chan struct{}) {
|
||||||
|
|
||||||
func (n *Nexus) BroadcastCall(call *calls.Call) {
|
func (n *Nexus) BroadcastCall(call *calls.Call) {
|
||||||
n.callCh <- call
|
n.callCh <- call
|
||||||
|
log.Debug().Msg("call sent to ch")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Nexus) broadcastCallToClients(call *calls.Call) {
|
func (n *Nexus) broadcastCallToClients(call *calls.Call) {
|
||||||
|
@ -61,7 +66,9 @@ func (n *Nexus) broadcastCallToClients(call *calls.Call) {
|
||||||
defer n.Unlock()
|
defer n.Unlock()
|
||||||
|
|
||||||
for cl, _ := range n.clients {
|
for cl, _ := range n.clients {
|
||||||
|
log.Debug().Msg("sending")
|
||||||
if cl.Send(message) {
|
if cl.Send(message) {
|
||||||
|
log.Debug().Msg("channel was closed")
|
||||||
// we already hold the lock, and the channel is closed anyway
|
// we already hold the lock, and the channel is closed anyway
|
||||||
delete(n.clients, cl)
|
delete(n.clients, cl)
|
||||||
}
|
}
|
||||||
|
@ -80,6 +87,5 @@ func (n *Nexus) Unregister(c Client) {
|
||||||
defer n.Unlock()
|
defer n.Unlock()
|
||||||
|
|
||||||
cl := c.(*client)
|
cl := c.(*client)
|
||||||
cl.Connection.CloseCh()
|
|
||||||
delete(n.clients, cl)
|
delete(n.clients, cl)
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,10 @@ type wsConn struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wsConn) Send(msg *pb.Message) (closed bool) {
|
func (w *wsConn) Send(msg *pb.Message) (closed bool) {
|
||||||
|
log.Debug().Msg("sending wsc")
|
||||||
select {
|
select {
|
||||||
case w.out <- msg:
|
case w.out <- msg:
|
||||||
|
log.Debug().Str("msg", msg.String()).Msg("sent wsc")
|
||||||
default:
|
default:
|
||||||
close(w.out)
|
close(w.out)
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
|
|
||||||
"dynatron.me/x/stillbox/pkg/gordio/calls"
|
"dynatron.me/x/stillbox/pkg/gordio/calls"
|
||||||
"dynatron.me/x/stillbox/pkg/gordio/nexus"
|
"dynatron.me/x/stillbox/pkg/gordio/nexus"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NexusSink struct {
|
type NexusSink struct {
|
||||||
|
@ -24,6 +26,7 @@ func (ns *NexusSink) SinkType() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ns *NexusSink) Call(ctx context.Context, call *calls.Call) error {
|
func (ns *NexusSink) Call(ctx context.Context, call *calls.Call) error {
|
||||||
|
log.Debug().Msg("nexus Call()")
|
||||||
ns.nexus.BroadcastCall(call)
|
ns.nexus.BroadcastCall(call)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue