examples.go 731 B

123456789101112131415161718192021222324252627282930313233
  1. package jobs
  2. import (
  3. "IotAdmin/core/logger"
  4. "time"
  5. )
  6. // ExamplesOne
  7. // 新添加的job 必须按照以下格式定义,并实现Exec函数
  8. type ExamplesOne struct {
  9. }
  10. func (t *ExamplesOne) Exec(arg interface{}) error {
  11. logger.Info(time.Now().Format(timeFormat) + " [INFO] JobCore ExamplesOne exec START")
  12. // TODO: 这里需要注意 Examples 传入参数是 string 所以 arg.(string);请根据对应的类型进行转化;
  13. switch arg.(type) {
  14. case string:
  15. if arg.(string) != "" {
  16. } else {
  17. logger.Errorf(time.Now().Format(timeFormat) + " [ERROR] JobCore ExamplesOne exec error: arg is empty")
  18. }
  19. break
  20. case int:
  21. break
  22. }
  23. return nil
  24. }
  25. func (t *ExamplesOne) GetName() string {
  26. return "函数测试"
  27. }