Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
trueleo committed Oct 9, 2023
1 parent 63de18a commit f99003c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
13 changes: 6 additions & 7 deletions server/src/external_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@ impl Registration {
.iter()
.any(|x| x.module_path == path && method.eq(&x.method))
}

pub fn set_version(&mut self, version: &str) -> Result<(), String> {
if version.starts_with('v') {
match Version::parse(&version[1..]) {
Ok(_) => {
self.version = version.to_string();
Ok(())
}
Err(_) => Err("Invalid SemVer format".to_string()),
if let Some(version) = version.strip_prefix('v') {
if Version::parse(version).is_err() {
return Err("Invalid SemVer format".to_string());
}
self.version = version.to_string();
Ok(())
} else {
Err("Module version must start with 'v'".to_string())
}
Expand Down
7 changes: 5 additions & 2 deletions server/src/handlers/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,11 @@ pub fn configure_routes(
.route(web::put().to(external::register))
.route(web::delete().to(external::deregister)),
)
.service(resource("{module}/config/{logstream}").route(web::get().to(external::get_config)))
.service(resource("{module}/config/{logstream}").route(web::put().to(external::put_config)))
.service(
resource("{module}/config/{logstream}")
.route(web::get().to(external::get_config))
.route(web::put().to(external::put_config)),
)
.service(resource("{module}/{tail}*").to(external::router))
.app_data(web::Data::from(Arc::clone(&*MODULE_REGISTRY)));

Expand Down
10 changes: 5 additions & 5 deletions server/src/handlers/http/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ pub async fn put_config(
let url = url.join(&path)?;
let client = reqwest::Client::new();
let req_body = serde_json::to_vec(&config).expect("valid json");
CONFIG
.storage()
.get_object_store()
.put_module_config(&stream_name, name, config)
.await?;
let request = client.post(url).body(req_body).build().unwrap();
let resp = client.execute(request).await?;

Expand All @@ -109,11 +114,6 @@ pub async fn put_config(
return Err(ModuleError::Custom(resp_body.into()));
}

CONFIG
.storage()
.get_object_store()
.put_module_config(&stream_name, name, config)
.await?;
Ok(HttpResponse::Ok())
}

Expand Down

0 comments on commit f99003c

Please sign in to comment.