options.go 498 B

1234567891011121314151617181920212223242526272829
  1. package mongo
  2. import (
  3. "time"
  4. "github.com/zeromicro/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. // SetSlowThreshold sets the slow threshold.
  15. func SetSlowThreshold(threshold time.Duration) {
  16. slowThreshold.Set(threshold)
  17. }
  18. func defaultOptions() *options {
  19. return &options{
  20. timeout: defaultTimeout,
  21. }
  22. }