rcvr.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. "property-mqtt/impl/v1/face"
  7. "property-mqtt/pb"
  8. pb_v1 "property-mqtt/pb/v1"
  9. "git.getensh.com/common/gopkgs/tasker/rpctasker"
  10. "google.golang.org/grpc"
  11. )
  12. // 具体实现
  13. type Rcvr struct {
  14. }
  15. func Register(s *grpc.Server) {
  16. pb.RegisterMqttServer(s, &Rcvr{})
  17. }
  18. //
  19. func (c *Rcvr) FaceWhiteAdd(ctx context.Context, req *pb_v1.FaceWhiteAddRequest) (reply *pb_v1.FaceWhiteAddReply, err error) {
  20. t1 := func() error {
  21. reply, err = face.FaceWhiteAdd(ctx, req)
  22. return err
  23. }
  24. return reply, rpctasker.Exec(ctx, t1)
  25. }
  26. func (c *Rcvr) FaceWhiteDel(ctx context.Context, req *pb_v1.FaceWhiteDelRequest) (reply *pb_v1.FaceWhiteDelReply, err error) {
  27. t1 := func() error {
  28. reply, err = face.FaceWhiteDel(ctx, req)
  29. return err
  30. }
  31. return reply, rpctasker.Exec(ctx, t1)
  32. }
  33. func (c *Rcvr) FaceOpen(ctx context.Context, req *pb_v1.FaceOpenRequest) (reply *pb_v1.FaceOpenReply, err error) {
  34. t1 := func() error {
  35. reply, err = face.FaceOpen(ctx, req)
  36. return err
  37. }
  38. return reply, rpctasker.Exec(ctx, t1)
  39. }
  40. func (c *Rcvr) FaceReboot(ctx context.Context, req *pb_v1.FaceRebootRequest) (reply *pb_v1.FaceRebootReply, err error) {
  41. t1 := func() error {
  42. reply, err = face.FaceReboot(ctx, req)
  43. return err
  44. }
  45. return reply, rpctasker.Exec(ctx, t1)
  46. }
  47. func (c *Rcvr) NewMqttDevice(ctx context.Context, req *pb_v1.NewMqttDeviceRequest) (reply *pb_v1.NewMqttDeviceReply, err error) {
  48. t1 := func() error {
  49. reply, err = face.NewMqttDevice(ctx, req)
  50. return err
  51. }
  52. return reply, rpctasker.Exec(ctx, t1)
  53. }