1
0
Fork 0

Resync oxy with original repository

This commit is contained in:
SALLEYRON Julien 2017-11-22 18:20:03 +01:00 committed by Traefiker
parent da5e4a13bf
commit bee8ebb00b
31 changed files with 650 additions and 808 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"time"
log "github.com/Sirupsen/logrus"
"github.com/mailgun/timetools"
)
@ -33,14 +34,17 @@ func (r *ratioController) String() string {
}
func (r *ratioController) allowRequest() bool {
log.Infof("%v", r)
t := r.targetRatio()
// This condition answers the question - would we satisfy the target ratio if we allow this request?
e := r.computeRatio(r.allowed+1, r.denied)
if e < t {
r.allowed++
log.Infof("%v allowed", r)
return true
}
r.denied++
log.Infof("%v denied", r)
return false
}