func NewPool(logOutput io.Writer, maxTime time.Duration, maxStreams int, tlsConfig *tls.Config) *ConnPool {
	pool := &ConnPool{
		logOutput:  logOutput,
		maxTime:    maxTime,
		maxStreams: maxStreams,
		pool:       make(map[string]*Conn),
		tlsConfig:  tlsConfig,
		shutdownCh: make(chan struct{}),
	}
	if maxTime > 0 {
		go pool.reap()
	}
	return pool
}
NewPool is used to make a new connection pool
Maintain at most one connection per host, for up to maxTime.
Set maxTime to 0 to disable reaping. maxStreams is used to control
the number of idle streams allowed.
If TLS settings are provided outgoing connections use TLS.
package consul
import (
	"container/list"
	"crypto/tls"
	"fmt"
	"io"
	"net"
	"net/rpc"
	"sync"
	"sync/atomic"
	"time"
	"github.com/socketplane/socketplane/Godeps/_workspace/src/github.com/hashicorp/consul/tlsutil"
	"github.com/socketplane/socketplane/Godeps/_workspace/src/github.com/hashicorp/go-msgpack/codec"
	"github.com/socketplane/socketplane/Godeps/_workspace/src/github.com/hashicorp/yamux"
	"github.com/socketplane/socketplane/Godeps/_workspace/src/github.com/inconshreveable/muxado"
)
var msgpackHandle = &codec.MsgpackHandle{}
type muxSession interface {
	Open() (net.Conn, error)
	Close() error
}
type muxadoWrapper struct {
	m muxado.Session
}
func (w *muxadoWrapper) Open() (net.Conn, error) {
	return w.m.Open()
}
func (w *muxadoWrapper) Close() error {
	return w.m.Close()
}
type StreamClient struct {
	stream net.Conn
	client *rpc.Client
}
type Conn struct {
	refCount    int32
	shouldClose int32
	addr     net.Addr
	session  muxSession
	lastUsed time.Time
	version  int
	pool *ConnPool
	clients    *list.List
	clientLock sync.Mutex
}
func (c *Conn) Close() error {
	return c.session.Close()
}
func (c *Conn) getClient() (*StreamClient, error) {
	c.clientLock.Lock()
	front := c.clients.Front()
	if front != nil {
		c.clients.Remove(front)
	}
	c.clientLock.Unlock()
	if front != nil {
		return front.Value.(*StreamClient), nil
	}
	stream, err := c.session.Open()
	if err != nil {
		return nil, err
	}
	cc := codec.GoRpc.ClientCodec(stream, msgpackHandle)
	client := rpc.NewClientWithCodec(cc)
	sc := &StreamClient{
		stream: stream,
		client: client,
	}
	return sc, nil
}
func (c *Conn) returnClient(client *StreamClient) {
	didSave := false
	c.clientLock.Lock()
	if c.clients.Len() < c.pool.maxStreams && atomic.LoadInt32(&c.shouldClose) == 0 {
		c.clients.PushFront(client)
		didSave = true
	}
	c.clientLock.Unlock()
	if !didSave {
		client.stream.Close()
	}
}
type ConnPool struct {
	sync.Mutex
	logOutput io.Writer
	maxTime time.Duration
	maxStreams int
	pool map[string]*Conn
	tlsConfig *tls.Config
	shutdown   bool
	shutdownCh chan struct{}
}