conf.go 450 B

1234567891011121314151617181920212223242526
  1. package flowmonitor
  2. import (
  3. "time"
  4. "errors"
  5. xtime "go-common/library/time"
  6. )
  7. type Config struct {
  8. Interval xtime.Duration
  9. Addr string
  10. }
  11. func (fm *FlowMonitor) checkConfig() (err error) {
  12. if fm.conf == nil {
  13. return errors.New("config for flowmonitor is nil")
  14. }
  15. if fm.conf.Interval == 0 {
  16. fm.conf.Interval = xtime.Duration(time.Second * 5)
  17. }
  18. if fm.conf.Addr == "" {
  19. return errors.New("addr of flowmonitor is nil")
  20. }
  21. return
  22. }