MCPcopy Create free account
hub / github.com/actix/examples / asyncio_weather

Function asyncio_weather

databases/sqlite/src/main.rs:25–34  ·  view source on GitHub ↗

Version 1: Calls 4 queries in sequential order, as an asynchronous handler

(db: web::Data<Pool>)

Source from the content-addressed store, hash-verified

23
24/// Version 1: Calls 4 queries in sequential order, as an asynchronous handler
25async fn asyncio_weather(db: web::Data<Pool>) -> Result<HttpResponse, AWError> {
26 let result = vec![
27 db::execute(&db, Queries::GetTopTenHottestYears).await?,
28 db::execute(&db, Queries::GetTopTenColdestYears).await?,
29 db::execute(&db, Queries::GetTopTenHottestMonths).await?,
30 db::execute(&db, Queries::GetTopTenColdestMonths).await?,
31 ];
32
33 Ok(HttpResponse::Ok().json(result))
34}
35
36/// Version 2: Calls 4 queries in parallel, as an asynchronous handler
37/// Returning Error types turn into None values in the response

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected