Ejemplo n.º 1
0
// watch watches the connection for error, sends detected error to c.errors
func (c *conn) watch(log *loggo.Logger) {
	for {
		data := make([]byte, 1)
		_, err := c.netConn.Read(data)

		if err != nil {
			log.Errorf("Connection error: %v on Connection: %d", err, c.connectionId)
			c.netConn.Close()
			c.errors <- err
			return
		}
	}
}
Ejemplo n.º 2
0
// reconnectNeeded determines if a reconnect is needed by checking for a
// message on the readErrors channel
func (c *conn) reconnectNeeded(log *loggo.Logger) bool {
	if c == nil {
		return true
	}

	if c.forceReset {
		return true
	}

	select {
	case <-c.errors:
		log.Errorf("Error from connection: %d reconnectNeeded due to error while reading", c.connectionId)
		return true
	default:
		return false
	}
}