diff --git a/conn/pool.go b/conn/pool.go index b8aa13057840b02c2db6687e4a04be52194c1d7e..40e00e8bb458dd6a61068263a2cfcfabcfd7a93f 100644 --- a/conn/pool.go +++ b/conn/pool.go @@ -13,12 +13,12 @@ var glog = x.Log("conn") type Pool struct { clients chan *rpc.Client - addr string + Addr string } func NewPool(addr string, maxCap int) *Pool { p := new(Pool) - p.addr = addr + p.Addr = addr p.clients = make(chan *rpc.Client, maxCap) client, err := p.dialNew() if err != nil { @@ -36,7 +36,7 @@ func (p *Pool) dialNew() (*rpc.Client, error) { var nconn net.Conn var err error for i := 0; i < 10; i++ { - nconn, err = d.Dial("tcp", p.addr) + nconn, err = d.Dial("tcp", p.Addr) if err == nil { break } @@ -44,7 +44,7 @@ func (p *Pool) dialNew() (*rpc.Client, error) { break } - glog.WithField("error", err).WithField("addr", p.addr). + glog.WithField("error", err).WithField("addr", p.Addr). Info("Retrying connection...") time.Sleep(10 * time.Second) } diff --git a/worker/worker.go b/worker/worker.go index 5175a9b5ac154b53155ea488afe4c6fb659cded4..1e97061c7c0d04122e3595ae902ffa4522dab21c 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -22,7 +22,6 @@ var glog = x.Log("worker") var dataStore, uidStore *store.Store var pools []*conn.Pool var numInstances, instanceIdx uint64 -var addrs []string func Init(ps, uStore *store.Store, idx, numInst uint64) { dataStore = ps @@ -45,8 +44,7 @@ func Connect(workerList []string) { Fatalf("Wrong number of instances in workerList") } - addrs = workerList - for _, addr := range addrs { + for _, addr := range workerList { if len(addr) == 0 { continue } @@ -73,7 +71,7 @@ func ProcessTaskOverNetwork(qu []byte) (result []byte, rerr error) { attr := string(q.Attr()) idx := farm.Fingerprint64([]byte(attr)) % numInstances - runHere := false + var runHere bool = false if attr == "_xid_" || attr == "_uid_" { idx = 0 runHere = (instanceIdx == 0) @@ -86,7 +84,7 @@ func ProcessTaskOverNetwork(qu []byte) (result []byte, rerr error) { } pool := pools[idx] - addr := addrs[idx] + addr := pool.Addr query := new(conn.Query) query.Data = qu reply := new(conn.Reply)