Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions demo/node/src/data_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ use sp_governed_map::GovernedMapDataSource;
use sp_partner_chains_bridge::TokenBridgeDataSource;
use std::{error::Error, sync::Arc};

use crate::diff_sources;

pub const DATA_SOURCE_VAR: &str = "CARDANO_DATA_SOURCE";

#[derive(Clone, Debug, PartialEq)]
pub enum DataSourceType {
DbSync,
Mock,
Dolos,
// data source running queries against both dbsync and dolos, returning dolos, logging differences
// to be removed after dolos source is stable
DbSyncDolosDiff,
}

impl DataSourceType {
Expand All @@ -35,9 +40,11 @@ impl std::str::FromStr for DataSourceType {
"db-sync" => Ok(DataSourceType::DbSync),
"mock" => Ok(DataSourceType::Mock),
"dolos" => Ok(DataSourceType::Dolos),
_ => {
Err(format!("Invalid data source type: {}. Valid options: db-sync, mock, dolos", s))
},
"dolos-diff" => Ok(DataSourceType::DbSyncDolosDiff),
_ => Err(format!(
"Invalid data source type: {}. Valid options: db-sync, mock, dolos, dolos-diff",
s
)),
}
}
}
Expand All @@ -48,6 +55,7 @@ impl std::fmt::Display for DataSourceType {
DataSourceType::DbSync => write!(f, "db-sync"),
DataSourceType::Mock => write!(f, "mock"),
DataSourceType::Dolos => write!(f, "dolos"),
DataSourceType::DbSyncDolosDiff => write!(f, "dolos-diff"),
}
}
}
Expand Down Expand Up @@ -84,6 +92,14 @@ pub(crate) async fn create_cached_data_sources(
DataSourceType::Dolos => create_dolos_data_sources().await.map_err(|err| {
ServiceError::Application(format!("Failed to create dolos data sources: {err}").into())
}),

DataSourceType::DbSyncDolosDiff => {
diff_sources::create_diff_data_sources(metrics_opt).await.map_err(|err| {
ServiceError::Application(
format!("Failed to create diff data sources: {err}").into(),
)
})
},
}
}

Expand Down
Loading
Loading