Example #1
0
func startWorkers(config mylib.Config, r *consistent.Consistent, mon *mylib.Mmon) []mylib.Sender {
	workers := make([]mylib.Sender, 0)
	index := 0
	for _, st := range config.Storages {
		for j := 0; j <= st.Num; j++ {
			var w mylib.Sender
			w.Host = st.Host
			w.Port = st.Port
			w.Pipe = make(chan string, config.ChanLimit)
			w.Index = index
			r.Add(st.Host)
			index++
			workers = append(workers, w)
			go sender(w, &mon.Send)
		}
	}
	return workers
}
Example #2
0
func buildMapping(mapping map[string][]string, hosts []string, con *consistent.Consistent) {
	for _, host := range hosts {
		site, _ := con.Get(host)
		mapping[site] = append(mapping[site], host)
	}
}