Skip to content

Commit 86b1030

Browse files
authored
pkg/settings/limits: set ErrorRateLimited.Key (#1797)
1 parent 1cd3adb commit 86b1030

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pkg/loop/settings.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ func (a *AtomicSettings) Unsubscribe(ch <-chan core.SettingsUpdate) {
7070
}
7171
}
7272

73+
func (a *AtomicSettings) Load() (core.SettingsUpdate, error) {
74+
a.mu.RLock()
75+
defer a.mu.RUnlock()
76+
return *a.current, nil
77+
}
78+
7379
func (a *AtomicSettings) Store(update core.SettingsUpdate) error {
7480
getter, err := settings.NewTOMLGetter([]byte(update.Settings))
7581
if err != nil {

pkg/settings/limits/rate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ func (l *rateLimiter) WaitN(ctx context.Context, n int) error {
321321

322322
func (f Factory) newScopedRateLimiter(limit settings.Setting[config.Rate]) (RateLimiter, error) {
323323
l := &scopedRateLimiter{
324+
key: limit.Key,
324325
scope: limit.Scope,
325326
defaultRate: limit.DefaultValue,
326327
}
@@ -373,6 +374,7 @@ func (f Factory) newScopedRateLimiter(limit settings.Setting[config.Rate]) (Rate
373374

374375
type scopedRateLimiter struct {
375376
lggr logger.Logger
377+
key string
376378
scope settings.Scope
377379
defaultRate config.Rate
378380

@@ -432,6 +434,7 @@ func (s *scopedRateLimiter) getOrCreate(ctx context.Context) (RateLimiter, func(
432434

433435
func (s *scopedRateLimiter) newRateLimiter(tenant string) *rateLimiter {
434436
l := &rateLimiter{
437+
key: s.key,
435438
scope: s.scope,
436439
tenant: tenant,
437440
updater: newUpdater[config.Rate](logger.With(s.lggr, s.scope.String(), tenant), s.rateFn, s.subFn),

0 commit comments

Comments
 (0)