service.go 906 B

123456789101112131415161718192021222324252627282930313233343536
  1. package grpc
  2. import (
  3. "context"
  4. "go-common/app/service/main/identify-game/api/grpc/v1"
  5. "go-common/app/service/main/identify-game/service"
  6. "go-common/library/net/rpc/warden"
  7. )
  8. // New identify game warden rpc server
  9. func New(cfg *warden.ServerConfig, s *service.Service) *warden.Server {
  10. w := warden.NewServer(cfg)
  11. v1.RegisterIdentifyGameServer(w.Server(), &server{s})
  12. ws, err := w.Start()
  13. if err != nil {
  14. panic(err)
  15. }
  16. return ws
  17. }
  18. type server struct {
  19. svr *service.Service
  20. }
  21. var _ v1.IdentifyGameServer = &server{}
  22. func (s *server) DelCache(ctx context.Context, req *v1.DelCacheReq) (*v1.DelCacheReply, error) {
  23. err := s.svr.DelCache(ctx, req.Token)
  24. return &v1.DelCacheReply{}, err
  25. }
  26. func (s *server) GetCookieByToken(ctx context.Context, req *v1.CreateCookieReq) (*v1.CreateCookieReply, error) {
  27. cookies, err := s.svr.GetCookieByToken(ctx, req.Token, req.From)
  28. return cookies, err
  29. }