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:
authorWill Chandler <wchandler@gitlab.com>2022-12-06 23:06:58 +0300
committerWill Chandler <wchandler@gitlab.com>2022-12-06 23:06:58 +0300
commit6e4f6f4e36f6af0a3710e11970bf7705cb5cec2c (patch)
tree1c0a8553771786b43a8c0f5a6c77a2892a8ea855 /internal/middleware
parent434051eb74b0043267538213192a790095caf671 (diff)
parent704fb5642d4512696e66a0cf07812b782963876e (diff)
Merge branch 'pks-convert-detailed-errors-to-structerr' into 'master'
global: Return structured errors via `structerr` package See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/5140 Merged-by: Will Chandler <wchandler@gitlab.com> Approved-by: Justin Tobler <jtobler@gitlab.com> Approved-by: Will Chandler <wchandler@gitlab.com> Co-authored-by: Patrick Steinhardt <psteinhardt@gitlab.com>
Diffstat (limited to 'internal/middleware')
-rw-r--r--internal/middleware/limithandler/rate_limiter.go16
1 files changed, 2 insertions, 14 deletions
diff --git a/internal/middleware/limithandler/rate_limiter.go b/internal/middleware/limithandler/rate_limiter.go
index 5f2f2d9f6..9e4114e23 100644
--- a/internal/middleware/limithandler/rate_limiter.go
+++ b/internal/middleware/limithandler/rate_limiter.go
@@ -9,8 +9,8 @@ import (
"github.com/prometheus/client_golang/prometheus"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
- "gitlab.com/gitlab-org/labkit/log"
"golang.org/x/time/rate"
"google.golang.org/protobuf/types/known/durationpb"
)
@@ -43,24 +43,12 @@ func (r *RateLimiter) Limit(ctx context.Context, lockKey string, f LimitedFunc)
// of traffic.
r.requestsDroppedMetric.Inc()
- err := helper.ErrUnavailable(ErrRateLimit)
-
- detailedErr, errGeneratingDetailedErr := helper.ErrWithDetails(
- err,
+ return nil, structerr.NewUnavailable("%w", ErrRateLimit).WithDetail(
&gitalypb.LimitError{
ErrorMessage: ErrRateLimit.Error(),
RetryAfter: durationpb.New(0),
},
)
- if errGeneratingDetailedErr != nil {
- log.WithField("rate_limit_error", err).
- WithError(errGeneratingDetailedErr).
- Error("failed to generate detailed error")
-
- return nil, err
- }
-
- return nil, detailedErr
}
return f()