2016-11-10 17:26:17 +01:00
|
|
|
// consumer
|
|
|
|
package m2r
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2016-11-17 10:09:23 +01:00
|
|
|
|
2016-11-10 17:26:17 +01:00
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func consumer() {
|
|
|
|
|
|
|
|
for {
|
|
|
|
|
|
|
|
prod := <-consume
|
|
|
|
|
|
|
|
status = _Consumer
|
|
|
|
|
|
|
|
start := time.Now()
|
|
|
|
|
2016-11-17 10:09:23 +01:00
|
|
|
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
|
2016-11-10 17:26:17 +01:00
|
|
|
} else {
|
2016-11-17 10:09:23 +01:00
|
|
|
count.AddDuplicate(resp.Errors)
|
2016-11-10 17:26:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
count.AddLog(len(prod.logins))
|
|
|
|
|
|
|
|
if opts.Debug {
|
2016-11-17 10:09:23 +01:00
|
|
|
fmt.Printf("CONS: logins=%d in %v - active=%d\n", len(prod.logins), time.Since(start))
|
2016-11-10 17:26:17 +01:00
|
|
|
}
|
|
|
|
|
2016-11-17 10:09:23 +01:00
|
|
|
wg.Done()
|
2016-11-10 17:26:17 +01:00
|
|
|
}
|
|
|
|
}
|