runtime-rs: make static resource mgmt idiomatic

Make the get value process (cpu and mem) more idiomatic.

Fixes: #4742
Signed-off-by: Ji-Xinyou <jerryji0414@outlook.com>
This commit is contained in:
Ji-Xinyou 2022-08-15 11:14:18 +08:00
parent 4a54876dde
commit 00f3a6de12

View File

@ -383,10 +383,7 @@ impl Annotation {
let value = self
.get_value::<u64>(SANDBOX_CPU_QUOTA_KEY)
.unwrap_or(Some(0));
if let Some(q) = value {
return q;
}
0
value.unwrap_or(0)
}
/// Get the annotation of cpu period for sandbox
@ -394,19 +391,13 @@ impl Annotation {
let value = self
.get_value::<i64>(SANDBOX_CPU_PERIOD_KEY)
.unwrap_or(Some(0));
if let Some(p) = value {
return p;
}
0
value.unwrap_or(0)
}
/// Get the annotation of memory for sandbox
pub fn get_sandbox_mem(&self) -> i64 {
let value = self.get_value::<i64>(SANDBOX_MEM_KEY).unwrap_or(Some(0));
if let Some(m) = value {
return m;
}
0
value.unwrap_or(0)
}
/// Get the annotation to specify the Resources.Memory.Swappiness.