package remotes import ( "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/load" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote" ) // Will determine number of total projects, // then based on projectsPerPage (request) and // projectsPerGoroutine, will spin off goroutines // with offsets const ( projectsPerPage = 20 projectsPerGoroutine = 200 ) type Remotes []remote.Remote func (r *Remotes) AddRemote(remote remote.Remote) { *r = append(*r, remote) } // Launches project streamsers for all remotes in goroutines // returns slice of load.ProgressInfo func (r *Remotes) StreamRemotes(opts *remote.RemoteQueryOpts) []*load.ProgressInfo { progressInfos := make([]*load.ProgressInfo, len(*r)) for i, remoteInstance := range *r { progressInfos[i] = &load.ProgressInfo{ ProgressChan: make(chan load.Progress), ProjectsChan: make(chan []*projects.Project), ErrorChan: make(chan error), DoneChan: make(chan interface{}), NumProjects: remoteInstance.GetNumProjects(opts), } go remoteInstance.StreamProjects(progressInfos[i], opts) } return progressInfos } func NewRemotes() *Remotes { var remotes Remotes remotes = make([]remote.Remote, 0) return &remotes }