Skip to content

Commit

Permalink
reduce transaction_timeout and returned random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
almostinf committed Nov 21, 2023
1 parent fe9f6ac commit 3fe8f0d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/notifier/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func getDefault() config {
},
Notification: cmd.NotificationConfig{
DelayedTime: "1m",
TransactionTimeout: "200ms",
TransactionTimeout: "100ms",
TransactionMaxRetries: 10,
TransactionHeuristicLimit: 10000,
},
Expand Down
4 changes: 2 additions & 2 deletions database/redis/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func NewTestDatabase(logger moira.Logger) *DbConnector {
},
NotificationConfig{
DelayedTime: time.Minute,
TransactionTimeout: 200 * time.Millisecond,
TransactionTimeout: 100 * time.Millisecond,
TransactionMaxRetries: 10,
TransactionHeuristicLimit: 10000,
},
Expand All @@ -114,7 +114,7 @@ func NewTestDatabaseWithIncorrectConfig(logger moira.Logger) *DbConnector {
},
NotificationConfig{
DelayedTime: time.Minute,
TransactionTimeout: 200 * time.Millisecond,
TransactionTimeout: 100 * time.Millisecond,
TransactionMaxRetries: 10,
TransactionHeuristicLimit: 10000,
},
Expand Down
2 changes: 1 addition & 1 deletion database/redis/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (connector *DbConnector) SaveMetrics(metrics map[string]*moira.MatchedMetri
c := *connector.client
ctx := connector.context

rand.New(rand.NewSource(time.Now().Unix()))
rand.Seed(time.Now().UnixNano())

Check failure on line 108 in database/redis/metric.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: Programs that call Seed and then expect a specific sequence of results from the global random source (using functions such as Int) can be broken when a dependency changes how much it consumes from the global random source. To avoid such breakages, programs that need a specific result sequence should use NewRand(NewSource(seed)) to obtain a random generator that other packages cannot access. (staticcheck)
pipe := c.TxPipeline()

for _, metric := range metrics {
Expand Down
2 changes: 1 addition & 1 deletion local/notifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ notification_history:
query_limit: 10000
notification:
delayed_time: 1m
transaction_timeout: 200ms
transaction_timeout: 100ms
transaction_max_retries: 10
transaction_heuristic_limit: 10000
log:
Expand Down

0 comments on commit 3fe8f0d

Please sign in to comment.