dao.go 821 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/job/main/sms/conf"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/library/stat/prom"
  7. )
  8. // Dao struct info of Dao.
  9. type Dao struct {
  10. c *conf.Config
  11. httpClient *bm.Client
  12. }
  13. var (
  14. errorsCount = prom.BusinessErrCount
  15. infosCount = prom.BusinessInfoCount
  16. )
  17. // New new a Dao and return.
  18. func New(c *conf.Config) (d *Dao) {
  19. d = &Dao{
  20. c: c,
  21. httpClient: bm.NewClient(c.HTTPClient),
  22. }
  23. return
  24. }
  25. // PromError prometheus error count.
  26. func PromError(name string) {
  27. errorsCount.Incr(name)
  28. }
  29. // PromInfo prometheus info count.
  30. func PromInfo(name string) {
  31. infosCount.Incr(name)
  32. }
  33. // Close close connections of mc, redis, db.
  34. func (d *Dao) Close() {}
  35. // Ping ping health of db.
  36. func (d *Dao) Ping(c context.Context) (err error) {
  37. return
  38. }