RRD_CACHE: use a OnceCell instead of lazy_static
And initialize only with proxmox-backup-proxy. Other binaries dont need it. Signed-off-by: Dietmar Maurer <dietmar@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
1d44f175c6
commit
fa49d0fde9
@ -10,7 +10,7 @@ use pbs_api_types::{
|
||||
|
||||
use proxmox_rrd::rrd::RRD_DATA_ENTRIES;
|
||||
|
||||
use crate::RRD_CACHE;
|
||||
use crate::get_rrd_cache;
|
||||
|
||||
pub fn create_value_from_rrd(
|
||||
basedir: &str,
|
||||
@ -22,8 +22,10 @@ pub fn create_value_from_rrd(
|
||||
let mut result = Vec::new();
|
||||
let now = proxmox_time::epoch_f64();
|
||||
|
||||
let rrd_cache = get_rrd_cache()?;
|
||||
|
||||
for name in list {
|
||||
let (start, reso, list) = match RRD_CACHE.extract_cached_data(basedir, name, now, timeframe, cf) {
|
||||
let (start, reso, list) = match rrd_cache.extract_cached_data(basedir, name, now, timeframe, cf) {
|
||||
Some(result) => result,
|
||||
None => continue,
|
||||
};
|
||||
|
@ -22,7 +22,7 @@ use pbs_datastore::DataStore;
|
||||
use pbs_config::CachedUserInfo;
|
||||
|
||||
use crate::tools::statistics::{linear_regression};
|
||||
use crate::RRD_CACHE;
|
||||
use crate::get_rrd_cache;
|
||||
|
||||
#[api(
|
||||
returns: {
|
||||
@ -90,6 +90,8 @@ pub fn datastore_status(
|
||||
|
||||
let mut list = Vec::new();
|
||||
|
||||
let rrd_cache = get_rrd_cache()?;
|
||||
|
||||
for (store, (_, _)) in &config.sections {
|
||||
let user_privs = user_info.lookup_privs(&auth_id, &["datastore", &store]);
|
||||
let allowed = (user_privs & (PRIV_DATASTORE_AUDIT| PRIV_DATASTORE_BACKUP)) != 0;
|
||||
@ -123,7 +125,8 @@ pub fn datastore_status(
|
||||
let rrd_dir = format!("datastore/{}", store);
|
||||
let now = proxmox_time::epoch_f64();
|
||||
|
||||
let get_rrd = |what: &str| RRD_CACHE.extract_cached_data(
|
||||
|
||||
let get_rrd = |what: &str| rrd_cache.extract_cached_data(
|
||||
&rrd_dir,
|
||||
what,
|
||||
now,
|
||||
|
Reference in New Issue
Block a user