rcvr.go 867 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package impl
  4. import (
  5. "google.golang.org/grpc"
  6. "smart-log/pb"
  7. "context"
  8. "smart-log/pb/v1"
  9. "smart-log/impl/v1/operation_log"
  10. "github.com/jaryhe/gopkgs/tasker/rpctasker"
  11. )
  12. // 具体实现
  13. type Rcvr struct {
  14. }
  15. func Register(s *grpc.Server) {
  16. pb.RegisterSmartSiteLogServer(s, &Rcvr{})
  17. }
  18. func (c *Rcvr) LogAdd(ctx context.Context, req *v1.LogAddRequest) (reply *v1.LogAddReply, err error) {
  19. t1 := func() error {
  20. reply, err = operation_log.LogAdd(ctx, req)
  21. return err
  22. }
  23. return reply, rpctasker.Exec(ctx, t1)
  24. }
  25. func (c *Rcvr) LogList(ctx context.Context, req *v1.LogListRequest) (reply *v1.LogListReply, err error) {
  26. t1 := func() error {
  27. reply, err = operation_log.LogList(ctx, req)
  28. return err
  29. }
  30. return reply, rpctasker.Exec(ctx, t1)
  31. }