use foundation_netio::shared::client::DnsResolver;
use foundation_netio::http::SimpleHttpClient;
use foundation_db::core::state::traits::StateStore;
use std::sync::Arc;
pub struct ProviderClient<S, R>
where
S: StateStore + Send + Sync + 'static,
R: DnsResolver + Clone + 'static,
{
pub state_store: Arc<S>,
pub project: String,
pub stage: String,
pub http_client: Arc<SimpleHttpClient<R>>,
}
impl<S, R> Clone for ProviderClient<S, R>
where
S: StateStore + Send + Sync + 'static,
R: DnsResolver + Clone + 'static,
{
fn clone(&self) -> Self {
Self {
state_store: self.state_store.clone(),
project: self.project.clone(),
stage: self.stage.clone(),
http_client: self.http_client.clone(),
}
}
}
impl<S, R> ProviderClient<S, R>
where
S: StateStore + Send + Sync + 'static,
R: DnsResolver + Clone + 'static,
{
pub fn new(
project: &str,
stage: &str,
state_store: S,
http_client: SimpleHttpClient<R>,
) -> Self {
Self {
state_store: Arc::new(state_store),
project: project.to_string(),
stage: stage.to_string(),
http_client: Arc::new(http_client),
}
}
#[must_use]
pub fn state_store(&self) -> &S {
&self.state_store
}
#[must_use]
pub fn project(&self) -> &str {
&self.project
}
#[must_use]
pub fn stage(&self) -> &str {
&self.stage
}
#[must_use]
pub fn http_client(&self) -> &SimpleHttpClient<R> {
&self.http_client
}
}
pub use foundation_db::core::state::store_state_task::ProviderError;
pub use foundation_db::core::state::store_state_task::StoreStateIdentifierTask;