service.go 837 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/interface/main/web-feed/conf"
  5. "go-common/app/interface/main/web-feed/dao"
  6. accrpc "go-common/app/service/main/account/rpc/client"
  7. feedrpc "go-common/app/service/main/feed/rpc/client"
  8. "go-common/library/cache"
  9. )
  10. // Service service struct info
  11. type Service struct {
  12. c *conf.Config
  13. dao *dao.Dao
  14. feedRPC *feedrpc.Service
  15. accRPC *accrpc.Service3
  16. cache *cache.Cache
  17. }
  18. // New .
  19. func New(c *conf.Config) (s *Service) {
  20. s = &Service{
  21. c: c,
  22. dao: dao.New(c),
  23. feedRPC: feedrpc.New(c.FeedRPC),
  24. accRPC: accrpc.New3(c.AccountRPC),
  25. cache: cache.New(1, 1024),
  26. }
  27. return s
  28. }
  29. // Close closes dao.
  30. func (s *Service) Close() {
  31. s.dao.Close()
  32. }
  33. // Ping is check server ping.
  34. func (s *Service) Ping(c context.Context) (err error) {
  35. return s.dao.Ping(c)
  36. }