refine the redeliver timeout schedule
This commit is contained in:
parent
24cee3302a
commit
dccbec5c8e
|
@ -35,28 +35,22 @@ type Doover struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func sayitagain(doover Doover) {
|
func sayitagain(doover Doover) {
|
||||||
rcpt := doover.Rcpt
|
|
||||||
var drift time.Duration
|
|
||||||
doover.Tries += 1
|
doover.Tries += 1
|
||||||
switch doover.Tries {
|
var drift time.Duration
|
||||||
case 1:
|
if doover.Tries <= 3 { // 5, 10, 15 minutes
|
||||||
drift = 5 * time.Minute
|
drift = time.Duration(doover.Tries*5) * time.Minute
|
||||||
case 2:
|
} else if doover.Tries <= 6 { // 1, 2, 3 hours
|
||||||
drift = 1 * time.Hour
|
drift = time.Duration(doover.Tries-3) * time.Hour
|
||||||
case 3:
|
} else if doover.Tries <= 9 { // 12, 12, 12 hours
|
||||||
drift = 4 * time.Hour
|
drift = time.Duration(12) * time.Hour
|
||||||
case 4:
|
} else {
|
||||||
drift = 12 * time.Hour
|
ilog.Printf("he's dead jim: %s", doover.Rcpt)
|
||||||
case 5:
|
|
||||||
drift = 24 * time.Hour
|
|
||||||
default:
|
|
||||||
ilog.Printf("he's dead jim: %s", rcpt)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
drift += time.Duration(notrand.Int63n(int64(drift / 10)))
|
drift += time.Duration(notrand.Int63n(int64(drift / 10)))
|
||||||
when := time.Now().Add(drift)
|
when := time.Now().Add(drift)
|
||||||
data := bytes.Join(doover.Msgs, []byte{0})
|
data := bytes.Join(doover.Msgs, []byte{0})
|
||||||
_, err := stmtAddDoover.Exec(when.UTC().Format(dbtimeformat), doover.Tries, doover.Userid, rcpt, data)
|
_, err := stmtAddDoover.Exec(when.UTC().Format(dbtimeformat), doover.Tries, doover.Userid, doover.Rcpt, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
elog.Printf("error saving doover: %s", err)
|
elog.Printf("error saving doover: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue