use std::sync::{Arc, Mutex};
use crate::{reactor::SharedReactorState, store::SqliteDagStore};
#[cfg(feature = "dagdb-gateway-proxy")]
#[derive(Clone, Default)]
pub struct DagDbGatewayConfig {
pub base_url: Option<String>,
pub bearer_token: Option<zeroize::Zeroizing<String>>,
pub tenant_id: Option<String>,
pub namespace: Option<String>,
}
#[cfg(feature = "dagdb-gateway-proxy")]
impl DagDbGatewayConfig {
#[must_use]
pub fn new(
base_url: impl Into<String>,
bearer_token: impl Into<String>,
tenant_id: impl Into<String>,
namespace: impl Into<String>,
) -> Self {
Self {
base_url: Some(base_url.into()),
bearer_token: Some(zeroize::Zeroizing::new(bearer_token.into())),
tenant_id: Some(tenant_id.into()),
namespace: Some(namespace.into()),
}
}
}
#[derive(Clone, Default)]
pub struct NodeContext {
pub reactor_state: Option<SharedReactorState>,
pub store: Option<Arc<Mutex<SqliteDagStore>>>,
pub node_did: Option<String>,
#[cfg(feature = "dagdb-gateway-proxy")]
pub dagdb_gateway: Option<DagDbGatewayConfig>,
}
impl NodeContext {
#[must_use]
pub fn empty() -> Self {
Self::default()
}
#[must_use]
#[allow(dead_code)]
pub fn has_reactor(&self) -> bool {
self.reactor_state.is_some()
}
#[must_use]
pub fn has_store(&self) -> bool {
self.store.is_some()
}
}