Skip to content

Commit

Permalink
Clean up linting warnings (#4290)
Browse files Browse the repository at this point in the history
* Clean up linting warnings
  • Loading branch information
yux0 authored Jul 7, 2021
1 parent deed482 commit 24cd8fa
Show file tree
Hide file tree
Showing 46 changed files with 4,720 additions and 4,774 deletions.
12 changes: 0 additions & 12 deletions client/matching/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,3 @@ func (c *clientImpl) getClientForTaskList(key string) (Client, error) {
}
return client.(Client), nil
}

func (c *clientImpl) getTaskListsByDomain(
cl Client,
ctx context.Context,
request *types.GetTaskListsByDomainRequest,
opts ...yarpc.CallOption,
) (*types.GetTaskListsByDomainResponse, error) {
ctx, cancel := c.createContext(ctx)
defer cancel()

return cl.GetTaskListsByDomain(ctx, request, opts...)
}
4 changes: 3 additions & 1 deletion common/metrics/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ package metrics

import "context"

const contextTagsKey = "metrics.Tags"
type contextTag string

const contextTagsKey = contextTag("metrics.Tags")

func TagContext(ctx context.Context, tag Tag) context.Context {
tags, ok := ctx.Value(contextTagsKey).([]Tag)
Expand Down
2 changes: 1 addition & 1 deletion common/persistence/nosql/nosqlTaskStore.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (t *nosqlTaskStore) LeaseTaskList(
}

// Update the rangeID as this is an ownership change
currTL.RangeID += 1
currTL.RangeID++

err = t.db.UpdateTaskList(ctx, &nosqlplugin.TaskListRow{
DomainID: request.DomainID,
Expand Down
22 changes: 6 additions & 16 deletions common/persistence/sql/sqlExecutionStoreUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,15 @@ func applyWorkflowMutationTx(
}
}

if err := updateBufferedEvents(
return updateBufferedEvents(
ctx,
tx,
workflowMutation.NewBufferedEvents,
shardID,
domainID,
workflowID,
runID,
); err != nil {
return err
}
return nil
)
}

func applyWorkflowSnapshotTxAsReset(
Expand Down Expand Up @@ -395,16 +392,13 @@ func applyWorkflowSnapshotTxAsReset(
return err
}

if err := deleteBufferedEvents(
return deleteBufferedEvents(
ctx,
tx,
shardID,
domainID,
workflowID,
runID); err != nil {
return err
}
return nil
runID)
}

func (m *sqlExecutionStore) applyWorkflowSnapshotTxAsNew(
Expand Down Expand Up @@ -516,19 +510,15 @@ func (m *sqlExecutionStore) applyWorkflowSnapshotTxAsNew(
return err
}

if err := updateSignalsRequested(
return updateSignalsRequested(
ctx,
tx,
workflowSnapshot.SignalRequestedIDs,
nil,
shardID,
domainID,
workflowID,
runID); err != nil {
return err
}

return nil
runID)
}

func applyTasks(
Expand Down
6 changes: 3 additions & 3 deletions common/persistence/sql/sqlplugin/postgres/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ func (pdb *db) IsDupEntryError(err error) bool {
return ok && sqlErr.Code == ErrDupEntry
}

func (mdb *db) IsNotFoundError(err error) bool {
func (pdb *db) IsNotFoundError(err error) bool {
if err == sql.ErrNoRows {
return true
}
return false
}

func (mdb *db) IsTimeoutError(err error) bool {
func (pdb *db) IsTimeoutError(err error) bool {
if err == context.DeadlineExceeded {
return true
}
return false
}

func (mdb *db) IsThrottlingError(err error) bool {
func (pdb *db) IsThrottlingError(err error) bool {
sqlErr, ok := err.(*pq.Error)
if ok {
if sqlErr.Code == ErrTooManyConnections ||
Expand Down
5 changes: 2 additions & 3 deletions common/persistence/visibilitySamplingClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,9 @@ func (p *visibilitySamplingClient) tryConsumeListToken(domain string) error {
if ok {
p.logger.Debug("List API request consumed QPS token", tag.WorkflowDomainName(domain), tag.Name(callerFuncName(2)))
return nil
} else {
p.logger.Debug("List API request is being sampled", tag.WorkflowDomainName(domain), tag.Name(callerFuncName(2)))
return errPersistenceLimitExceededForList
}
p.logger.Debug("List API request is being sampled", tag.WorkflowDomainName(domain), tag.Name(callerFuncName(2)))
return errPersistenceLimitExceededForList
}

func callerFuncName(skip int) string {
Expand Down
10 changes: 10 additions & 0 deletions common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,3 +900,13 @@ func MicrosecondsToDuration(d int64) time.Duration {
func NanosecondsToDuration(d int64) time.Duration {
return time.Duration(d) * time.Nanosecond
}

// SleepWithMinDuration sleeps for the minimum of desired and available duration
// returns the remaining available time duration
func SleepWithMinDuration(desired time.Duration, available time.Duration) time.Duration {
d := MinDuration(desired, available)
if d > 0 {
time.Sleep(d)
}
return available - d
}
2 changes: 1 addition & 1 deletion host/activityTest.go → host/activity_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016 Uber Technologies, Inc.
// Copyright (c) 2021 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion host/archivalTest.go → host/archival_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016 Uber Technologies, Inc.
// Copyright (c) 2021 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016 Uber Technologies, Inc.
// Copyright (c) 2021 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 24cd8fa

Please sign in to comment.