update readme

This commit is contained in:
kevin
2020-10-11 19:42:40 +08:00
parent a1b141d31a
commit 20d53add46
2 changed files with 18 additions and 13 deletions

View File

@@ -16,12 +16,12 @@ func MaxConns(n int) func(http.Handler) http.Handler {
}
return func(next http.Handler) http.Handler {
latchLimiter := syncx.NewLimit(n)
latch := syncx.NewLimit(n)
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if latchLimiter.TryBorrow() {
if latch.TryBorrow() {
defer func() {
if err := latchLimiter.Return(); err != nil {
if err := latch.Return(); err != nil {
logx.Error(err)
}
}()