Skip to content

Confusion in the codes of WatchAssignments function #1472

@goace

Description

@goace

Here is the codes of WatchAssignments:

func (s *frontendService) WatchAssignments(req *pb.WatchAssignmentsRequest, stream pb.FrontendService_WatchAssignmentsServer) error {
	ctx := stream.Context()
	for {
		select {
		case <-ctx.Done():
			return ctx.Err()
		default:
			sender := func(assignment *pb.Assignment) error {
				return stream.Send(&pb.WatchAssignmentsResponse{Assignment: assignment})
			}
			return doWatchAssignments(ctx, req.GetTicketId(), sender, s.store)
		}
	}
}

Here is my question: Since the loop will quit in the first loop anyway, what's the meaning of the "for" here?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions