hamelin_executor/
executor.rs1use std::{error::Error, fmt::Debug};
2
3use async_trait::async_trait;
4use hamelin_lib::{
5 catalog::Catalog,
6 translation::{DMLTranslation, QueryTranslation, StatementTranslation},
7 TimeRange,
8};
9
10use crate::results::ResultSet;
11
12#[async_trait]
13pub trait Executor: Debug + Send + Sync {
14 async fn execute_query(&self, query: QueryTranslation) -> Result<ResultSet, ExecutorError>;
16 async fn execute_dml(&self, dml: DMLTranslation) -> Result<usize, ExecutorError>;
17 async fn execute(&self, statement: StatementTranslation) -> Result<(), ExecutorError>;
18 async fn resolve_time_range(&self, query: QueryTranslation)
19 -> Result<TimeRange, ExecutorError>;
20 async fn reflect_catalog(&self) -> Result<Catalog, ExecutorError>;
21}
22
23#[derive(Debug, thiserror::Error)]
24pub enum ExecutorError {
25 #[error("Server error: {0}")]
26 ServerError(Box<dyn Error + Send + Sync + 'static>),
28
29 #[error("Query error: {0}")]
30 QueryError(Box<dyn Error + Send + Sync + 'static>),
32
33 #[error("Connection error: {0}")]
34 ConnectionError(Box<dyn Error + Send + Sync + 'static>),
36
37 #[error("Connection error: {0}")]
38 ConfigurationError(Box<dyn Error + Send + Sync + 'static>),
40
41 #[error("Unexpected result set: {0}")]
42 UnexpectedResultSet(Box<dyn Error + Send + Sync + 'static>),
44}