Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,907 changes: 3,476 additions & 431 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ once_cell = { version = "1.18.0" }
regex = "1.9.1"
reqwest = { version = "0.11.18", features = ["json"] }
rs-snowflake = "0.6.0"
serde = { version = "^1", features = ["derive"] }
rustyscript = { version = "0.12.3", default-features = false, features = ["console", "crypto", "url", "web"] }
serde = { version = "=1.0.221", features = ["derive"] }
serde_json = { version = "1.0.140" }
secrecy = "0.10"
strum = "0.25"
Expand Down
7 changes: 3 additions & 4 deletions crates/cac_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ impl Client {
self.tenant
));
}
StatusCode::OK => log::info!(
"{}",
format!("{} CAC: new config received, updating", self.tenant)
),
StatusCode::OK => {
log::info!("{} CAC: new config received, updating", self.tenant)
}
x => return Err(format!("{} CAC: fetch failed, status: {}", self.tenant, x)),
};
Ok(resp)
Expand Down
1 change: 1 addition & 0 deletions crates/context_aware_config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jsonlogic = { workspace = true }
jsonschema = { workspace = true }
log = { workspace = true }
num-bigint = "0.4"
rustyscript = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
secrecy = { workspace = true }
Expand Down
9 changes: 3 additions & 6 deletions crates/context_aware_config/src/api/context/validations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,20 @@ pub fn validate_context_jsonschema(
.with_draft(Draft::Draft7)
.compile(dimension_schema)
.map_err(|e| {
log::error!(
"Failed to compile as a Draft-7 JSON schema: {}",
e.to_string()
);
log::error!("Failed to compile as a Draft-7 JSON schema: {}", e);
bad_argument!("Error encountered: invalid jsonschema for dimension.")
})?;

dimension_schema.validate(dimension_value).map_err(|e| {
let verrors = e.collect::<Vec<ValidationError>>();
log::error!(
"failed to validate dimension value {}: {:?}",
dimension_value.to_string(),
dimension_value,
verrors
);
validation_error!(
"failed to validate dimension value {}: {}",
dimension_value.to_string(),
dimension_value,
validation_err_to_str(verrors)
.first()
.unwrap_or(&String::new())
Expand Down
37 changes: 22 additions & 15 deletions crates/context_aware_config/src/api/functions/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,28 @@ async fn test_handler(
}
};

let result = execute_fn(
&workspace_context,
&code,
&req,
version,
&mut conn,
&state.master_encryption_key,
)
.map_err(|(e, stdout)| {
bad_argument!(
"Function failed with error: {}, stdout: {:?}",
e,
stdout.unwrap_or_default()
)
})?;
let handle = rustyscript::tokio::runtime::Handle::current();

let result = handle
.spawn_blocking(move || {
execute_fn(
&workspace_context,
&code,
&req,
version,
&mut conn,
&state.master_encryption_key,
)
.map_err(|(e, stdout)| {
bad_argument!(
"Function failed with error: {}, stdout: {:?}",
e,
stdout.unwrap_or_default()
)
})
})
.await
.map_err(|e| unexpected_error!("Function execution task failed: {}", e))??;

Ok(Json(result))
}
Expand Down
2 changes: 1 addition & 1 deletion crates/context_aware_config/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn calculate_weight_from_index(index: u32) -> Result<BigDecimal, String> {
let result = base.pow(index);
let biguint_str = &result.to_str_radix(10);
BigDecimal::from_str_radix(biguint_str, 10).map_err(|err| {
log::error!("failed to parse bigdecimal with error: {}", err.to_string());
log::error!("failed to parse bigdecimal with error: {}", err);
String::from("failed to parse bigdecimal with error")
})
}
Expand Down
Loading
Loading