rcvr.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2019 autocareai.com. All rights reserved.
  2. // Use of this source code is governed by autocareai.com.
  3. package impl
  4. import (
  5. "context"
  6. "gadm-task/pb"
  7. pb_v1 "gadm-task/pb/v1"
  8. "gadm-task/impl/v1/check"
  9. "gadm-task/impl/v1/task"
  10. "gitlab.sydip.com/repo/gopkgs/tasker/rpctasker"
  11. "google.golang.org/grpc"
  12. )
  13. // 具体实现
  14. type Rcvr struct{}
  15. func Register(s *grpc.Server) {
  16. pb.RegisterAdmTaskServer(s, &Rcvr{})
  17. }
  18. func (c *Rcvr) GetTaskBySourceCode(ctx context.Context, req *pb_v1.GetTaskBySourceCodeRequest) (reply *pb_v1.GetTaskBySourceCodeReply, err error) {
  19. t1 := func() error {
  20. reply, err = task.GetTaskBySourceCode(ctx, req)
  21. return err
  22. }
  23. return reply, rpctasker.Exec(ctx, t1)
  24. }
  25. func (c *Rcvr) UpdateOfflineTask(ctx context.Context, req *pb_v1.UpdateOfflineTaskRequest) (reply *pb_v1.UpdateOfflineTaskReply, err error) {
  26. t1 := func() error {
  27. reply, err = task.UpdateOfflineTask(ctx, req)
  28. return err
  29. }
  30. return reply, rpctasker.Exec(ctx, t1)
  31. }
  32. func (c *Rcvr) CheckFormat(ctx context.Context, req *pb_v1.CheckFormatRequest) (reply *pb_v1.CheckFormatReply, err error) {
  33. t1 := func() error {
  34. reply, err = check.CheckFormat(ctx, req)
  35. return err
  36. }
  37. return reply, rpctasker.Exec(ctx, t1)
  38. }
  39. func (c *Rcvr) FieldCheck(ctx context.Context, req *pb_v1.FieldCheckRequest) (reply *pb_v1.FieldCheckReply, err error) {
  40. t1 := func() error {
  41. reply, err = check.FieldCheck(ctx, req)
  42. return err
  43. }
  44. return reply, rpctasker.Exec(ctx, t1)
  45. }