mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-15 09:22:55 +00:00
@@ -235,7 +235,7 @@ pub struct TenantConfig {
|
||||
// Otherwise we'd have to move the types for eviction policy into this package.
|
||||
// We might do that once the eviction feature has stabilizied.
|
||||
// For now, this field is not even documented in the openapi_spec.yml.
|
||||
#[clap(long, value_parser = clap::value_parser!(serde_json::Value))]
|
||||
#[clap(long, value_parser = parse_json)]
|
||||
pub eviction_policy: Option<serde_json::Value>,
|
||||
#[clap(long)]
|
||||
pub min_resident_size_override: Option<u64>,
|
||||
@@ -244,6 +244,10 @@ pub struct TenantConfig {
|
||||
pub gc_feedback: Option<bool>,
|
||||
}
|
||||
|
||||
fn parse_json(s: &str) -> Result<serde_json::Value, serde_json::Error> {
|
||||
serde_json::from_str(s)
|
||||
}
|
||||
|
||||
impl TenantConfig {
|
||||
pub fn deserialize_from_settings(settings: HashMap<&str, &str>) -> Result<Self, anyhow::Error> {
|
||||
let config = TenantConfig::try_parse_from(
|
||||
@@ -928,6 +932,15 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_json_field() {
|
||||
let config = vec![(
|
||||
"eviction_policy",
|
||||
"eviction_policy:{\"kind\": \"NoEviction\"}",
|
||||
)];
|
||||
TenantConfig::deserialize_from_settings(config.into_iter().collect()).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tenantstatus_activating_serde() {
|
||||
let states = [
|
||||
|
||||
Reference in New Issue
Block a user