Skip to content

Commit

Permalink
Address a few linter errors (#3780)
Browse files Browse the repository at this point in the history
* Remove unreachable code
* Rename variables and identifiers that shadow import names
  • Loading branch information
mindaugasrukas authored Jan 11, 2023
1 parent bb4ec7f commit c5254f3
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 34 deletions.
2 changes: 0 additions & 2 deletions common/namespace/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,4 @@ func validateStateUpdate(existingNamespace *persistence.GetNamespaceResponse, ns
default:
return ErrInvalidNamespaceStateUpdate
}

return nil
}
2 changes: 0 additions & 2 deletions host/query_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ func (s *clientIntegrationSuite) TestQueryWorkflow_Consistent_PiggybackQuery() {
}).Get(ctx, nil)
}
}

return receivedMsgs, nil
}

s.worker.RegisterWorkflow(workflowFn)
Expand Down
20 changes: 10 additions & 10 deletions service/history/queues/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (s *convertSuite) TestConvertPredicate_Empty() {
}

func (s *convertSuite) TestConvertPredicate_And() {
predicates := []tasks.Predicate{
testCases := []tasks.Predicate{
predicates.And(
predicates.Universal[tasks.Task](),
predicates.Empty[tasks.Task](),
Expand Down Expand Up @@ -102,13 +102,13 @@ func (s *convertSuite) TestConvertPredicate_And() {
),
}

for _, predicate := range predicates {
for _, predicate := range testCases {
s.Equal(predicate, FromPersistencePredicate(ToPersistencePredicate(predicate)))
}
}

func (s *convertSuite) TestConvertPredicate_Or() {
predicates := []tasks.Predicate{
testCases := []tasks.Predicate{
predicates.Or(
predicates.Universal[tasks.Task](),
predicates.Empty[tasks.Task](),
Expand Down Expand Up @@ -145,13 +145,13 @@ func (s *convertSuite) TestConvertPredicate_Or() {
),
}

for _, predicate := range predicates {
for _, predicate := range testCases {
s.Equal(predicate, FromPersistencePredicate(ToPersistencePredicate(predicate)))
}
}

func (s *convertSuite) TestConvertPredicate_Not() {
predicates := []tasks.Predicate{
testCases := []tasks.Predicate{
predicates.Not(predicates.Universal[tasks.Task]()),
predicates.Not(predicates.Empty[tasks.Task]()),
predicates.Not(predicates.And[tasks.Task](
Expand All @@ -169,25 +169,25 @@ func (s *convertSuite) TestConvertPredicate_Not() {
})),
}

for _, predicate := range predicates {
for _, predicate := range testCases {
s.Equal(predicate, FromPersistencePredicate(ToPersistencePredicate(predicate)))
}
}

func (s *convertSuite) TestConvertPredicate_NamespaceID() {
predicates := []tasks.Predicate{
testCases := []tasks.Predicate{
tasks.NewNamespacePredicate(nil),
tasks.NewNamespacePredicate([]string{}),
tasks.NewNamespacePredicate([]string{uuid.New(), uuid.New(), uuid.New()}),
}

for _, predicate := range predicates {
for _, predicate := range testCases {
s.Equal(predicate, FromPersistencePredicate(ToPersistencePredicate(predicate)))
}
}

func (s *convertSuite) TestConvertPredicate_TaskType() {
predicates := []tasks.Predicate{
testCases := []tasks.Predicate{
tasks.NewTypePredicate(nil),
tasks.NewTypePredicate([]enumsspb.TaskType{}),
tasks.NewTypePredicate([]enumsspb.TaskType{
Expand All @@ -197,7 +197,7 @@ func (s *convertSuite) TestConvertPredicate_TaskType() {
}),
}

for _, predicate := range predicates {
for _, predicate := range testCases {
s.Equal(predicate, FromPersistencePredicate(ToPersistencePredicate(predicate)))
}
}
Expand Down
10 changes: 5 additions & 5 deletions service/history/queues/executable.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ func (e *executableImpl) Execute() (retErr error) {
return nil
}

namespaceName, _ := e.namespaceRegistry.GetNamespaceName(namespace.ID(e.GetNamespaceID()))
ns, _ := e.namespaceRegistry.GetNamespaceName(namespace.ID(e.GetNamespaceID()))
ctx := headers.SetCallerInfo(
metrics.AddMetricsContext(context.Background()),
headers.NewBackgroundCallerInfo(namespaceName.String()),
headers.NewBackgroundCallerInfo(ns.String()),
)

var panicErr error
Expand Down Expand Up @@ -476,15 +476,15 @@ func (e *executableImpl) rescheduleTime(
return e.timeSource.Now().Add(dependencyTaskNotCompletedReschedulePolicy.ComputeNextDelay(0, attempt))
}

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

return e.timeSource.Now().Add(backoff)
return e.timeSource.Now().Add(backoffDuration)
}

func (e *executableImpl) updatePriority() {
Expand Down
6 changes: 3 additions & 3 deletions service/history/queues/queue_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/predicates"
"go.temporal.io/server/common/quotas"
"go.temporal.io/server/service/history/shard"
hshard "go.temporal.io/server/service/history/shard"
"go.temporal.io/server/service/history/tasks"
)

Expand Down Expand Up @@ -75,7 +75,7 @@ type (
}

queueBase struct {
shard shard.Context
shard hshard.Context

status int32
shutdownCh chan struct{}
Expand Down Expand Up @@ -120,7 +120,7 @@ type (
)

func newQueueBase(
shard shard.Context,
shard hshard.Context,
category tasks.Category,
paginationFnProvider PaginationFnProvider,
scheduler Scheduler,
Expand Down
4 changes: 2 additions & 2 deletions service/history/queues/queue_immediate.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/quotas"
"go.temporal.io/server/service/history/shard"
hshard "go.temporal.io/server/service/history/shard"
"go.temporal.io/server/service/history/tasks"
)

Expand All @@ -51,7 +51,7 @@ type (
)

func NewImmediateQueue(
shard shard.Context,
shard hshard.Context,
category tasks.Category,
scheduler Scheduler,
rescheduler Rescheduler,
Expand Down
4 changes: 2 additions & 2 deletions service/history/queues/queue_scheduled.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/quotas"
"go.temporal.io/server/common/timer"
"go.temporal.io/server/service/history/shard"
hshard "go.temporal.io/server/service/history/shard"
"go.temporal.io/server/service/history/tasks"
)

Expand All @@ -63,7 +63,7 @@ const (
)

func NewScheduledQueue(
shard shard.Context,
shard hshard.Context,
category tasks.Category,
scheduler Scheduler,
rescheduler Rescheduler,
Expand Down
6 changes: 3 additions & 3 deletions service/history/queues/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ func NewNamespacePriorityScheduler(
namespaceWeights := options.ActiveNamespaceWeights
namespaceName := namespace.EmptyName

namespace, err := namespaceRegistry.GetNamespaceByID(namespace.ID(key.NamespaceID))
ns, err := namespaceRegistry.GetNamespaceByID(namespace.ID(key.NamespaceID))
if err == nil {
namespaceName = namespace.Name()
if !namespace.ActiveInCluster(currentClusterName) {
namespaceName = ns.Name()
if !ns.ActiveInCluster(currentClusterName) {
namespaceWeights = options.StandbyNamespaceWeights
}
} else {
Expand Down
10 changes: 5 additions & 5 deletions service/history/shard/context_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (
"go.temporal.io/server/common"
"go.temporal.io/server/common/archiver"
"go.temporal.io/server/common/backoff"
"go.temporal.io/server/common/clock"
cclock "go.temporal.io/server/common/clock"
"go.temporal.io/server/common/cluster"
"go.temporal.io/server/common/convert"
"go.temporal.io/server/common/definition"
Expand Down Expand Up @@ -108,7 +108,7 @@ type (
clientBean client.Bean
historyClient historyservice.HistoryServiceClient
payloadSerializer serialization.Serializer
timeSource clock.TimeSource
timeSource cclock.TimeSource
namespaceRegistry namespace.Registry
saProvider searchattribute.Provider
saMapper searchattribute.Mapper
Expand Down Expand Up @@ -1281,7 +1281,7 @@ func (s *ContextImpl) updateShardInfoLocked() error {
}

var err error
now := clock.NewRealTimeSource().Now()
now := cclock.NewRealTimeSource().Now()
if s.lastUpdated.Add(s.config.ShardUpdateMinInterval()).After(now) {
return nil
}
Expand Down Expand Up @@ -2078,7 +2078,7 @@ func newContext(
historyClient historyservice.HistoryServiceClient,
metricsHandler metrics.Handler,
payloadSerializer serialization.Serializer,
timeSource clock.TimeSource,
timeSource cclock.TimeSource,
namespaceRegistry namespace.Registry,
saProvider searchattribute.Provider,
saMapper searchattribute.Mapper,
Expand Down Expand Up @@ -2180,7 +2180,7 @@ func (s *ContextImpl) GetMetricsHandler() metrics.Handler {
return s.metricsHandler
}

func (s *ContextImpl) GetTimeSource() clock.TimeSource {
func (s *ContextImpl) GetTimeSource() cclock.TimeSource {
return s.timeSource
}

Expand Down

0 comments on commit c5254f3

Please sign in to comment.