autumn_plugin_aws_athena/lib.rs
1//! Autumn plugin for Amazon Athena.
2//!
3//! Add [`AthenaPlugin`] to the app. Then use the [`Athena`] extractor in a handler.
4//!
5//! ```rust,no_run
6//! use autumn_plugin_aws_athena::{Athena, AthenaPlugin, AthenaResultExt as _};
7//! use autumn_web::prelude::*;
8//!
9//! #[derive(serde::Deserialize, serde::Serialize)]
10//! struct Order {
11//! id: i64,
12//! total: f64,
13//! }
14//!
15//! #[get("/customers/{id}/orders")]
16//! async fn orders(athena: Athena, Path(id): Path<String>) -> AutumnResult<Json<Vec<Order>>> {
17//! let rows = athena
18//! .query("SELECT id, total FROM orders WHERE customer_id = ?")
19//! .bind(id)
20//! .fetch_as::<Order>()
21//! .await
22//! .or_http()?;
23//! Ok(Json(rows))
24//! }
25//!
26//! # async fn run() {
27//! autumn_web::app()
28//! .plugin(AthenaPlugin::new())
29//! .routes(routes![orders])
30//! .run()
31//! .await;
32//! # }
33//! ```
34//!
35//! The plugin reads `[athena]` in `autumn.toml`. See [`config`] for the keys.
36//!
37//! # Security rules
38//!
39//! - Bind each value with [`AthenaQuery::bind`]. Do not put values into the SQL text.
40//! - Each query has a timeout, a row limit and a byte limit. The plugin stops a timed-out query in Athena.
41//! - Set `BytesScannedCutoffPerQuery` on the workgroup. This limits the cost of one query.
42//! - Logs have query IDs. Logs do not have SQL text or parameter values.
43
44pub mod api;
45mod backoff;
46mod client;
47pub mod config;
48mod error;
49mod health;
50pub mod literal;
51mod metrics;
52mod placeholder;
53mod plugin;
54mod result;
55pub mod sdk;
56#[cfg(any(test, feature = "test-support"))]
57pub mod testing;
58pub mod value;
59
60pub use api::{ApiError, AthenaApi, Column, FailureInfo, QueryState, StatementType, Statistics};
61pub use client::{Athena, AthenaQuery, Execution, QueryOutput};
62pub use config::{AthenaConfig, PollConfig};
63pub use error::{AthenaError, AthenaResultExt};
64pub use literal::Param;
65pub use plugin::{AthenaPlugin, PLUGIN_NAME};
66pub use sdk::SdkAthena;
67pub use value::{Row, Value};