func (c *connManagerType) Refreshes() uint64 {
	c.lock.Lock()
	defer c.lock.Unlock()
	return c.connRefreshes
}
Refreshes returns the number of connection refreshes. That is, the
number of times Get() created a new connection to replace a bad connection.
package queuesender
import (
	"bufio"
	"bytes"
	"crypto/tls"
	"encoding/json"
	"errors"
	"io"
	"net"
	"net/http"
	"net/url"
	"strings"
	"sync"
)
type connManagerType struct {
	refresh       func() (net.Conn, error)
	lock          sync.Mutex
	active        *connType
	connRefreshes uint64
}
func newConnManager(urlStr string) (*connManagerType, error) {
	scheme, endpoint, err := extractEndpoint(urlStr)
	if err != nil {
		return nil, err
	}
	var refresh func() (net.Conn, error)
	if scheme == "https" {
		refresh = func() (net.Conn, error) {
			return tls.Dial("tcp", endpoint, nil)
		}
	} else if scheme == "http" {
		refresh = func() (net.Conn, error) {
			return net.Dial("tcp", endpoint)
		}
	}
	if refresh == nil {
		return nil, errors.New("Unsupported scheme")
	}
	return &connManagerType{refresh: refresh}, nil
}
func (c *connManagerType) Get() (*connType, error) {
	c.lock.Lock()
	defer c.lock.Unlock()
	if c.active != nil && !c.active.isBad() {
		return c.active.get(), nil
	}
	conn, err := c.refresh()
	if err != nil {
		return nil, err
	}
	c.active = newConn(conn)
	c.connRefreshes++
	return c.active.get(), nil
}