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:
Dietmar Maurer
2021-10-13 10:24:39 +02:00
committed by Thomas Lamprecht
parent 1d44f175c6
commit fa49d0fde9
5 changed files with 58 additions and 33 deletions

View File

@ -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,
};