service.go 604 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/admin/main/bfs/conf"
  5. "go-common/app/admin/main/bfs/dao"
  6. )
  7. // Service struct
  8. type Service struct {
  9. c *conf.Config
  10. d *dao.Dao
  11. }
  12. // New init
  13. func New(c *conf.Config) (s *Service) {
  14. s = &Service{
  15. c: c,
  16. d: dao.New(c),
  17. }
  18. return s
  19. }
  20. // Clusters .
  21. func (s *Service) Clusters(c context.Context) (clusters []string) {
  22. for name := range s.c.Zookeepers {
  23. clusters = append(clusters, name)
  24. }
  25. return
  26. }
  27. // Ping .
  28. func (s *Service) Ping(c context.Context) (err error) {
  29. return s.d.Ping(c)
  30. }
  31. // Close .
  32. func (s *Service) Close() {
  33. s.d.Close()
  34. }