Skip to content

Commit

Permalink
Remove raw_region_routing from validate_raw_configuration, default ge…
Browse files Browse the repository at this point in the history
…t_read_regions and get_write_regions implementations
  • Loading branch information
danieljharvey committed Sep 18, 2023
1 parent abfc255 commit 37139d0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
13 changes: 9 additions & 4 deletions rust-connector-sdk/src/connector.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use async_trait::async_trait;
use ndc_client::models;
use serde::Serialize;
use std::{collections::BTreeMap, error::Error};
use std::error::Error;
use thiserror::Error;
pub mod example;

Expand Down Expand Up @@ -189,9 +189,15 @@ pub trait Connector {
/// The type of unserializable state
type State;

fn get_read_regions(config: &Self::Configuration) -> Vec<String>;
/// Return any read regions defined in the connector's configuration
fn get_read_regions(_config: &Self::Configuration) -> Vec<String> {
vec![]
}

fn get_write_regions(config: &Self::Configuration) -> Vec<String>;
/// Return any write regions defined in the connector's configuration
fn get_write_regions(_config: &Self::Configuration) -> Vec<String> {
vec![]
}

fn make_empty_configuration() -> Self::RawConfiguration;

Expand All @@ -203,7 +209,6 @@ pub trait Connector {
/// returning a configuration error or a validated [`Connector::Configuration`].
async fn validate_raw_configuration(
configuration: &Self::RawConfiguration,
region_routing: &BTreeMap<String, Vec<String>>,
) -> Result<Self::Configuration, ValidateError>;

/// Initialize the connector's in-memory state.
Expand Down
1 change: 0 additions & 1 deletion rust-connector-sdk/src/connector/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ impl Connector for Example {

async fn validate_raw_configuration(
_configuration: &Self::Configuration,
_region_routing: &BTreeMap<String, Vec<String>>,
) -> Result<Self::Configuration, ValidateError> {
Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions rust-connector-sdk/src/default_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use opentelemetry_sdk::trace::Sampler;
use prometheus::Registry;
use schemars::{schema::RootSchema, JsonSchema};
use serde::{de::DeserializeOwned, Serialize};
use std::error::Error;
use std::net;
use std::{collections::BTreeMap, error::Error};
use std::{env, process::exit};
use tower_http::{
cors::CorsLayer,
Expand Down Expand Up @@ -301,7 +301,7 @@ where
let configuration_json = std::fs::read_to_string(config_file).unwrap();
let raw_configuration =
serde_json::de::from_str::<C::RawConfiguration>(configuration_json.as_str()).unwrap();
let configuration = C::validate_raw_configuration(&raw_configuration, &BTreeMap::default())
let configuration = C::validate_raw_configuration(&raw_configuration)
.await
.unwrap();

Expand Down Expand Up @@ -474,7 +474,7 @@ async fn post_validate<C: Connector>(
where
C::RawConfiguration: DeserializeOwned,
{
let configuration = C::validate_raw_configuration(&configuration, &BTreeMap::default())
let configuration = C::validate_raw_configuration(&configuration)
.await
.map_err(|e| match e {
crate::connector::ValidateError::ValidateError(ranges) => (
Expand Down Expand Up @@ -537,7 +537,7 @@ where
let configuration_json = std::fs::read_to_string(command.configuration).unwrap();
let raw_configuration =
serde_json::de::from_str::<C::RawConfiguration>(configuration_json.as_str()).unwrap();
let configuration = C::validate_raw_configuration(&raw_configuration, &BTreeMap::default())
let configuration = C::validate_raw_configuration(&raw_configuration)
.await
.unwrap();

Expand Down

0 comments on commit 37139d0

Please sign in to comment.