func (s *Sender) sendLoop() {
	var lastConn *connType
	for {
		req := s.queue.NextNotSent()
		conn := s.getConn()
		if conn != lastConn {
			lastConn = conn
			s.queue.ResetNextNotSent()
			req = s.queue.NextNotSent()
		}
		if err := conn.Send(req); err != nil {
			conn.MarkBad()
		}
		conn.Put()
	}
}
This loop sends requests in the queue.
package queuesender
import (
	"fmt"
	"github.com/Symantec/Dominator/lib/log"
	"github.com/Symantec/tricorder/go/tricorder"
	"github.com/Symantec/tricorder/go/tricorder/units"
	"time"
)
func _new(endpoint string, size int, name string, logger log.Logger) (
	*Sender, error) {
	if size < 1 {
		panic("Size must be at least 1")
	}
	connManager, err := newConnManager(endpoint)
	if err != nil {
		return nil, err
	}
	result := &Sender{
		queue:       newQueue(size),
		connManager: connManager,
	}
	if logger != nil {
		result.logger = &loggerType{name: name, logger: logger}
	}
	go result.sendLoop()
	go result.receiveLoop()
	return result, nil
}
func (s *Sender) getConn() *connType {
	conn, err := s.connManager.Get()
	duration := time.Second
	for err != nil {
		s.logger.Log(err)
		time.Sleep(duration)
		duration *= 2
		conn, err = s.connManager.Get()
	}
	return conn
}