func (ts *ThriftSet) MaxActivePerHost() int {
	return ts.maxActivePerHost
}
MaxActivePerHost returna the max active connections for a given host.
This is part of the endpoints.Pooler interface.
package thriftset
import (
	"errors"
	"io"
	"time"
	"github.com/strava/go.serversets/internal/endpoints"
	"github.com/apache/thrift/lib/go/thrift"
	"github.com/strava/go.statsd"
)
const (
	sdConnRequested = "thriftset.conn.requested"
	sdConnCreated   = "thriftset.conn.created"
	sdConnCreateErr = "thriftset.conn.create_error"
	sdConnReleased  = "thriftset.conn.released"
	sdConnClosed    = "thriftset.conn.closed"
	sdZKEvent       = "thriftset.zk_event"
)
const (
	DefaultMaxIdlePerHost   = 10
	DefaultMaxActivePerHost = 10
	DefaultTimeout          = time.Second
	DefaultIdleTimeout      = 5 * time.Minute
)
var (
	ErrNoEndpoints = errors.New("thriftset: no endpoints configured or available")
	ErrGetOnClosedSet = errors.New("thriftset: get on closed set")
	ErrGetOnClosedEndpoint = errors.New("endpoint closed")
	errMap = map[error]error{
		endpoints.ErrNoEndpoints:         ErrNoEndpoints,
		endpoints.ErrGetOnClosedEndpoint: ErrGetOnClosedEndpoint,
	}
)
type Watcher interface {
	Endpoints() []string
	Event() <-chan struct{}
	IsClosed() bool
}
type ThriftSet struct {
	watch Watcher
	LastEvent  time.Time
	EventCount int
	StatsD     statsd.Stater
	maxIdlePerHost   int  
	maxActivePerHost int
	timeout          time.Duration
	idleTimeout      time.Duration
	endpoints *endpoints.Set
	event         chan struct{}
	watcherClosed chan struct{}
	done          chan struct{}
}
type Conn struct {
	thriftset *ThriftSet  
	parent    *endpoints.Conn
	Socket *thrift.TSocket  
	Client interface{}      
}
func New(watch Watcher) *ThriftSet {
	ts := &ThriftSet{
		watch:         watch,
		event:         make(chan struct{}, 1),
		watcherClosed: make(chan struct{}, 1),
		StatsD: statsd.NoopClient{},
		maxIdlePerHost:   DefaultMaxIdlePerHost,
		maxActivePerHost: DefaultMaxActivePerHost,
		timeout:          DefaultTimeout,
		idleTimeout:      DefaultIdleTimeout,
		done: make(chan struct{}),
	}
	ts.endpoints = endpoints.NewSet(ts)
	ts.resetEndpoints()
	go func() {
		defer func() {
			close(ts.watcherClosed)  
			watcherClosed()
		}()
		for {
			select {
			case <-ts.done:
				return
			case <-watch.Event():
				ts.StatsD.Count(sdZKEvent, 1.0)
				ts.resetEndpoints()
				ts.triggerEvent()
			}
			if watch.IsClosed() {
				break
			}
		}
	}()
	return ts
}
var watcherClosed = func() {}
func (ts *ThriftSet) OpenConn(hostPort string) (io.Closer, error) {
	ts.StatsD.Count(sdConnCreated)
	socket, err := socketBuilder(hostPort, ts.timeout)
	if err != nil {
		ts.StatsD.Count(sdConnCreateErr, 1.0)
		return nil, err
	}
	return socket, err
}
var socketBuilder = func(hostPort string, timeout time.Duration) (*thrift.TSocket, error) {
	return thrift.NewTSocketTimeout(hostPort, timeout)
}
func (ts *ThriftSet) IdleTimeout() time.Duration {
	return ts.idleTimeout
}
func (ts *ThriftSet) SetIdleTimeout(t time.Duration) {
	ts.idleTimeout = t
}