Skip to content

Commit

Permalink
use value
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed May 11, 2024
1 parent 5229bb3 commit b9b2971
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions pkg/core/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ type RegionHeartbeatRequest interface {
}

// RegionFromHeartbeat constructs a Region from region heartbeat.
func RegionFromHeartbeat(heartbeat RegionHeartbeatRequest, opts ...RegionCreateOption) *RegionInfo {
func RegionFromHeartbeat(heartbeat RegionHeartbeatRequest, opts ...RegionCreateOption) RegionInfo {
// Convert unit to MB.
// If region isn't empty and less than 1MB, use 1MB instead.
// The size of empty region will be correct by the previous RegionInfo.
Expand All @@ -221,7 +221,7 @@ func RegionFromHeartbeat(heartbeat RegionHeartbeatRequest, opts ...RegionCreateO
regionSize = EmptyRegionApproximateSize
}

region := &RegionInfo{
region := RegionInfo{
term: heartbeat.GetTerm(),
meta: heartbeat.GetRegion(),
leader: heartbeat.GetLeader(),
Expand All @@ -246,7 +246,7 @@ func RegionFromHeartbeat(heartbeat RegionHeartbeatRequest, opts ...RegionCreateO
}

for _, opt := range opts {
opt(region)
opt(&region)
}

if region.writtenKeys >= ImpossibleFlowSize || region.writtenBytes >= ImpossibleFlowSize {
Expand All @@ -261,7 +261,7 @@ func RegionFromHeartbeat(heartbeat RegionHeartbeatRequest, opts ...RegionCreateO
sort.Sort(peerStatsSlice(region.downPeers))
sort.Sort(peerSlice(region.pendingPeers))

classifyVoterAndLearner(region)
classifyVoterAndLearner(&region)
return region

Check failure on line 265 in pkg/core/region.go

View workflow job for this annotation

GitHub Actions / statics

copylocks: return copies lock value: github.com/tikv/pd/pkg/core.RegionInfo contains sync/atomic.Int32 contains sync/atomic.noCopy (govet)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/mcs/scheduling/server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (s *Service) RegionHeartbeat(stream schedulingpb.Scheduling_RegionHeartbeat
lastBind = time.Now()
}
region := core.RegionFromHeartbeat(request)
err = c.HandleRegionHeartbeat(region)
err = c.HandleRegionHeartbeat(&region)
if err != nil {
// TODO: if we need to send the error back to API server.
log.Error("failed handle region heartbeat", zap.Error(err))
Expand Down
10 changes: 5 additions & 5 deletions pkg/ratelimit/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var TaskPool = &sync.Pool{
// Task is a task to run.
type Task struct {
Ctx context.Context
Opts *TaskOpts
Opts TaskOpts
f func(context.Context)
submittedAt time.Time
}
Expand All @@ -63,7 +63,7 @@ func NewTask(ctx context.Context, f func(context.Context), opts ...TaskOption) *
task := TaskPool.Get().(*Task)
task.Ctx = ctx
task.f = f
task.Opts = &TaskOpts{}
task.Opts = TaskOpts{}
task.submittedAt = time.Now()
for _, opt := range opts {
opt(task.Opts)
Expand All @@ -74,7 +74,7 @@ func NewTask(ctx context.Context, f func(context.Context), opts ...TaskOption) *
// ReleaseTask releases the task.
func ReleaseTask(task *Task) {
task.Ctx = nil
task.Opts = nil
task.Opts = TaskOpts{}
task.f = nil
task.submittedAt = time.Time{}
TaskPool.Put(task)
Expand Down Expand Up @@ -120,11 +120,11 @@ type TaskOpts struct {
}

// TaskOption configures TaskOp
type TaskOption func(opts *TaskOpts)
type TaskOption func(opts TaskOpts)

// WithTaskName specify the task name.
func WithTaskName(name string) TaskOption {
return func(opts *TaskOpts) { opts.TaskName = name }
return func(opts TaskOpts) { opts.TaskName = name }
}

// Start starts the runner.
Expand Down
2 changes: 1 addition & 1 deletion server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ func (s *GrpcServer) RegionHeartbeat(stream pdpb.PD_RegionHeartbeatServer) error
continue
}
start := time.Now()
err = rc.HandleRegionHeartbeat(region)
err = rc.HandleRegionHeartbeat(&region)
if err != nil {
regionHeartbeatCounter.WithLabelValues(storeAddress, storeLabel, "report", "err").Inc()
msg := err.Error()
Expand Down

0 comments on commit b9b2971

Please sign in to comment.