Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DedupingBucketRateLimiter #6025

Merged
Merged
Show file tree
Hide file tree
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
36 changes: 36 additions & 0 deletions flytepropeller/pkg/controller/interfaces/rate_limiter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package interfaces

import (
"context"
"time"

"golang.org/x/time/rate"
)

//go:generate mockery-v2 --name Limiter --output ../mocks --case=snake --with-expecter
//go:generate mockery-v2 --name Reservation --output ../mocks --case=snake --with-expecter

type Limiter interface {
Allow() bool
AllowN(t time.Time, n int) bool
Burst() int
Limit() rate.Limit
Reserve() Reservation
ReserveN(t time.Time, n int) Reservation
SetBurst(newBurst int)
SetBurstAt(t time.Time, newBurst int)
SetLimit(newLimit rate.Limit)
SetLimitAt(t time.Time, newLimit rate.Limit)
Tokens() float64
TokensAt(t time.Time) float64
Wait(ctx context.Context) (err error)
WaitN(ctx context.Context, n int) (err error)
}

type Reservation interface {
Cancel()
CancelAt(t time.Time)
Delay() time.Duration
DelayFrom(t time.Time) time.Duration
OK() bool
}
Loading
Loading