corretto un bug nella funzione <exit>. Aggiunta l'opzione MaxError per uscire nel caso di superamento numero errori su mongo

This commit is contained in:
Miki 2015-11-24 12:28:22 +01:00
parent 98b1858329
commit 31b3c5d14d
5 changed files with 10 additions and 3 deletions

View file

@ -80,7 +80,7 @@ func consumer(id int) {
retval, err := dbs.ll.Upsert(ind, ml)
if err != nil {
log.Printf("Insert error: %+v\n", err)
log.Printf("Insert error: %+v - %s\n", err, cons.user)
// se l'errore non e' "duplicate key error" salta al prossimo senza cancellare niente
count.AddErr()
cons.error = true

View file

@ -20,10 +20,11 @@ type Options struct {
Debug bool
Version bool
Concurrent int
MaxError int
}
func usage() {
fmt.Println("Usage: llmongo -m <mongo uri> -r <redis uri> -t <redis keys ttl> -l <logfile> -b <concurrent thread> -T <running ttl> -D -v\n")
fmt.Println("Usage: llmongo -m <mongo uri> -r <redis uri> -t <redis keys ttl> -l <logfile> -b <concurrent thread> -T <running ttl> -v\n")
os.Exit(0)
}
@ -46,4 +47,5 @@ func init() {
flag.DurationVar(&opts.Timeout, "T", 0, "Running timeout")
flag.BoolVar(&opts.Debug, "D", false, "Debug")
flag.IntVar(&opts.Concurrent, "c", 1, "Concurrent thread")
flag.IntVar(&opts.MaxError, "E", 100, "Max Mongodb Error")
}

View file

@ -64,4 +64,6 @@ func producer(id int) {
logins: logs,
}
}
done[id] <- true
}

View file

@ -27,6 +27,9 @@ func remover(id int) {
fmt.Printf("SADD (%d): %s\n", id, rem.user)
}
conn.Send("sadd", "llindex", rem.user)
if count.ValErr() >= opts.MaxError {
exit()
}
}
conn.Send("expire", rem.user, opts.RedisTTL.Seconds())
conn.Flush()

View file

@ -14,7 +14,7 @@ func exit() {
log.Println("EXIT ", i)
fmt.Println("EXIT ", i)
loop[i] = false
done[i] <- true
// done[i] <- true
}
}