use std::sync::Arc;
use crate::config::CassandraConfig;
use crate::error::CassandraResult;
pub struct CassandraConnection {
config: CassandraConfig,
#[allow(dead_code)]
session: Arc<CdrsSessionHandle>,
}
pub(crate) struct CdrsSessionHandle {
#[allow(dead_code)]
inner: Box<dyn std::any::Any + Send + Sync>,
}
impl CassandraConnection {
pub async fn connect(config: CassandraConfig) -> CassandraResult<Self> {
Err(crate::error::CassandraError::Connection(format!(
"CassandraConnection::connect is not yet wired to cdrs-tokio (nodes: {:?})",
config.known_nodes
)))
}
pub fn config(&self) -> &CassandraConfig {
&self.config
}
pub async fn ping(&self) -> CassandraResult<()> {
Err(crate::error::CassandraError::Connection(
"ping requires a live cdrs-tokio session".into(),
))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_connect_without_live_cluster_returns_error() {
let config = CassandraConfig::builder()
.known_nodes(["127.0.0.1:9042".to_string()])
.build();
let result = CassandraConnection::connect(config).await;
assert!(result.is_err());
}
}