Skip to content

Commit

Permalink
Address the comments
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato committed Nov 11, 2024
1 parent f240187 commit d98cf59
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions client/batch_controller.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 TiKV Project Authors.
// Copyright 2024 TiKV Project Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,20 +36,20 @@ type batchController[T any] struct {
collectedRequestCount int

// The finisher function to cancel collected requests when an internal error occurs.
cancelFinisher finisherFunc[T]
finisher finisherFunc[T]
// The observer to record the best batch size.
bestBatchObserver prometheus.Histogram
// The time after getting the first request and the token, and before performing extra batching.
extraBatchingStartTime time.Time
}

func newBatchController[T any](maxBatchSize int, cancelFinisher finisherFunc[T], bestBatchObserver prometheus.Histogram) *batchController[T] {
func newBatchController[T any](maxBatchSize int, finisher finisherFunc[T], bestBatchObserver prometheus.Histogram) *batchController[T] {
return &batchController[T]{
maxBatchSize: maxBatchSize,
bestBatchSize: defaultBestBatchSize,
collectedRequests: make([]T, maxBatchSize+1),
collectedRequestCount: 0,
cancelFinisher: cancelFinisher,
finisher: finisher,
bestBatchObserver: bestBatchObserver,
}
}
Expand All @@ -67,7 +67,7 @@ func (bc *batchController[T]) fetchPendingRequests(ctx context.Context, requestC
if tokenAcquired {
tokenCh <- struct{}{}
}
bc.finishCollectedRequests(bc.cancelFinisher, errRet)
bc.finishCollectedRequests(bc.finisher, errRet)
}
}()

Expand Down Expand Up @@ -224,7 +224,7 @@ func (bc *batchController[T]) adjustBestBatchSize() {

func (bc *batchController[T]) finishCollectedRequests(finisher finisherFunc[T], err error) {
if finisher == nil {
finisher = bc.cancelFinisher
finisher = bc.finisher
}
if finisher != nil {
for i := range bc.collectedRequestCount {
Expand Down

0 comments on commit d98cf59

Please sign in to comment.