Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-14 15:05:43 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-15 10:13:03 +0300
commit84a404618f9d5046020bffd9a5d99de80f180efb (patch)
treea1f575d2db5e41b7ebeffb5b52065acc8e6a6a9e
parent152dd3c663c73f79db4c1ff0f63b9011316e35a0 (diff)
limithandler: Rename file hosting middleware implementation
The limithandler package implements both the concurrency-limiting primitives as well as the middleware used by gRPC. The files are confusingly named though, so it's not clear which file hosts which logic. Rename the "limithandler" file to "middleware" to clarify.
-rw-r--r--internal/middleware/limithandler/middleware.go (renamed from internal/middleware/limithandler/limithandler.go)15
-rw-r--r--internal/middleware/limithandler/middleware_test.go (renamed from internal/middleware/limithandler/limithandler_test.go)0
2 files changed, 10 insertions, 5 deletions
diff --git a/internal/middleware/limithandler/limithandler.go b/internal/middleware/limithandler/middleware.go
index 7d8d6ab8f..c276183a2 100644
--- a/internal/middleware/limithandler/limithandler.go
+++ b/internal/middleware/limithandler/middleware.go
@@ -3,6 +3,7 @@ package limithandler
import (
"context"
+ "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"google.golang.org/grpc"
)
@@ -78,11 +79,15 @@ func (w *wrappedStream) RecvMsg(m interface{}) error {
}
ready := make(chan struct{})
- go limiter.Limit(ctx, lockKey, func() (interface{}, error) {
- close(ready)
- <-ctx.Done()
- return nil, nil
- })
+ go func() {
+ if _, err := limiter.Limit(ctx, lockKey, func() (interface{}, error) {
+ close(ready)
+ <-ctx.Done()
+ return nil, nil
+ }); err != nil {
+ ctxlogrus.Extract(ctx).WithError(err).Error("rate limiting streaming request")
+ }
+ }()
select {
case <-ctx.Done():
diff --git a/internal/middleware/limithandler/limithandler_test.go b/internal/middleware/limithandler/middleware_test.go
index 84df9f150..84df9f150 100644
--- a/internal/middleware/limithandler/limithandler_test.go
+++ b/internal/middleware/limithandler/middleware_test.go