Version 2: Calls 4 queries in parallel, as an asynchronous handler Returning Error types turn into None values in the response
(db: web::Data<Pool>)
| 36 | /// Version 2: Calls 4 queries in parallel, as an asynchronous handler |
| 37 | /// Returning Error types turn into None values in the response |
| 38 | async fn parallel_weather(db: web::Data<Pool>) -> Result<HttpResponse, AWError> { |
| 39 | let fut_result = vec![ |
| 40 | db::execute(&db, Queries::GetTopTenHottestYears), |
| 41 | db::execute(&db, Queries::GetTopTenColdestYears), |
| 42 | db::execute(&db, Queries::GetTopTenHottestMonths), |
| 43 | db::execute(&db, Queries::GetTopTenColdestMonths), |
| 44 | ]; |
| 45 | let result: Result<Vec<_>, _> = join_all(fut_result).await.into_iter().collect(); |
| 46 | |
| 47 | Ok(HttpResponse::Ok().json(result.map_err(AWError::from)?)) |
| 48 | } |
| 49 | |
| 50 | #[actix_web::main] |
| 51 | async fn main() -> io::Result<()> { |
nothing calls this directly
no outgoing calls
no test coverage detected