Expand description
Autumn plugin for Amazon Athena.
Add AthenaPlugin to the app. Then use the Athena extractor in a handler.
use autumn_plugin_aws_athena::{Athena, AthenaPlugin, AthenaResultExt as _};
use autumn_web::prelude::*;
#[derive(serde::Deserialize, serde::Serialize)]
struct Order {
id: i64,
total: f64,
}
#[get("/customers/{id}/orders")]
async fn orders(athena: Athena, Path(id): Path<String>) -> AutumnResult<Json<Vec<Order>>> {
let rows = athena
.query("SELECT id, total FROM orders WHERE customer_id = ?")
.bind(id)
.fetch_as::<Order>()
.await
.or_http()?;
Ok(Json(rows))
}
autumn_web::app()
.plugin(AthenaPlugin::new())
.routes(routes![orders])
.run()
.await;The plugin reads [athena] in autumn.toml. See config for the keys.
§Security rules
- Bind each value with
AthenaQuery::bind. Do not put values into the SQL text. - Each query has a timeout, a row limit and a byte limit. The plugin stops a timed-out query in Athena.
- Set
BytesScannedCutoffPerQueryon the workgroup. This limits the cost of one query. - Logs have query IDs. Logs do not have SQL text or parameter values.
Re-exports§
pub use api::ApiError;pub use api::AthenaApi;pub use api::Column;pub use api::FailureInfo;pub use api::QueryState;pub use api::StatementType;pub use api::Statistics;pub use config::AthenaConfig;pub use config::PollConfig;pub use literal::Param;pub use sdk::SdkAthena;pub use value::Row;pub use value::Value;
Modules§
- api
- The seam between the plugin and Athena.
- config
- The
[athena]section ofautumn.toml. - literal
- Athena SQL literals for execution parameters.
- sdk
AthenaApion the AWS SDK client.- testing
- A scripted fake of Athena for tests.
- value
- Typed values and rows.
Structs§
- Athena
- A handle to Athena. Clones share one connection and one set of open queries.
- Athena
Plugin - Installs an
Athenahandle in an Autumn app. - Athena
Query - A query to run. Make one with
Athena::query. - Execution
- A query that succeeded.
- Query
Output - The rows of a query that succeeded.
Enums§
- Athena
Error - An error from the plugin.
Constants§
- PLUGIN_
NAME - The plugin name in Autumn diagnostics.
Traits§
- Athena
Result Ext - Adds
or_httptoResult<T, AthenaError>.