task.go 644 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package services
  2. import (
  3. "eta_gn/eta_api/services/data"
  4. "eta_gn/eta_api/utils"
  5. "fmt"
  6. "strings"
  7. )
  8. func Task() {
  9. fmt.Println("task start")
  10. go ImportManualDataRefresh()
  11. go data.HandleEdbRefreshQueue()
  12. go DealReplaceEdbCache()
  13. fmt.Println("task end")
  14. }
  15. func ImportManualDataRefresh() {
  16. defer func() {
  17. if err := recover(); err != nil {
  18. fmt.Println("[ImportManualDataRefresh]", err)
  19. }
  20. }()
  21. for {
  22. utils.Rc.Brpop(utils.CACHE_IMPORT_MANUAL_DATA, func(b []byte) {
  23. edbCode := string(b)
  24. edbCode = strings.TrimPrefix(edbCode, `"`)
  25. edbCode = strings.TrimSuffix(edbCode, `"`)
  26. data.RefreshManualData(edbCode)
  27. })
  28. }
  29. }