feat: slow threshold customizable in mongo (#1186)

This commit is contained in:
Kevin Wan
2021-11-01 07:12:53 +08:00
committed by GitHub
parent 429f85a9de
commit 8be0f77d96
6 changed files with 68 additions and 23 deletions

View File

@@ -0,0 +1,28 @@
package mongo
import (
"time"
"github.com/tal-tech/go-zero/core/syncx"
)
var slowThreshold = syncx.ForAtomicDuration(defaultSlowThreshold)
type (
options struct {
timeout time.Duration
}
// Option defines the method to customize a mongo model.
Option func(opts *options)
)
func SetSlowThreshold(threshold time.Duration) {
slowThreshold.Set(threshold)
}
func defaultOptions() *options {
return &options{
timeout: defaultTimeout,
}
}