Open PFangwang opened 1 month ago
your func:
func (c *StatsConnection) Disconnect() { if c == nil { return } if c.statsClient != nil { if err := c.statsClient.Disconnect(); err != nil { log.Debugf("disconnecting stats client failed: %v", err) } } close(c.connChan) close(c.done) }
in another fiber:
case <-c.done: log.Debugf("health check watcher closed") c.sendStatsConnEvent(ConnectionEvent{Timestamp: time.Now(), State: Disconnected, Error: nil}) return }
func sendStatsConnEvent:
func (c *StatsConnection) sendStatsConnEvent(event ConnectionEvent) { select { case c.connChan <- event: default: log.Warn("Stats connection state channel is full, discarding value.") } }
note this: case c.connChan <- event: now the c.connChan is cloed,then panic
case c.connChan <- event:
your func:
in another fiber:
func sendStatsConnEvent:
note this:
case c.connChan <- event:
now the c.connChan is cloed,then panic