dao.go 707 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package http
  2. import (
  3. "context"
  4. "go-common/app/admin/main/aegis/conf"
  5. "go-common/library/database/elastic"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. // Dao dao
  9. type Dao struct {
  10. c *conf.Config
  11. clientR, clientW *bm.Client
  12. es *elastic.Elastic
  13. }
  14. // New init mysql db
  15. func New(c *conf.Config) (dao *Dao) {
  16. dao = &Dao{
  17. c: c,
  18. clientR: bm.NewClient(c.HTTPClient.Read),
  19. clientW: bm.NewClient(c.HTTPClient.Write),
  20. es: elastic.NewElastic(&elastic.Config{
  21. Host: c.Host.Manager,
  22. HTTPClient: c.HTTPClient.Es,
  23. }),
  24. }
  25. return
  26. }
  27. // Close close the resource.
  28. func (d *Dao) Close() {
  29. }
  30. // Ping dao ping
  31. func (d *Dao) Ping(c context.Context) error {
  32. return nil
  33. }