diff --git a/connecting_fronts.go b/connecting_fronts.go index 39b178e..e0456fe 100644 --- a/connecting_fronts.go +++ b/connecting_fronts.go @@ -27,7 +27,7 @@ func newConnectingFronts(size int) *connecting { } } -// AddFront adds a new front to the list of fronts. +// onConnected adds a working front to the channel of working fronts. func (cf *connecting) onConnected(m Front) { cf.frontsCh <- m } @@ -35,6 +35,7 @@ func (cf *connecting) onConnected(m Front) { func (cf *connecting) connectingFront(ctx context.Context) (Front, error) { for { select { + // This is typically the context of the HTTP request. If the context is done, return an error. case <-ctx.Done(): return nil, ctx.Err() case m := <-cf.frontsCh: diff --git a/fronted.go b/fronted.go index bc0dd1f..d3574d5 100644 --- a/fronted.go +++ b/fronted.go @@ -144,6 +144,7 @@ func loadFronts(providers map[string]*Provider) sortedFronts { fronts := make(sortedFronts, size) + // Note that map iteration order is random, so the order of the providers is automatically randomized. index := 0 for key, p := range providers { arr := p.Masquerades