server.go 967 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package grpc
  2. import (
  3. "context"
  4. v1 "go-common/app/interface/main/app-resource/api/v1"
  5. "go-common/app/interface/main/app-resource/http"
  6. modulesvr "go-common/app/interface/main/app-resource/service/module"
  7. "go-common/library/log"
  8. "go-common/library/net/rpc/warden"
  9. )
  10. // Server struct
  11. type Server struct {
  12. moduleSvc *modulesvr.Service
  13. }
  14. // New Coin warden rpc server
  15. func New(c *warden.ServerConfig, svr *http.Server) (wsvr *warden.Server, err error) {
  16. wsvr = warden.NewServer(c)
  17. v1.RegisterAppResourceServer(wsvr.Server(), &Server{
  18. moduleSvc: svr.ModuleSvc,
  19. })
  20. wsvr, err = wsvr.Start()
  21. return
  22. }
  23. // ModuleUpdateCache update module cache
  24. func (s *Server) ModuleUpdateCache(c context.Context, noArg *v1.NoArgRequest) (noReply *v1.NoReply, err error) {
  25. if err = s.moduleSvc.ModuleUpdateCache(); err != nil {
  26. log.Error("ModuleUpdateCache error(%v)", err)
  27. return
  28. }
  29. noReply = &v1.NoReply{}
  30. log.Info("ModuleUpdateCache load cache success")
  31. return
  32. }