options.go 452 B

12345678910111213141516171819202122232425262728
  1. package mongo
  2. import (
  3. "time"
  4. "github.com/tal-tech/go-zero/core/syncx"
  5. )
  6. var slowThreshold = syncx.ForAtomicDuration(defaultSlowThreshold)
  7. type (
  8. options struct {
  9. timeout time.Duration
  10. }
  11. // Option defines the method to customize a mongo model.
  12. Option func(opts *options)
  13. )
  14. func SetSlowThreshold(threshold time.Duration) {
  15. slowThreshold.Set(threshold)
  16. }
  17. func defaultOptions() *options {
  18. return &options{
  19. timeout: defaultTimeout,
  20. }
  21. }