Skip to content

Commit c5254f3

Browse files
Address a few linter errors (#3780)
* Remove unreachable code * Rename variables and identifiers that shadow import names
1 parent bb4ec7f commit c5254f3

9 files changed

+30
-34
lines changed

common/namespace/handler.go

-2
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,4 @@ func validateStateUpdate(existingNamespace *persistence.GetNamespaceResponse, ns
954954
default:
955955
return ErrInvalidNamespaceStateUpdate
956956
}
957-
958-
return nil
959957
}

host/query_workflow_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ func (s *clientIntegrationSuite) TestQueryWorkflow_Consistent_PiggybackQuery() {
105105
}).Get(ctx, nil)
106106
}
107107
}
108-
109-
return receivedMsgs, nil
110108
}
111109

112110
s.worker.RegisterWorkflow(workflowFn)

service/history/queues/convert_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (s *convertSuite) TestConvertPredicate_Empty() {
6565
}
6666

6767
func (s *convertSuite) TestConvertPredicate_And() {
68-
predicates := []tasks.Predicate{
68+
testCases := []tasks.Predicate{
6969
predicates.And(
7070
predicates.Universal[tasks.Task](),
7171
predicates.Empty[tasks.Task](),
@@ -102,13 +102,13 @@ func (s *convertSuite) TestConvertPredicate_And() {
102102
),
103103
}
104104

105-
for _, predicate := range predicates {
105+
for _, predicate := range testCases {
106106
s.Equal(predicate, FromPersistencePredicate(ToPersistencePredicate(predicate)))
107107
}
108108
}
109109

110110
func (s *convertSuite) TestConvertPredicate_Or() {
111-
predicates := []tasks.Predicate{
111+
testCases := []tasks.Predicate{
112112
predicates.Or(
113113
predicates.Universal[tasks.Task](),
114114
predicates.Empty[tasks.Task](),
@@ -145,13 +145,13 @@ func (s *convertSuite) TestConvertPredicate_Or() {
145145
),
146146
}
147147

148-
for _, predicate := range predicates {
148+
for _, predicate := range testCases {
149149
s.Equal(predicate, FromPersistencePredicate(ToPersistencePredicate(predicate)))
150150
}
151151
}
152152

153153
func (s *convertSuite) TestConvertPredicate_Not() {
154-
predicates := []tasks.Predicate{
154+
testCases := []tasks.Predicate{
155155
predicates.Not(predicates.Universal[tasks.Task]()),
156156
predicates.Not(predicates.Empty[tasks.Task]()),
157157
predicates.Not(predicates.And[tasks.Task](
@@ -169,25 +169,25 @@ func (s *convertSuite) TestConvertPredicate_Not() {
169169
})),
170170
}
171171

172-
for _, predicate := range predicates {
172+
for _, predicate := range testCases {
173173
s.Equal(predicate, FromPersistencePredicate(ToPersistencePredicate(predicate)))
174174
}
175175
}
176176

177177
func (s *convertSuite) TestConvertPredicate_NamespaceID() {
178-
predicates := []tasks.Predicate{
178+
testCases := []tasks.Predicate{
179179
tasks.NewNamespacePredicate(nil),
180180
tasks.NewNamespacePredicate([]string{}),
181181
tasks.NewNamespacePredicate([]string{uuid.New(), uuid.New(), uuid.New()}),
182182
}
183183

184-
for _, predicate := range predicates {
184+
for _, predicate := range testCases {
185185
s.Equal(predicate, FromPersistencePredicate(ToPersistencePredicate(predicate)))
186186
}
187187
}
188188

189189
func (s *convertSuite) TestConvertPredicate_TaskType() {
190-
predicates := []tasks.Predicate{
190+
testCases := []tasks.Predicate{
191191
tasks.NewTypePredicate(nil),
192192
tasks.NewTypePredicate([]enumsspb.TaskType{}),
193193
tasks.NewTypePredicate([]enumsspb.TaskType{
@@ -197,7 +197,7 @@ func (s *convertSuite) TestConvertPredicate_TaskType() {
197197
}),
198198
}
199199

200-
for _, predicate := range predicates {
200+
for _, predicate := range testCases {
201201
s.Equal(predicate, FromPersistencePredicate(ToPersistencePredicate(predicate)))
202202
}
203203
}

service/history/queues/executable.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ func (e *executableImpl) Execute() (retErr error) {
172172
return nil
173173
}
174174

175-
namespaceName, _ := e.namespaceRegistry.GetNamespaceName(namespace.ID(e.GetNamespaceID()))
175+
ns, _ := e.namespaceRegistry.GetNamespaceName(namespace.ID(e.GetNamespaceID()))
176176
ctx := headers.SetCallerInfo(
177177
metrics.AddMetricsContext(context.Background()),
178-
headers.NewBackgroundCallerInfo(namespaceName.String()),
178+
headers.NewBackgroundCallerInfo(ns.String()),
179179
)
180180

181181
var panicErr error
@@ -476,15 +476,15 @@ func (e *executableImpl) rescheduleTime(
476476
return e.timeSource.Now().Add(dependencyTaskNotCompletedReschedulePolicy.ComputeNextDelay(0, attempt))
477477
}
478478

479-
backoff := reschedulePolicy.ComputeNextDelay(0, attempt)
479+
backoffDuration := reschedulePolicy.ComputeNextDelay(0, attempt)
480480
if common.IsResourceExhausted(err) {
481481
// try a different reschedule policy to slow down retry
482482
// upon resource exhausted error and pick the longer backoff
483483
// duration
484-
backoff = util.Max(backoff, taskResourceExhuastedReschedulePolicy.ComputeNextDelay(0, e.resourceExhaustedCount))
484+
backoffDuration = util.Max(backoffDuration, taskResourceExhuastedReschedulePolicy.ComputeNextDelay(0, e.resourceExhaustedCount))
485485
}
486486

487-
return e.timeSource.Now().Add(backoff)
487+
return e.timeSource.Now().Add(backoffDuration)
488488
}
489489

490490
func (e *executableImpl) updatePriority() {

service/history/queues/queue_base.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import (
4141
"go.temporal.io/server/common/persistence"
4242
"go.temporal.io/server/common/predicates"
4343
"go.temporal.io/server/common/quotas"
44-
"go.temporal.io/server/service/history/shard"
44+
hshard "go.temporal.io/server/service/history/shard"
4545
"go.temporal.io/server/service/history/tasks"
4646
)
4747

@@ -75,7 +75,7 @@ type (
7575
}
7676

7777
queueBase struct {
78-
shard shard.Context
78+
shard hshard.Context
7979

8080
status int32
8181
shutdownCh chan struct{}
@@ -120,7 +120,7 @@ type (
120120
)
121121

122122
func newQueueBase(
123-
shard shard.Context,
123+
shard hshard.Context,
124124
category tasks.Category,
125125
paginationFnProvider PaginationFnProvider,
126126
scheduler Scheduler,

service/history/queues/queue_immediate.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
"go.temporal.io/server/common/metrics"
3737
"go.temporal.io/server/common/persistence"
3838
"go.temporal.io/server/common/quotas"
39-
"go.temporal.io/server/service/history/shard"
39+
hshard "go.temporal.io/server/service/history/shard"
4040
"go.temporal.io/server/service/history/tasks"
4141
)
4242

@@ -51,7 +51,7 @@ type (
5151
)
5252

5353
func NewImmediateQueue(
54-
shard shard.Context,
54+
shard hshard.Context,
5555
category tasks.Category,
5656
scheduler Scheduler,
5757
rescheduler Rescheduler,

service/history/queues/queue_scheduled.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
"go.temporal.io/server/common/persistence"
4040
"go.temporal.io/server/common/quotas"
4141
"go.temporal.io/server/common/timer"
42-
"go.temporal.io/server/service/history/shard"
42+
hshard "go.temporal.io/server/service/history/shard"
4343
"go.temporal.io/server/service/history/tasks"
4444
)
4545

@@ -63,7 +63,7 @@ const (
6363
)
6464

6565
func NewScheduledQueue(
66-
shard shard.Context,
66+
shard hshard.Context,
6767
category tasks.Category,
6868
scheduler Scheduler,
6969
rescheduler Rescheduler,

service/history/queues/scheduler.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ func NewNamespacePriorityScheduler(
117117
namespaceWeights := options.ActiveNamespaceWeights
118118
namespaceName := namespace.EmptyName
119119

120-
namespace, err := namespaceRegistry.GetNamespaceByID(namespace.ID(key.NamespaceID))
120+
ns, err := namespaceRegistry.GetNamespaceByID(namespace.ID(key.NamespaceID))
121121
if err == nil {
122-
namespaceName = namespace.Name()
123-
if !namespace.ActiveInCluster(currentClusterName) {
122+
namespaceName = ns.Name()
123+
if !ns.ActiveInCluster(currentClusterName) {
124124
namespaceWeights = options.StandbyNamespaceWeights
125125
}
126126
} else {

service/history/shard/context_impl.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import (
4747
"go.temporal.io/server/common"
4848
"go.temporal.io/server/common/archiver"
4949
"go.temporal.io/server/common/backoff"
50-
"go.temporal.io/server/common/clock"
50+
cclock "go.temporal.io/server/common/clock"
5151
"go.temporal.io/server/common/cluster"
5252
"go.temporal.io/server/common/convert"
5353
"go.temporal.io/server/common/definition"
@@ -108,7 +108,7 @@ type (
108108
clientBean client.Bean
109109
historyClient historyservice.HistoryServiceClient
110110
payloadSerializer serialization.Serializer
111-
timeSource clock.TimeSource
111+
timeSource cclock.TimeSource
112112
namespaceRegistry namespace.Registry
113113
saProvider searchattribute.Provider
114114
saMapper searchattribute.Mapper
@@ -1281,7 +1281,7 @@ func (s *ContextImpl) updateShardInfoLocked() error {
12811281
}
12821282

12831283
var err error
1284-
now := clock.NewRealTimeSource().Now()
1284+
now := cclock.NewRealTimeSource().Now()
12851285
if s.lastUpdated.Add(s.config.ShardUpdateMinInterval()).After(now) {
12861286
return nil
12871287
}
@@ -2078,7 +2078,7 @@ func newContext(
20782078
historyClient historyservice.HistoryServiceClient,
20792079
metricsHandler metrics.Handler,
20802080
payloadSerializer serialization.Serializer,
2081-
timeSource clock.TimeSource,
2081+
timeSource cclock.TimeSource,
20822082
namespaceRegistry namespace.Registry,
20832083
saProvider searchattribute.Provider,
20842084
saMapper searchattribute.Mapper,
@@ -2180,7 +2180,7 @@ func (s *ContextImpl) GetMetricsHandler() metrics.Handler {
21802180
return s.metricsHandler
21812181
}
21822182

2183-
func (s *ContextImpl) GetTimeSource() clock.TimeSource {
2183+
func (s *ContextImpl) GetTimeSource() cclock.TimeSource {
21842184
return s.timeSource
21852185
}
21862186

0 commit comments

Comments
 (0)