Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SDK for new deployment spec #97

Merged
merged 11 commits into from
Feb 16, 2024
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ COPY ./rust-connector-sdk .
RUN cargo build --release

FROM debian:buster-slim as connector
RUN set -ex; \
apt-get update; \
DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends --assume-yes \
libssl-dev
COPY --from=build /app/target/release/ndc_hub_example ./ndc_hub_example
ENTRYPOINT [ "/ndc_hub_example" ]
CMD [ "serve", "--port", "8080" ]
CMD [ "serve", "--configuration", "/etc/connector" ]
24 changes: 3 additions & 21 deletions rust-connector-sdk/src/connector.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::error::Error;
use std::{error::Error, path::Path};

use async_trait::async_trait;
use ndc_client::models;
Expand Down Expand Up @@ -32,16 +32,6 @@ pub enum KeyOrIndex {
Index(u32),
}

/// Errors which occur when trying to validate connector
/// configuration.
///
/// See [`Connector::update_configuration`].
#[derive(Debug, Error)]
pub enum UpdateConfigurationError {
#[error("error validating configuration: {0}")]
Other(#[from] Box<dyn Error + Send + Sync>),
}

/// Errors which occur when trying to initialize connector
/// state.
///
Expand Down Expand Up @@ -201,23 +191,15 @@ pub enum MutationError {
/// connection string would be state.
#[async_trait]
pub trait Connector {
/// The type of unvalidated, raw configuration, as provided by the user.
type RawConfiguration: Sync + Send;
/// The type of validated configuration
type Configuration: Sync + Send;
/// The type of unserializable state
type State: Sync + Send;

fn make_empty_configuration() -> Self::RawConfiguration;

async fn update_configuration(
config: Self::RawConfiguration,
) -> Result<Self::RawConfiguration, UpdateConfigurationError>;

/// Validate the raw configuration provided by the user,
/// returning a configuration error or a validated [`Connector::Configuration`].
async fn validate_raw_configuration(
configuration: Self::RawConfiguration,
async fn parse_configuration(
configuration_dir: impl AsRef<Path> + Send,
) -> Result<Self::Configuration, ValidateError>;

/// Initialize the connector's in-memory state.
Expand Down
13 changes: 2 additions & 11 deletions rust-connector-sdk/src/connector/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ pub struct Example {}

#[async_trait]
impl Connector for Example {
type RawConfiguration = ();
type Configuration = ();
type State = ();

fn make_empty_configuration() -> Self::RawConfiguration {}

async fn update_configuration(
_config: Self::RawConfiguration,
) -> Result<Self::RawConfiguration, UpdateConfigurationError> {
Ok(())
}

async fn validate_raw_configuration(
_configuration: Self::Configuration,
async fn parse_configuration(
_configuration_dir: impl AsRef<Path> + Send,
) -> Result<Self::Configuration, ValidateError> {
Ok(())
}
Expand Down
Loading
Loading