Skip to content

Commit

Permalink
chore: remove option
Browse files Browse the repository at this point in the history
  • Loading branch information
v3g42 committed Oct 5, 2023
1 parent 312009f commit 04b4852
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 50 deletions.
4 changes: 2 additions & 2 deletions dozer-cli/src/cli/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ pub fn generate_connection(connection_name: &str) -> Connection {
topics: vec![],
};
let ethereum_config = EthConfig {
provider: Some(EthProviderConfig::Log(EthLogConfig {
provider: EthProviderConfig::Log(EthLogConfig {
wss_url: "wss://link".to_owned(),
filter: Some(eth_filter),
contracts: vec![],
})),
}),
};
let connection: Connection = Connection {
name: "ethereum".to_owned(),
Expand Down
2 changes: 1 addition & 1 deletion dozer-ingestion/src/connectors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pub fn get_connector(connection: Connection) -> Result<Box<dyn Connector>, Conne
Ok(Box::new(PostgresConnector::new(postgres_config)))
}
#[cfg(feature = "ethereum")]
ConnectionConfig::Ethereum(eth_config) => match eth_config.provider.unwrap() {
ConnectionConfig::Ethereum(eth_config) => match eth_config.provider {
dozer_types::ingestion_types::EthProviderConfig::Log(log_config) => {
Ok(Box::new(EthLogConnector::new(log_config, connection.name)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ fn test_unsupported_format() {
#[tokio::test]
async fn test_missing_directory() {
let mut local_storage = get_local_storage_config("unsupported", "");
local_storage.details = Some(LocalDetails {
local_storage.details = LocalDetails {
path: "not_existing_path".to_string(),
});
};
let connector = ObjectStoreConnector::new(local_storage);

let tables = connector
Expand Down
20 changes: 10 additions & 10 deletions dozer-ingestion/src/connectors/object_store/tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ pub fn get_local_storage_config(typ: &str, prefix: &str) -> LocalStorage {
match typ {
"parquet" => match prefix {
"" => LocalStorage {
details: Some(LocalDetails {
details: LocalDetails {
path: p.to_str().unwrap().to_string(),
}),
},
tables: vec![Table {
config: Some(TableConfig::Parquet(ParquetConfig {
extension: typ.to_string(),
Expand All @@ -21,9 +21,9 @@ pub fn get_local_storage_config(typ: &str, prefix: &str) -> LocalStorage {
}],
},
&_ => LocalStorage {
details: Some(LocalDetails {
details: LocalDetails {
path: p.to_str().unwrap().to_string(),
}),
},
tables: vec![Table {
config: Some(TableConfig::Parquet(ParquetConfig {
extension: typ.to_string(),
Expand All @@ -36,9 +36,9 @@ pub fn get_local_storage_config(typ: &str, prefix: &str) -> LocalStorage {
},
"csv" => match prefix {
"" => LocalStorage {
details: Some(LocalDetails {
details: LocalDetails {
path: p.to_str().unwrap().to_string(),
}),
},
tables: vec![Table {
config: Some(TableConfig::CSV(CsvConfig {
extension: typ.to_string(),
Expand All @@ -49,9 +49,9 @@ pub fn get_local_storage_config(typ: &str, prefix: &str) -> LocalStorage {
}],
},
&_ => LocalStorage {
details: Some(LocalDetails {
details: LocalDetails {
path: p.to_str().unwrap().to_string(),
}),
},
tables: vec![Table {
config: Some(TableConfig::CSV(CsvConfig {
extension: typ.to_string(),
Expand All @@ -63,9 +63,9 @@ pub fn get_local_storage_config(typ: &str, prefix: &str) -> LocalStorage {
},
},
&_ => LocalStorage {
details: Some(LocalDetails {
details: LocalDetails {
path: p.to_str().unwrap().to_string(),
}),
},
tables: vec![Table {
config: None,
name: String::new(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ fn create_connector(
writer.close().expect("Failed to close writer");

let local_storage = LocalStorage {
details: Some(LocalDetails {
details: LocalDetails {
path: temp_dir.path().to_str().expect("Non-UTF8 path").to_string(),
}),
},
tables: vec![Table {
config: Some(TableConfig::Parquet(ParquetConfig {
path: table_name.to_string(),
Expand Down
10 changes: 7 additions & 3 deletions dozer-types/src/ingestion_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub enum GrpcConfigSchemas {

#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone, Hash, JsonSchema, Default)]
pub struct EthConfig {
pub provider: Option<EthProviderConfig>,
pub provider: EthProviderConfig,
}

#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone, Hash, JsonSchema)]
Expand All @@ -86,6 +86,11 @@ pub enum EthProviderConfig {

Trace(EthTraceConfig),
}
impl Default for EthProviderConfig {
fn default() -> Self {
EthProviderConfig::Log(EthLogConfig::default())
}
}

#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone, Hash, JsonSchema, Default)]
pub struct EthLogConfig {
Expand Down Expand Up @@ -117,8 +122,7 @@ impl EthConfig {
pub fn convert_to_table(&self) -> PrettyTable {
let mut table = table!();

let provider = self.provider.as_ref().expect("Must provide provider");
match provider {
match &self.provider {
EthProviderConfig::Log(log) => {
table.add_row(row!["provider", "logs"]);
table.add_row(row!["wss_url", format!("{:?}", log.wss_url)]);
Expand Down
24 changes: 10 additions & 14 deletions dozer-types/src/tests/eth_yaml_deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ fn standard() {
topics: vec![],
};
let expected_eth_config = EthConfig {
provider: Some(crate::ingestion_types::EthProviderConfig::Log(
EthLogConfig {
filter: Some(expected_eth_filter),
wss_url: "wss://link".to_owned(),
contracts: vec![],
},
)),
provider: crate::ingestion_types::EthProviderConfig::Log(EthLogConfig {
filter: Some(expected_eth_filter),
wss_url: "wss://link".to_owned(),
contracts: vec![],
}),
};
let expected = ConnectionConfig::Ethereum(expected_eth_config);
assert_eq!(expected, deserializer_result);
Expand All @@ -51,13 +49,11 @@ fn config_without_empty_array() {
topics: vec![],
};
let expected_eth_config = EthConfig {
provider: Some(crate::ingestion_types::EthProviderConfig::Log(
EthLogConfig {
wss_url: "wss://link".to_owned(),
filter: Some(expected_eth_filter),
contracts: vec![],
},
)),
provider: crate::ingestion_types::EthProviderConfig::Log(EthLogConfig {
wss_url: "wss://link".to_owned(),
filter: Some(expected_eth_filter),
contracts: vec![],
}),
};
let expected = ConnectionConfig::Ethereum(expected_eth_config);
assert_eq!(expected, deserializer_result);
Expand Down
12 changes: 4 additions & 8 deletions json_schemas/connections.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,12 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "EthConfig",
"type": "object",
"required": [
"provider"
],
"properties": {
"provider": {
"anyOf": [
{
"$ref": "#/definitions/EthProviderConfig"
},
{
"type": "null"
}
]
"$ref": "#/definitions/EthProviderConfig"
}
},
"definitions": {
Expand Down
12 changes: 4 additions & 8 deletions json_schemas/dozer.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,16 +713,12 @@
},
"EthConfig": {
"type": "object",
"required": [
"provider"
],
"properties": {
"provider": {
"anyOf": [
{
"$ref": "#/definitions/EthProviderConfig"
},
{
"type": "null"
}
]
"$ref": "#/definitions/EthProviderConfig"
}
}
},
Expand Down

0 comments on commit 04b4852

Please sign in to comment.