Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/service/ratelimit.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ratelimit

import (
"fmt"
"strings"
"sync"

Expand Down Expand Up @@ -113,7 +114,28 @@ func (this *service) shouldRateLimitWorker(

limitsToCheck := make([]*config.RateLimit, len(request.Descriptors))
for i, descriptor := range request.Descriptors {
if logger.IsLevelEnabled(logger.DebugLevel) {
var descriptorEntryStrings []string
for _, descriptorEntry := range descriptor.GetEntries() {
descriptorEntryStrings = append(
descriptorEntryStrings,
fmt.Sprintf("(%s=%s)", descriptorEntry.Key, descriptorEntry.Value),
)
}
logger.Debugf("got descriptor: %s", strings.Join(descriptorEntryStrings, ","))
}
limitsToCheck[i] = snappedConfig.GetLimit(ctx, request.Domain, descriptor)
if logger.IsLevelEnabled(logger.DebugLevel) {
if limitsToCheck[i] == nil {
logger.Debugf("descriptor does not match any limit, no limits applied")
} else {
logger.Debugf(
"applying limit: %d requests per %s",
limitsToCheck[i].Limit.RequestsPerUnit,
limitsToCheck[i].Limit.Unit.String(),
)
}
}
}

responseDescriptorStatuses := this.cache.DoLimit(ctx, request, limitsToCheck)
Expand Down