}
func (b *Balancer) balance(work <-chan *Request) {
+ fmt.Println("balance(): Starting workers..")
+ for _, w := range b.pool {
+ go w.work(time.Now().Format("05.000"), b.done)
+ time.Sleep(time.Second)
+ }
+
timeout := time.After(20 * time.Second)
out:
for {
func (b *Balancer) dispatch(req *Request) {
w := heap.Pop(&b.pool).(*Worker)
fmt.Printf("dispatch() '%v': sending to '%v'\n", req, w)
- go w.work(time.Now().Format("05.000"), b.done)
w.pending++
heap.Push(&b.pool, w)
w.requests <- req