proxy.go 源码阅读
摘要:package mainimport ( "net" "time")func initProxy() { pLog.Infof("Proxying %s -> %s\n", pConfig.Bind, pConfig.Backend) //输出服务地址 后端服务地址列表 server, err := net.Listen("tcp", pConfig.Bind) ...
阅读全文
balance.go 源码阅读
摘要:import ( //"fmt" "math/rand" "net" "stathat.com/c/consistent" "time")// BackendSvr Typetype BackendSvr struct { svrStr string isUp bool // is Up or Down failTimes int}v...
阅读全文
monitor.go 源码阅读
摘要:package mainimport ( "fmt" "net/http")// 查询监控信息的接口func statsHandler(w http.ResponseWriter, r *http.Request) { _str := "" for _, v := range pBackendSvrs { _str += fmt.Sprintf("Server...
阅读全文
log.go 源码阅读
摘要:package mainimport ( "github.com/Sirupsen/logrus" "os" "path/filepath")func initLogger() error { dirPath, _ := filepath.Abs(filepath.Dir(pConfig.Log.Path)) //获取日志文件目录 if _, err := os.S...
阅读全文
config.go 源码阅读
摘要:package mainimport ( "io/ioutil" "launchpad.net/goyaml")// ProxyConfig Typetype ProxyConfig struct { Bind string `yaml:"bind"` //代理服务监听端口 WaitQueueLen int `yaml:"wait_que...
阅读全文