Skip to content

Commit

Permalink
chore: remove sinks for offline mode (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
sighphyre authored Feb 9, 2023
1 parent 81d49ef commit 9a34999
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 30 deletions.
6 changes: 3 additions & 3 deletions server/src/data_sources/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ pub struct SinkInfo {
pub metrics_interval_seconds: u64,
}

fn build_offline(offline_args: OfflineArgs) -> EdgeResult<DataProviderPair> {
fn build_offline(offline_args: OfflineArgs) -> EdgeResult<Arc<RwLock<dyn EdgeSource>>> {
let provider = OfflineProvider::instantiate_provider(
offline_args.bootstrap_file,
offline_args.client_keys,
)?;
let provider = Arc::new(RwLock::new(provider));
Ok((provider.clone(), provider))
Ok(provider)
}

fn build_memory(sender: Sender<EdgeToken>) -> EdgeResult<DataProviderPair> {
Expand All @@ -55,7 +55,7 @@ fn build_redis(redis_url: String, sender: Sender<EdgeToken>) -> EdgeResult<DataP
pub fn build_source_and_sink(args: CliArgs) -> EdgeResult<RepositoryInfo> {
match args.mode {
EdgeMode::Offline(offline_args) => {
let (source, _) = build_offline(offline_args)?;
let source = build_offline(offline_args)?;
Ok(RepositoryInfo {
source,
sink_info: None,
Expand Down
28 changes: 1 addition & 27 deletions server/src/data_sources/offline_provider.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::error::EdgeError;
use crate::types::{
ClientFeaturesResponse, EdgeResult, EdgeSink, EdgeSource, EdgeToken, FeatureSink,
FeaturesSource, TokenSink, TokenSource, TokenValidationStatus,
EdgeResult, EdgeSource, EdgeToken, FeaturesSource, TokenSource, TokenValidationStatus,
};
use actix_web::http::header::EntityTag;
use async_trait::async_trait;
use std::collections::HashMap;
use std::fs::File;
Expand Down Expand Up @@ -62,30 +60,6 @@ impl TokenSource for OfflineProvider {
}

impl EdgeSource for OfflineProvider {}
impl EdgeSink for OfflineProvider {}

#[async_trait]
impl FeatureSink for OfflineProvider {
async fn sink_features(
&mut self,
_token: &EdgeToken,
_features: ClientFeatures,
) -> EdgeResult<()> {
todo!()
}
async fn fetch_features(&mut self, _token: &EdgeToken) -> EdgeResult<ClientFeaturesResponse> {
Ok(ClientFeaturesResponse::NoUpdate(EntityTag::new_weak(
"this_provider_does_not_support_refreshing_features".into(),
)))
}
}

#[async_trait]
impl TokenSink for OfflineProvider {
async fn sink_tokens(&mut self, _token: Vec<EdgeToken>) -> EdgeResult<()> {
todo!()
}
}

impl OfflineProvider {
pub fn instantiate_provider(
Expand Down

0 comments on commit 9a34999

Please sign in to comment.