mongo2rethink/consumer.go
2016-11-17 10:15:59 +01:00

40 lines
590 B
Go

// consumer
package main
import (
"fmt"
"strings"
"time"
)
func consumer() {
for {
prod := <-consume
status = _Consumer
start := time.Now()
resp, err := dbs.Rethink.MultiInsert(prod.logins)
count.AddInsert(resp.Inserted)
if err != nil {
if !strings.Contains(err.Error(), "Duplicate primary key") {
count.AddErr(resp.Errors)
continue
} else {
count.AddDuplicate(resp.Errors)
}
}
count.AddLog(len(prod.logins))
if opts.Debug {
fmt.Printf("CONS: logins=%d in %v - active=%d\n", len(prod.logins), time.Since(start))
}
wg.Done()
}
}