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

Remove references to controller-runtime/pkg/ratelimiter #777

Closed
Closed
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
3 changes: 1 addition & 2 deletions pkg/ratelimiter/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"golang.org/x/time/rate"
"k8s.io/client-go/rest"
"k8s.io/client-go/util/workqueue"
"sigs.k8s.io/controller-runtime/pkg/ratelimiter"
)

// NewGlobal returns a token bucket rate limiter meant for limiting the number
Expand All @@ -36,7 +35,7 @@ func NewGlobal(rps int) *workqueue.BucketRateLimiter {
// NewController returns a rate limiter that takes the maximum delay between the
// passed rate limiter and a per-item exponential backoff limiter. The
// exponential backoff limiter has a base delay of 1s and a maximum of 60s.
func NewController() ratelimiter.RateLimiter {
func NewController() workqueue.RateLimiter {
return workqueue.NewItemExponentialFailureRateLimiter(1*time.Second, 60*time.Second)
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/ratelimiter/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"sync"
"time"

"sigs.k8s.io/controller-runtime/pkg/ratelimiter"
"k8s.io/client-go/util/workqueue"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)

Expand All @@ -31,7 +31,7 @@ import (
type Reconciler struct {
name string
inner reconcile.Reconciler
limit ratelimiter.RateLimiter
limit workqueue.RateLimiter

limited map[string]struct{}
limitedL sync.RWMutex
Expand All @@ -40,7 +40,7 @@ type Reconciler struct {
// NewReconciler wraps the supplied Reconciler, ensuring requests are passed to
// it no more frequently than the supplied RateLimiter allows. Multiple uniquely
// named Reconcilers can share the same RateLimiter.
func NewReconciler(name string, r reconcile.Reconciler, l ratelimiter.RateLimiter) *Reconciler {
func NewReconciler(name string, r reconcile.Reconciler, l workqueue.RateLimiter) *Reconciler {
return &Reconciler{name: name, inner: r, limit: l, limited: make(map[string]struct{})}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/ratelimiter/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (

"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/ratelimiter"
"k8s.io/client-go/util/workqueue"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/crossplane/crossplane-runtime/pkg/test"
)

var _ ratelimiter.RateLimiter = &predictableRateLimiter{}
var _ workqueue.RateLimiter = &predictableRateLimiter{}

type predictableRateLimiter struct{ d time.Duration }

Expand Down