func (up UpstreamPool) Shutdown() {
	close(up.shutdown)
	up.Next()
}
This should only be called if the upstream pool is no longer active or this may deadlock
package upstream
import (
	"github.com/ngmoco/falcore"
	"net/http"
	"strconv"
	"strings"
	"sync"
	"time"
)
type UpstreamEntryConfig struct {
	HostPort  string
	Weight    int
	ForceHttp bool
	PingPath  string
}
type UpstreamEntry struct {
	Upstream *Upstream
	Weight   int
}
type UpstreamPool struct {
	pool         []*UpstreamEntry
	rr_count     int
	ping_count   int64
	Name         string
	nextUpstream chan *UpstreamEntry
	shutdown     chan int
	weightMutex  *sync.RWMutex
	pinger       *time.Ticker
}
func NewUpstreamPool(name string, config []UpstreamEntryConfig) *UpstreamPool {
	up := new(UpstreamPool)
	up.pool = make([]*UpstreamEntry, len(config))
	up.Name = name
	up.nextUpstream = make(chan *UpstreamEntry)
	up.weightMutex = new(sync.RWMutex)
	up.shutdown = make(chan int)
	up.pinger = time.NewTicker(3e9)  
	for i, uec := range config {
		parts := strings.Split(uec.HostPort, ":")
		upstreamHost := parts[0]
		upstreamPort := 80
		if len(parts) > 1 {
			var err error
			upstreamPort, err = strconv.Atoi(parts[1])
			if err != nil {
				upstreamPort = 80
				falcore.Error("UpstreamPool Error converting port to int for", upstreamHost, ":", err)
			}
		}
		ups := NewUpstream(upstreamHost, upstreamPort, uec.ForceHttp)
		ups.PingPath = uec.PingPath
		ue := new(UpstreamEntry)
		ue.Upstream = ups
		ue.Weight = uec.Weight
		up.pool[i] = ue
	}
	go up.nextServer()
	go up.pingUpstreams()
	return up
}
func (up UpstreamPool) Next() *UpstreamEntry {
	return <-up.nextUpstream
}
func (up UpstreamPool) LogStatus() {
	weightsBuffer := make([]int, len(up.pool))
	up.weightMutex.RLock()
	for i, ue := range up.pool {
		weightsBuffer[i] = ue.Weight
	}
	up.weightMutex.RUnlock()
	for i, ue := range up.pool {
		falcore.Info("Upstream %v: %v:%v\t%v", up.Name, ue.Upstream.Host, ue.Upstream.Port, weightsBuffer[i])
	}
}
func (up UpstreamPool) FilterRequest(req *falcore.Request) (res *http.Response) {
	ue := up.Next()
	res = ue.Upstream.FilterRequest(req)
	if req.CurrentStage.Status == 2 {
		up.updateUpstream(ue, 0)
		up.LogStatus()
	}
	return
}
func (up UpstreamPool) updateUpstream(ue *UpstreamEntry, wgt int) {
	up.weightMutex.Lock()
	ue.Weight = wgt
	up.weightMutex.Unlock()
}