rcvr.go 613 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package impl
  4. import (
  5. "context"
  6. "adm-data/impl/v1/query"
  7. "adm-data/pb"
  8. v1 "adm-data/pb/v1"
  9. "git.getensh.com/common/gopkgsv2/tasker/rpctasker"
  10. "google.golang.org/grpc"
  11. )
  12. // 具体实现
  13. type Rcvr struct{}
  14. func Register(s *grpc.Server) {
  15. pb.RegisterDataServer(s, &Rcvr{})
  16. }
  17. func (c *Rcvr) Query(ctx context.Context, req *v1.QueryRequest) (reply *v1.QueryResponse, err error) {
  18. t1 := func() error {
  19. reply, err = query.Query(ctx, req)
  20. return err
  21. }
  22. return reply, rpctasker.Exec(ctx, t1)
  23. }