Skip to content

Commit

Permalink
Expose burst
Browse files Browse the repository at this point in the history
  • Loading branch information
jveski committed Nov 6, 2023
1 parent 29cee68 commit cc31378
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions internal/reconstitution/writebuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ type writeBuffer struct {
queue workqueue.RateLimitingInterface
}

func newWriteBuffer(cli client.Client, logger logr.Logger, batchInterval time.Duration) *writeBuffer {
func newWriteBuffer(cli client.Client, logger logr.Logger, batchInterval time.Duration, burst int) *writeBuffer {
return &writeBuffer{
client: cli,
logger: logger.WithValues("controller", "writeBuffer"),
state: make(map[types.NamespacedName][]*asyncStatusUpdate),
queue: workqueue.NewRateLimitingQueueWithConfig(
&workqueue.BucketRateLimiter{Limiter: rate.NewLimiter(rate.Every(batchInterval), 2)},
&workqueue.BucketRateLimiter{Limiter: rate.NewLimiter(rate.Every(batchInterval), burst)},
workqueue.RateLimitingQueueConfig{
Name: "writeBuffer",
}),
Expand Down
12 changes: 6 additions & 6 deletions internal/reconstitution/writebuffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
func TestWriteBufferBasics(t *testing.T) {
ctx := context.Background()
cli := testutil.NewClient(t)
w := newWriteBuffer(cli, testr.New(t), 0)
w := newWriteBuffer(cli, testr.New(t), 0, 1)

// One resource slice w/ len of 3
slice := &apiv1.ResourceSlice{}
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestWriteBufferBatching(t *testing.T) {
return client.SubResource(subResourceName).Update(ctx, obj, opts...)
},
})
w := newWriteBuffer(cli, testr.New(t), time.Millisecond*2)
w := newWriteBuffer(cli, testr.New(t), time.Millisecond*2, 1)

// One resource slice w/ len of 3
slice := &apiv1.ResourceSlice{}
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestWriteBufferBatching(t *testing.T) {
func TestWriteBufferNoUpdates(t *testing.T) {
ctx := context.Background()
cli := testutil.NewClient(t)
w := newWriteBuffer(cli, testr.New(t), 0)
w := newWriteBuffer(cli, testr.New(t), 0, 1)

// One resource slice w/ len of 3
slice := &apiv1.ResourceSlice{}
Expand All @@ -115,7 +115,7 @@ func TestWriteBufferNoUpdates(t *testing.T) {
func TestWriteBufferMissingSlice(t *testing.T) {
ctx := context.Background()
cli := testutil.NewClient(t)
w := newWriteBuffer(cli, testr.New(t), 0)
w := newWriteBuffer(cli, testr.New(t), 0, 1)

req := &ManifestRef{}
req.Slice.Name = "test-slice-1" // this doesn't exist
Expand All @@ -135,7 +135,7 @@ func TestWriteBufferNoChange(t *testing.T) {
return nil
},
})
w := newWriteBuffer(cli, testr.New(t), 0)
w := newWriteBuffer(cli, testr.New(t), 0, 1)

// One resource slice
slice := &apiv1.ResourceSlice{}
Expand All @@ -161,7 +161,7 @@ func TestWriteBufferUpdateError(t *testing.T) {
return errors.New("could be any error")
},
})
w := newWriteBuffer(cli, testr.New(t), 0)
w := newWriteBuffer(cli, testr.New(t), 0, 1)

// One resource slice w/ len of 3
slice := &apiv1.ResourceSlice{}
Expand Down

0 comments on commit cc31378

Please sign in to comment.