Skip to content

Commit 8691d33

Browse files
committed
kvserver: rename processCallback processCallback to cb processCallback
Previously, the variable name processCallback shadowed its type name, which was not ideal. This commit renames the variable to cb.
1 parent b80f751 commit 8691d33

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

pkg/kv/kvserver/queue.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -660,17 +660,17 @@ func (h baseQueueHelper) MaybeAdd(
660660
}
661661

662662
func (h baseQueueHelper) Add(
663-
ctx context.Context, repl replicaInQueue, prio float64, processCallback processCallback,
663+
ctx context.Context, repl replicaInQueue, prio float64, cb processCallback,
664664
) {
665-
_, err := h.bq.addInternal(ctx, repl.Desc(), repl.ReplicaID(), prio, processCallback)
665+
_, err := h.bq.addInternal(ctx, repl.Desc(), repl.ReplicaID(), prio, cb)
666666
if err != nil && log.V(1) {
667667
log.Infof(ctx, "during Add: %s", err)
668668
}
669669
}
670670

671671
type queueHelper interface {
672672
MaybeAdd(ctx context.Context, repl replicaInQueue, now hlc.ClockTimestamp)
673-
Add(ctx context.Context, repl replicaInQueue, prio float64, processCallback processCallback)
673+
Add(ctx context.Context, repl replicaInQueue, prio float64, cb processCallback)
674674
}
675675

676676
// baseQueueAsyncRateLimited indicates that the base queue async task was rate
@@ -727,12 +727,12 @@ func (bq *baseQueue) MaybeAddAsync(
727727
// register a process callback that will be invoked when the replica is enqueued
728728
// or processed.
729729
func (bq *baseQueue) AddAsyncWithCallback(
730-
ctx context.Context, repl replicaInQueue, prio float64, processCallback processCallback,
730+
ctx context.Context, repl replicaInQueue, prio float64, cb processCallback,
731731
) {
732732
if err := bq.Async(ctx, "Add", true /* wait */, func(ctx context.Context, h queueHelper) {
733-
h.Add(ctx, repl, prio, processCallback)
733+
h.Add(ctx, repl, prio, cb)
734734
}); err != nil {
735-
processCallback.onEnqueueResult(-1 /*indexOnHeap*/, err)
735+
cb.onEnqueueResult(-1 /*indexOnHeap*/, err)
736736
}
737737
}
738738

@@ -838,22 +838,22 @@ func (bq *baseQueue) addInternal(
838838
desc *roachpb.RangeDescriptor,
839839
replicaID roachpb.ReplicaID,
840840
priority float64,
841-
processCallback processCallback,
841+
cb processCallback,
842842
) (bool, error) {
843843
// NB: this is intentionally outside of bq.mu to avoid having to consider
844844
// lock ordering constraints.
845845
if !desc.IsInitialized() {
846846
// We checked this above in MaybeAdd(), but we need to check it
847847
// again for Add().
848-
processCallback.onEnqueueResult(-1 /*indexOnHeap*/, errReplicaNotInitialized)
848+
cb.onEnqueueResult(-1 /*indexOnHeap*/, errReplicaNotInitialized)
849849
return false, errReplicaNotInitialized
850850
}
851851

852852
bq.mu.Lock()
853853
defer bq.mu.Unlock()
854854

855855
if bq.mu.stopped {
856-
processCallback.onEnqueueResult(-1 /*indexOnHeap*/, errQueueStopped)
856+
cb.onEnqueueResult(-1 /*indexOnHeap*/, errQueueStopped)
857857
return false, errQueueStopped
858858
}
859859

@@ -866,14 +866,14 @@ func (bq *baseQueue) addInternal(
866866
if log.V(3) {
867867
log.Infof(ctx, "queue disabled")
868868
}
869-
processCallback.onEnqueueResult(-1 /*indexOnHeap*/, errQueueDisabled)
869+
cb.onEnqueueResult(-1 /*indexOnHeap*/, errQueueDisabled)
870870
return false, errQueueDisabled
871871
}
872872
}
873873

874874
// If the replica is currently in purgatory, don't re-add it.
875875
if _, ok := bq.mu.purgatory[desc.RangeID]; ok {
876-
processCallback.onEnqueueResult(-1 /*indexOnHeap*/, errReplicaAlreadyInPurgatory)
876+
cb.onEnqueueResult(-1 /*indexOnHeap*/, errReplicaAlreadyInPurgatory)
877877
return false, nil
878878
}
879879

@@ -883,7 +883,7 @@ func (bq *baseQueue) addInternal(
883883
if item.processing {
884884
wasRequeued := item.requeue
885885
item.requeue = true
886-
processCallback.onEnqueueResult(-1 /*indexOnHeap*/, errReplicaAlreadyProcessing)
886+
cb.onEnqueueResult(-1 /*indexOnHeap*/, errReplicaAlreadyProcessing)
887887
return !wasRequeued, nil
888888
}
889889

@@ -895,8 +895,8 @@ func (bq *baseQueue) addInternal(
895895
log.Infof(ctx, "updating priority: %0.3f -> %0.3f", item.priority, priority)
896896
}
897897
bq.mu.priorityQ.update(item, priority)
898-
// item.index should be updated now based on heap property now.
899-
processCallback.onEnqueueResult(item.index /*indexOnHeap*/, nil)
898+
// item.index should be updated now based on heap property now.
899+
cb.onEnqueueResult(item.index /*indexOnHeap*/, nil)
900900
}
901901
return false, nil
902902
}
@@ -905,7 +905,7 @@ func (bq *baseQueue) addInternal(
905905
log.Infof(ctx, "adding: priority=%0.3f", priority)
906906
}
907907
item = &replicaItem{rangeID: desc.RangeID, replicaID: replicaID, priority: priority}
908-
item.registerCallback(processCallback)
908+
item.registerCallback(cb)
909909
bq.addLocked(item)
910910

911911
// If adding this replica has pushed the queue past its maximum size, remove
@@ -922,8 +922,8 @@ func (bq *baseQueue) addInternal(
922922
priority, replicaItemToDrop.replicaID)
923923
// TODO(wenyihu6): when we introduce base queue max size cluster setting,
924924
// remember to invoke this callback when shrinking the size
925-
for _, cb := range replicaItemToDrop.callbacks {
926-
cb.onEnqueueResult(-1 /*indexOnHeap*/, errDroppedDueToFullQueueSize)
925+
for _, callback := range replicaItemToDrop.callbacks {
926+
callback.onEnqueueResult(-1 /*indexOnHeap*/, errDroppedDueToFullQueueSize)
927927
}
928928
bq.removeLocked(replicaItemToDrop)
929929
}
@@ -934,7 +934,7 @@ func (bq *baseQueue) addInternal(
934934
// No need to signal again.
935935
}
936936
// Note: it may already be dropped or dropped afterwards.
937-
processCallback.onEnqueueResult(item.index /*indexOnHeap*/, nil)
937+
cb.onEnqueueResult(item.index /*indexOnHeap*/, nil)
938938
return true, nil
939939
}
940940

@@ -1384,7 +1384,7 @@ func (bq *baseQueue) addToPurgatoryLocked(
13841384
repl replicaInQueue,
13851385
purgErr PurgatoryError,
13861386
priorityAtEnqueue float64,
1387-
processCallback []processCallback,
1387+
cbs []processCallback,
13881388
) {
13891389
bq.mu.AssertHeld()
13901390

@@ -1413,7 +1413,7 @@ func (bq *baseQueue) addToPurgatoryLocked(
14131413
replicaID: repl.ReplicaID(),
14141414
index: -1,
14151415
priority: priorityAtEnqueue,
1416-
callbacks: processCallback,
1416+
callbacks: cbs,
14171417
}
14181418

14191419
bq.mu.replicas[repl.GetRangeID()] = item

pkg/kv/kvserver/queue_helpers_testutil.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ func (bq *baseQueue) testingAdd(
2525
// register a process callback that will be invoked when the replica is enqueued
2626
// or processed.
2727
func (bq *baseQueue) testingAddWithCallback(
28-
ctx context.Context, repl replicaInQueue, priority float64, callback processCallback,
28+
ctx context.Context, repl replicaInQueue, priority float64, cb processCallback,
2929
) (bool, error) {
30-
return bq.addInternal(ctx, repl.Desc(), repl.ReplicaID(), priority, callback)
30+
return bq.addInternal(ctx, repl.Desc(), repl.ReplicaID(), priority, cb)
3131
}
3232

3333
func forceScanAndProcess(ctx context.Context, s *Store, q *baseQueue) error {

0 commit comments

Comments
 (0)