Skip to content

Commit

Permalink
Execute redundancy (#47)
Browse files Browse the repository at this point in the history
Removed a bunch of redundant code left over from a refactor
  • Loading branch information
dylanratcliffe authored Jun 28, 2022
1 parent 47ac385 commit fd2962d
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions request_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,6 @@ func (r *RequestTracker) stopLinking() {
}

func (r *RequestTracker) Execute() ([]*sdp.Item, error) {
var errs []error
var errsMutex sync.Mutex
var requestsWait sync.WaitGroup
var expandedRequests []*sdp.ItemRequest

if r.unlinkedItems == nil {
r.unlinkedItems = make(chan *sdp.Item)
}
Expand All @@ -245,9 +240,6 @@ func (r *RequestTracker) Execute() ([]*sdp.Item, error) {
r.cancelFuncMutex.Unlock()
defer cancel()

// Populate the waitgroup with the initial number of requests
requestsWait.Add(len(expandedRequests))

r.startLinking(ctx)

// Run the request
Expand All @@ -260,19 +252,13 @@ func (r *RequestTracker) Execute() ([]*sdp.Item, error) {
// goroutine, linked and published once done
r.queueUnlinkedItem(item)
}
} else {
errsMutex.Lock()
errs = append(errs, err)
errsMutex.Unlock()
}

// Wait for all of the initial requests to be done processing
requestsWait.Wait()
r.stopLinking()

// If everything has failed then just stop here
if len(errs) == len(expandedRequests) && len(errs) > 0 {
return nil, errs[0]
if err != nil {
return r.LinkedItems(), err
}

return r.LinkedItems(), ctx.Err()
Expand Down

0 comments on commit fd2962d

Please sign in to comment.