Resync oxy with original repository
This commit is contained in:
parent
da5e4a13bf
commit
bee8ebb00b
31 changed files with 650 additions and 808 deletions
4
vendor/github.com/vulcand/oxy/cbreaker/ratio.go
generated
vendored
4
vendor/github.com/vulcand/oxy/cbreaker/ratio.go
generated
vendored
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue