Skip to content

Commit

Permalink
Update SDK for new deployment spec
Browse files Browse the repository at this point in the history
  • Loading branch information
paf31 committed Feb 13, 2024
1 parent e0653f4 commit 48ef017
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 288 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ COPY ./rust-connector-sdk .
RUN cargo build --release

FROM debian:buster-slim as connector
RUN 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" ]
22 changes: 2 additions & 20 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::PathBuf};

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;
/// The type of validated configuration
type Configuration;
/// The type of unserializable state
type State;

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,
configuration_dir: PathBuf,
) -> Result<Self::Configuration, ValidateError>;

/// Initialize the connector's in-memory state.
Expand Down
12 changes: 2 additions & 10 deletions rust-connector-sdk/src/connector/example.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::BTreeMap;
use std::path::PathBuf;

use async_trait::async_trait;
use tracing::info_span;
Expand All @@ -11,20 +12,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,
_configuration_dir: PathBuf,
) -> Result<Self::Configuration, ValidateError> {
Ok(())
}
Expand Down
Loading

0 comments on commit 48ef017

Please sign in to comment.