// GetWeatherReport calls all services in parallel and returns the first result
GetWeatherReport calls all services in parallel and returns the first result
// GetWeatherReport calls all services in parallel and returns the first result
func GetWeatherReport(ctx context.Context, services []WeatherService, lat, long string) WeatherReport {
	ch := make(chan WeatherReport, 1)
	ctx, seg := xray.BeginSubsegment(ctx, "weather-report")
	defer seg.Close(nil)
	for _, service := range services {
		go func(c context.Context, s WeatherService, la, lo string) {
			result, err := s.GetWeatherReport(c, la, lo)
			if err == nil {
				select {
				case ch <- result:
				default:
				}
			}
		}(ctx, service, lat, long)
	}
	return <-ch
}
func GetWeatherReport ( ctx context . Context , services [ ] WeatherService , lat , long string ) WeatherReport { ch := make ( chan WeatherReport , 1 ) ctx , seg := xray . BeginSubsegment ( ctx , " " ) defer seg . Close ( nil ) for _ , service := range services { go func ( c context . Context , s WeatherService , la , lo string ) { result , err := s . GetWeatherReport ( c , la , lo ) if err == nil { select { case ch <- result : default : } } } ( ctx , service , lat , long ) } return <- ch }
GetWeatherReport calls all services in parallel and returns the first result
GetWeatherReport calls all services in parallel and returns the first result
//	Start the service segment //	For each passed service ... //	Launch a goroutine for each service... //	Get its pollen report ... //	As long as we don't have an error, return what we found on the result channel //	Return the first result passed on the channel