(stream grpc.ClientStreamingServer[common.User, common.Empty])
| 15 | ) |
| 16 | |
| 17 | func (s *Service) SyncUser(stream grpc.ClientStreamingServer[common.User, common.Empty]) error { |
| 18 | for { |
| 19 | user, err := stream.Recv() |
| 20 | if err != nil { |
| 21 | return stream.SendAndClose(&common.Empty{}) |
| 22 | } |
| 23 | |
| 24 | if user.GetEmail() == "" { |
| 25 | return errors.New("email is required") |
| 26 | } |
| 27 | |
| 28 | log.Printf("Got user: %v", user.GetEmail()) |
| 29 | |
| 30 | if err = s.Backend().SyncUser(stream.Context(), user); err != nil { |
| 31 | log.Printf("Error syncing user: %v", err) |
| 32 | return status.Errorf(codes.Internal, "failed to update user: %v", err) |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func (s *Service) SyncUsers(ctx context.Context, users *common.Users) (*common.Empty, error) { |
| 38 | if err := s.Backend().SyncUsers(ctx, users.GetUsers()); err != nil { |
nothing calls this directly
no test coverage detected