mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-06-21 08:39:55 +00:00
Remove lazy_static dependency.
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -866,7 +866,6 @@ dependencies = [
|
|||||||
"humantime-serde",
|
"humantime-serde",
|
||||||
"jsonwebtoken",
|
"jsonwebtoken",
|
||||||
"lapin",
|
"lapin",
|
||||||
"lazy_static",
|
|
||||||
"lrwn",
|
"lrwn",
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
"oauth2",
|
"oauth2",
|
||||||
@ -946,7 +945,6 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"chirpstack_api",
|
"chirpstack_api",
|
||||||
"lazy_static",
|
|
||||||
"redis",
|
"redis",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -24,6 +24,5 @@
|
|||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
tokio = { version = "1.44", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.44", features = ["macros", "rt-multi-thread"] }
|
||||||
lazy_static = "1.5"
|
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
toml = "0.8"
|
toml = "0.8"
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
|
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -13,10 +11,8 @@ use tracing_subscriber::{filter, prelude::*};
|
|||||||
|
|
||||||
use chirpstack_api::{integration as integration_pb, prost::Message};
|
use chirpstack_api::{integration as integration_pb, prost::Message};
|
||||||
|
|
||||||
lazy_static! {
|
static INTEGRATION: LazyLock<RwLock<Option<Box<dyn IntegrationTrait + Sync + Send>>>> =
|
||||||
static ref INTEGRATION: RwLock<Option<Box<dyn IntegrationTrait + Sync + Send>>> =
|
LazyLock::new(|| RwLock::new(None));
|
||||||
RwLock::new(None);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Clone)]
|
#[derive(Default, Deserialize, Clone)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
@ -137,7 +137,6 @@
|
|||||||
] }
|
] }
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
lazy_static = "1.5"
|
|
||||||
uuid = { version = "1.16", features = ["v4", "serde"] }
|
uuid = { version = "1.16", features = ["v4", "serde"] }
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -14,10 +15,8 @@ pub mod lora_lr_fhss;
|
|||||||
pub mod lr_fhss;
|
pub mod lr_fhss;
|
||||||
pub mod plugin;
|
pub mod plugin;
|
||||||
|
|
||||||
lazy_static! {
|
static ADR_ALGORITHMS: LazyLock<RwLock<HashMap<String, Box<dyn Handler + Sync + Send>>>> =
|
||||||
static ref ADR_ALGORITHMS: RwLock<HashMap<String, Box<dyn Handler + Sync + Send>>> =
|
LazyLock::new(|| RwLock::new(HashMap::new()));
|
||||||
RwLock::new(HashMap::new());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn setup() -> Result<()> {
|
pub async fn setup() -> Result<()> {
|
||||||
info!("Setting up adr algorithms");
|
info!("Setting up adr algorithms");
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use std::sync::LazyLock;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use std::{
|
use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
@ -67,8 +68,7 @@ pub mod relay;
|
|||||||
pub mod tenant;
|
pub mod tenant;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
lazy_static! {
|
static GRPC_COUNTER: LazyLock<Family<GrpcLabels, Counter>> = LazyLock::new(|| {
|
||||||
static ref GRPC_COUNTER: Family<GrpcLabels, Counter> = {
|
|
||||||
let counter = Family::<GrpcLabels, Counter>::default();
|
let counter = Family::<GrpcLabels, Counter>::default();
|
||||||
prometheus::register(
|
prometheus::register(
|
||||||
"api_requests_handled",
|
"api_requests_handled",
|
||||||
@ -76,8 +76,8 @@ lazy_static! {
|
|||||||
counter.clone(),
|
counter.clone(),
|
||||||
);
|
);
|
||||||
counter
|
counter
|
||||||
};
|
});
|
||||||
static ref GRPC_HISTOGRAM: Family<GrpcLabels, Histogram> = {
|
static GRPC_HISTOGRAM: LazyLock<Family<GrpcLabels, Histogram>> = LazyLock::new(|| {
|
||||||
let histogram = Family::<GrpcLabels, Histogram>::new_with_constructor(|| {
|
let histogram = Family::<GrpcLabels, Histogram>::new_with_constructor(|| {
|
||||||
Histogram::new(
|
Histogram::new(
|
||||||
[
|
[
|
||||||
@ -92,8 +92,7 @@ lazy_static! {
|
|||||||
histogram.clone(),
|
histogram.clone(),
|
||||||
);
|
);
|
||||||
histogram
|
histogram
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(RustEmbed)]
|
#[derive(RustEmbed)]
|
||||||
#[folder = "../ui/build"]
|
#[folder = "../ui/build"]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::{Arc, LazyLock};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
@ -8,9 +8,8 @@ use crate::{config, stream};
|
|||||||
use backend::{Client, ClientConfig};
|
use backend::{Client, ClientConfig};
|
||||||
use lrwn::{EUI64Prefix, EUI64};
|
use lrwn::{EUI64Prefix, EUI64};
|
||||||
|
|
||||||
lazy_static! {
|
static CLIENTS: LazyLock<RwLock<Vec<(EUI64Prefix, Arc<Client>)>>> =
|
||||||
static ref CLIENTS: RwLock<Vec<(EUI64Prefix, Arc<Client>)>> = RwLock::new(vec![]);
|
LazyLock::new(|| RwLock::new(vec![]));
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn setup() -> Result<()> {
|
pub async fn setup() -> Result<()> {
|
||||||
info!("Setting up Join Server clients");
|
info!("Setting up Join Server clients");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::{Arc, LazyLock};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use chrono::{Duration, DurationRound};
|
use chrono::{Duration, DurationRound};
|
||||||
@ -15,9 +15,8 @@ use backend::{Client, ClientConfig, GWInfoElement, ULMetaData};
|
|||||||
use chirpstack_api::{common, gw};
|
use chirpstack_api::{common, gw};
|
||||||
use lrwn::{region, DevAddr, NetID, EUI64};
|
use lrwn::{region, DevAddr, NetID, EUI64};
|
||||||
|
|
||||||
lazy_static! {
|
static CLIENTS: LazyLock<RwLock<HashMap<NetID, Arc<Client>>>> =
|
||||||
static ref CLIENTS: RwLock<HashMap<NetID, Arc<Client>>> = RwLock::new(HashMap::new());
|
LazyLock::new(|| RwLock::new(HashMap::new()));
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn setup() -> Result<()> {
|
pub async fn setup() -> Result<()> {
|
||||||
info!("Setting up roaming clients");
|
info!("Setting up roaming clients");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, LazyLock, Mutex};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::{env, fs};
|
use std::{env, fs};
|
||||||
|
|
||||||
@ -9,9 +9,8 @@ use serde::{Deserialize, Serialize};
|
|||||||
use lrwn::region::CommonName;
|
use lrwn::region::CommonName;
|
||||||
use lrwn::{AES128Key, DevAddrPrefix, EUI64Prefix, NetID};
|
use lrwn::{AES128Key, DevAddrPrefix, EUI64Prefix, NetID};
|
||||||
|
|
||||||
lazy_static! {
|
static CONFIG: LazyLock<Mutex<Arc<Configuration>>> =
|
||||||
static ref CONFIG: Mutex<Arc<Configuration>> = Mutex::new(Arc::new(Default::default()));
|
LazyLock::new(|| Mutex::new(Arc::new(Default::default())));
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone)]
|
#[derive(Default, Serialize, Deserialize, Clone)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use aes::cipher::generic_array::GenericArray;
|
use aes::cipher::generic_array::GenericArray;
|
||||||
use aes::cipher::{BlockEncrypt, KeyInit};
|
use aes::cipher::{BlockEncrypt, KeyInit};
|
||||||
use aes::{Aes128, Block};
|
use aes::{Aes128, Block};
|
||||||
@ -7,14 +9,11 @@ use tracing::debug;
|
|||||||
|
|
||||||
use lrwn::DevAddr;
|
use lrwn::DevAddr;
|
||||||
|
|
||||||
lazy_static! {
|
static BEACON_PERIOD: LazyLock<Duration> = LazyLock::new(|| Duration::try_seconds(128).unwrap());
|
||||||
static ref BEACON_PERIOD: Duration = Duration::try_seconds(128).unwrap();
|
static BEACON_RESERVED: LazyLock<Duration> =
|
||||||
static ref BEACON_RESERVED: Duration = Duration::try_milliseconds(2120).unwrap();
|
LazyLock::new(|| Duration::try_milliseconds(2120).unwrap());
|
||||||
static ref BEACON_GUARD: Duration = Duration::try_seconds(3).unwrap();
|
static PING_PERIOD_BASE: usize = 1 << 12;
|
||||||
static ref BEACON_WINDOW: Duration = Duration::try_milliseconds(122880).unwrap();
|
static SLOT_LEN: LazyLock<Duration> = LazyLock::new(|| Duration::try_milliseconds(30).unwrap());
|
||||||
static ref PING_PERIOD_BASE: usize = 1 << 12;
|
|
||||||
static ref SLOT_LEN: Duration = Duration::try_milliseconds(30).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_beacon_start(ts: Duration) -> Duration {
|
pub fn get_beacon_start(ts: Duration) -> Duration {
|
||||||
Duration::try_seconds(ts.num_seconds() - (ts.num_seconds() % BEACON_PERIOD.num_seconds()))
|
Duration::try_seconds(ts.num_seconds() - (ts.num_seconds() % BEACON_PERIOD.num_seconds()))
|
||||||
@ -26,7 +25,7 @@ pub fn get_ping_offset(beacon_ts: Duration, dev_addr: &DevAddr, ping_nb: usize)
|
|||||||
return Err(anyhow!("ping_nb must be > 0"));
|
return Err(anyhow!("ping_nb must be > 0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let ping_period = *PING_PERIOD_BASE / ping_nb;
|
let ping_period = PING_PERIOD_BASE / ping_nb;
|
||||||
let beacon_time = (beacon_ts.num_seconds() % (1 << 32)) as u32;
|
let beacon_time = (beacon_ts.num_seconds() % (1 << 32)) as u32;
|
||||||
|
|
||||||
let key_bytes: [u8; 16] = [0x00; 16];
|
let key_bytes: [u8; 16] = [0x00; 16];
|
||||||
@ -54,7 +53,7 @@ pub fn get_next_ping_slot_after(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut beacon_start_ts = get_beacon_start(after_gps_epoch_ts);
|
let mut beacon_start_ts = get_beacon_start(after_gps_epoch_ts);
|
||||||
let ping_period = *PING_PERIOD_BASE / ping_nb;
|
let ping_period = PING_PERIOD_BASE / ping_nb;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let ping_offset = get_ping_offset(beacon_start_ts, dev_addr, ping_nb)?;
|
let ping_offset = get_ping_offset(beacon_start_ts, dev_addr, ping_nb)?;
|
||||||
@ -122,7 +121,7 @@ pub mod test {
|
|||||||
for k in 0..8 {
|
for k in 0..8 {
|
||||||
let mut beacon_ts = Duration::zero();
|
let mut beacon_ts = Duration::zero();
|
||||||
let ping_nb: usize = 1 << k;
|
let ping_nb: usize = 1 << k;
|
||||||
let ping_period = *PING_PERIOD_BASE / ping_nb;
|
let ping_period = PING_PERIOD_BASE / ping_nb;
|
||||||
let dev_addr = DevAddr::from_be_bytes([0, 0, 0, 0]);
|
let dev_addr = DevAddr::from_be_bytes([0, 0, 0, 0]);
|
||||||
|
|
||||||
for _ in 0..100000 {
|
for _ in 0..100000 {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
@ -6,11 +8,10 @@ use chirpstack_api::gw;
|
|||||||
|
|
||||||
use super::GatewayBackend;
|
use super::GatewayBackend;
|
||||||
|
|
||||||
lazy_static! {
|
static DOWNLINK_FRAMES: LazyLock<RwLock<Vec<gw::DownlinkFrame>>> =
|
||||||
static ref DOWNLINK_FRAMES: RwLock<Vec<gw::DownlinkFrame>> = RwLock::new(Vec::new());
|
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||||
static ref GATEWAY_CONFIGURATIONS: RwLock<Vec<gw::GatewayConfiguration>> =
|
static GATEWAY_CONFIGURATIONS: LazyLock<RwLock<Vec<gw::GatewayConfiguration>>> =
|
||||||
RwLock::new(Vec::new());
|
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn reset() {
|
pub async fn reset() {
|
||||||
DOWNLINK_FRAMES.write().await.drain(..);
|
DOWNLINK_FRAMES.write().await.drain(..);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -11,10 +12,8 @@ use crate::config;
|
|||||||
pub mod mock;
|
pub mod mock;
|
||||||
mod mqtt;
|
mod mqtt;
|
||||||
|
|
||||||
lazy_static! {
|
static BACKENDS: LazyLock<RwLock<HashMap<String, Box<dyn GatewayBackend + Sync + Send>>>> =
|
||||||
static ref BACKENDS: RwLock<HashMap<String, Box<dyn GatewayBackend + Sync + Send>>> =
|
LazyLock::new(|| RwLock::new(HashMap::new()));
|
||||||
RwLock::new(HashMap::new());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait GatewayBackend {
|
pub trait GatewayBackend {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::sync::RwLock;
|
use std::sync::{LazyLock, RwLock};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@ -38,8 +38,7 @@ struct CommandLabels {
|
|||||||
command: String,
|
command: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
static EVENT_COUNTER: LazyLock<Family<EventLabels, Counter>> = LazyLock::new(|| {
|
||||||
static ref EVENT_COUNTER: Family<EventLabels, Counter> = {
|
|
||||||
let counter = Family::<EventLabels, Counter>::default();
|
let counter = Family::<EventLabels, Counter>::default();
|
||||||
prometheus::register(
|
prometheus::register(
|
||||||
"gateway_backend_mqtt_events",
|
"gateway_backend_mqtt_events",
|
||||||
@ -47,8 +46,8 @@ lazy_static! {
|
|||||||
counter.clone(),
|
counter.clone(),
|
||||||
);
|
);
|
||||||
counter
|
counter
|
||||||
};
|
});
|
||||||
static ref COMMAND_COUNTER: Family<CommandLabels, Counter> = {
|
static COMMAND_COUNTER: LazyLock<Family<CommandLabels, Counter>> = LazyLock::new(|| {
|
||||||
let counter = Family::<CommandLabels, Counter>::default();
|
let counter = Family::<CommandLabels, Counter>::default();
|
||||||
prometheus::register(
|
prometheus::register(
|
||||||
"gateway_backend_mqtt_commands",
|
"gateway_backend_mqtt_commands",
|
||||||
@ -56,9 +55,9 @@ lazy_static! {
|
|||||||
counter.clone(),
|
counter.clone(),
|
||||||
);
|
);
|
||||||
counter
|
counter
|
||||||
};
|
});
|
||||||
static ref GATEWAY_JSON: RwLock<HashMap<String, bool>> = RwLock::new(HashMap::new());
|
static GATEWAY_JSON: LazyLock<RwLock<HashMap<String, bool>>> =
|
||||||
}
|
LazyLock::new(|| RwLock::new(HashMap::new()));
|
||||||
|
|
||||||
pub struct MqttBackend<'a> {
|
pub struct MqttBackend<'a> {
|
||||||
client: AsyncClient,
|
client: AsyncClient,
|
||||||
|
@ -1,82 +1,85 @@
|
|||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use chrono::{DateTime, Duration, TimeZone, Utc};
|
use chrono::{DateTime, Duration, TimeZone, Utc};
|
||||||
|
|
||||||
lazy_static! {
|
static GPS_EPOCH_TIME: LazyLock<DateTime<Utc>> =
|
||||||
static ref GPS_EPOCH_TIME: DateTime<Utc> = Utc.with_ymd_and_hms(1980, 1, 6, 0, 0, 0).unwrap();
|
LazyLock::new(|| Utc.with_ymd_and_hms(1980, 1, 6, 0, 0, 0).unwrap());
|
||||||
static ref LEAP_SECONDS_TABLE: Vec<(DateTime<Utc>, Duration)> = vec![
|
static LEAP_SECONDS_TABLE: LazyLock<Vec<(DateTime<Utc>, Duration)>> = LazyLock::new(|| {
|
||||||
|
vec![
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1981, 6, 30, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1981, 6, 30, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1982, 6, 30, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1982, 6, 30, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1983, 6, 30, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1983, 6, 30, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1985, 6, 30, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1985, 6, 30, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1987, 12, 31, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1987, 12, 31, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1989, 12, 31, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1989, 12, 31, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1990, 12, 31, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1990, 12, 31, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1992, 6, 30, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1992, 6, 30, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1993, 6, 30, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1993, 6, 30, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1994, 6, 30, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1994, 6, 30, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1995, 12, 31, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1995, 12, 31, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1997, 6, 30, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1997, 6, 30, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(1998, 12, 31, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(1998, 12, 31, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(2005, 12, 31, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(2005, 12, 31, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(2008, 12, 31, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(2008, 12, 31, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(2012, 6, 30, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(2012, 6, 30, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(2015, 6, 30, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(2015, 6, 30, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Utc.with_ymd_and_hms(2016, 12, 31, 23, 59, 59).unwrap(),
|
Utc.with_ymd_and_hms(2016, 12, 31, 23, 59, 59).unwrap(),
|
||||||
Duration::try_seconds(1).unwrap()
|
Duration::try_seconds(1).unwrap(),
|
||||||
),
|
),
|
||||||
];
|
]
|
||||||
}
|
});
|
||||||
|
|
||||||
pub trait ToGpsTime {
|
pub trait ToGpsTime {
|
||||||
fn to_gps_time(&self) -> Duration;
|
fn to_gps_time(&self) -> Duration;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -19,10 +20,8 @@ use chirpstack_api::integration;
|
|||||||
// implement re-connect on error. To reconnect within the Integration struct would require
|
// implement re-connect on error. To reconnect within the Integration struct would require
|
||||||
// mutability of the Integration struct, which is not possible without changing the
|
// mutability of the Integration struct, which is not possible without changing the
|
||||||
// IntegrationTrait as we would need to change the (&self, ...) signatures to (&mut self, ...).
|
// IntegrationTrait as we would need to change the (&self, ...) signatures to (&mut self, ...).
|
||||||
lazy_static! {
|
static CONNECTION: LazyLock<RwLock<Option<Connection>>> = LazyLock::new(|| RwLock::new(None));
|
||||||
static ref CONNECTION: RwLock<Option<Connection>> = RwLock::new(None);
|
static CHANNEL: LazyLock<RwLock<Option<Channel>>> = LazyLock::new(|| RwLock::new(None));
|
||||||
static ref CHANNEL: RwLock<Option<Channel>> = RwLock::new(None);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Integration<'a> {
|
pub struct Integration<'a> {
|
||||||
templates: Handlebars<'a>,
|
templates: Handlebars<'a>,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -8,17 +9,22 @@ use chirpstack_api::integration;
|
|||||||
|
|
||||||
use super::Integration as IntegrationTrait;
|
use super::Integration as IntegrationTrait;
|
||||||
|
|
||||||
lazy_static! {
|
static UPLINK_EVENTS: LazyLock<RwLock<Vec<integration::UplinkEvent>>> =
|
||||||
static ref UPLINK_EVENTS: RwLock<Vec<integration::UplinkEvent>> = RwLock::new(Vec::new());
|
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||||
static ref JOIN_EVENTS: RwLock<Vec<integration::JoinEvent>> = RwLock::new(Vec::new());
|
static JOIN_EVENTS: LazyLock<RwLock<Vec<integration::JoinEvent>>> =
|
||||||
static ref ACK_EVENTS: RwLock<Vec<integration::AckEvent>> = RwLock::new(Vec::new());
|
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||||
static ref TXACK_EVENTS: RwLock<Vec<integration::TxAckEvent>> = RwLock::new(Vec::new());
|
static ACK_EVENTS: LazyLock<RwLock<Vec<integration::AckEvent>>> =
|
||||||
static ref LOG_EVENTS: RwLock<Vec<integration::LogEvent>> = RwLock::new(Vec::new());
|
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||||
static ref STATUS_EVENTS: RwLock<Vec<integration::StatusEvent>> = RwLock::new(Vec::new());
|
static TXACK_EVENTS: LazyLock<RwLock<Vec<integration::TxAckEvent>>> =
|
||||||
static ref LOCATION_EVENTS: RwLock<Vec<integration::LocationEvent>> = RwLock::new(Vec::new());
|
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||||
static ref INTEGRATION_EVENTS: RwLock<Vec<integration::IntegrationEvent>> =
|
static LOG_EVENTS: LazyLock<RwLock<Vec<integration::LogEvent>>> =
|
||||||
RwLock::new(Vec::new());
|
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||||
}
|
static STATUS_EVENTS: LazyLock<RwLock<Vec<integration::StatusEvent>>> =
|
||||||
|
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||||
|
static LOCATION_EVENTS: LazyLock<RwLock<Vec<integration::LocationEvent>>> =
|
||||||
|
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||||
|
static INTEGRATION_EVENTS: LazyLock<RwLock<Vec<integration::IntegrationEvent>>> =
|
||||||
|
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||||
|
|
||||||
pub async fn reset() {
|
pub async fn reset() {
|
||||||
UPLINK_EVENTS.write().await.drain(..);
|
UPLINK_EVENTS.write().await.drain(..);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -33,11 +34,11 @@ mod postgresql;
|
|||||||
mod redis;
|
mod redis;
|
||||||
mod thingsboard;
|
mod thingsboard;
|
||||||
|
|
||||||
lazy_static! {
|
static GLOBAL_INTEGRATIONS: LazyLock<RwLock<Vec<Box<dyn Integration + Sync + Send>>>> =
|
||||||
static ref GLOBAL_INTEGRATIONS: RwLock<Vec<Box<dyn Integration + Sync + Send>>> =
|
LazyLock::new(|| RwLock::new(Vec::new()));
|
||||||
RwLock::new(Vec::new());
|
|
||||||
static ref MOCK_INTEGRATION: RwLock<bool> = RwLock::new(false);
|
#[cfg(test)]
|
||||||
}
|
static MOCK_INTEGRATION: LazyLock<RwLock<bool>> = LazyLock::new(|| RwLock::new(false));
|
||||||
|
|
||||||
pub async fn setup() -> Result<()> {
|
pub async fn setup() -> Result<()> {
|
||||||
info!("Setting up global integrations");
|
info!("Setting up global integrations");
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
extern crate diesel_migrations;
|
extern crate diesel_migrations;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate diesel;
|
extern crate diesel;
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
use std::sync::RwLock;
|
use std::sync::{LazyLock, RwLock};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use prometheus_client::encoding::text::encode;
|
use prometheus_client::encoding::text::encode;
|
||||||
use prometheus_client::registry::{Metric, Registry};
|
use prometheus_client::registry::{Metric, Registry};
|
||||||
|
|
||||||
lazy_static! {
|
static REGISTRY: LazyLock<RwLock<Registry>> = LazyLock::new(|| RwLock::new(<Registry>::default()));
|
||||||
static ref REGISTRY: RwLock<Registry> = RwLock::new(<Registry>::default());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn encode_to_string() -> Result<String> {
|
pub fn encode_to_string() -> Result<String> {
|
||||||
let registry_r = REGISTRY.read().unwrap();
|
let registry_r = REGISTRY.read().unwrap();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, LazyLock, RwLock};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use tracing::{info, span, trace, Level};
|
use tracing::{info, span, trace, Level};
|
||||||
@ -7,10 +7,8 @@ use tracing::{info, span, trace, Level};
|
|||||||
use crate::config;
|
use crate::config;
|
||||||
use lrwn::region;
|
use lrwn::region;
|
||||||
|
|
||||||
lazy_static! {
|
static REGIONS: LazyLock<RwLock<HashMap<String, Arc<Box<dyn region::Region + Sync + Send>>>>> =
|
||||||
static ref REGIONS: RwLock<HashMap<String, Arc<Box<dyn region::Region + Sync + Send>>>> =
|
LazyLock::new(|| RwLock::new(HashMap::new()));
|
||||||
RwLock::new(HashMap::new());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn setup() -> Result<()> {
|
pub fn setup() -> Result<()> {
|
||||||
info!("Setting up regions");
|
info!("Setting up regions");
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use std::sync::LazyLock;
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
@ -47,10 +48,10 @@ pub mod user;
|
|||||||
|
|
||||||
use crate::monitoring::prometheus;
|
use crate::monitoring::prometheus;
|
||||||
|
|
||||||
lazy_static! {
|
static ASYNC_REDIS_POOL: LazyLock<TokioRwLock<Option<AsyncRedisPool>>> =
|
||||||
static ref ASYNC_REDIS_POOL: TokioRwLock<Option<AsyncRedisPool>> = TokioRwLock::new(None);
|
LazyLock::new(|| TokioRwLock::new(None));
|
||||||
static ref REDIS_PREFIX: RwLock<String> = RwLock::new("".to_string());
|
static REDIS_PREFIX: LazyLock<RwLock<String>> = LazyLock::new(|| RwLock::new("".to_string()));
|
||||||
static ref STORAGE_REDIS_CONN_GET: Histogram = {
|
static STORAGE_REDIS_CONN_GET: LazyLock<Histogram> = LazyLock::new(|| {
|
||||||
let histogram = Histogram::new(exponential_buckets(0.001, 2.0, 12));
|
let histogram = Histogram::new(exponential_buckets(0.001, 2.0, 12));
|
||||||
prometheus::register(
|
prometheus::register(
|
||||||
"storage_redis_conn_get_duration_seconds",
|
"storage_redis_conn_get_duration_seconds",
|
||||||
@ -58,8 +59,7 @@ lazy_static! {
|
|||||||
histogram.clone(),
|
histogram.clone(),
|
||||||
);
|
);
|
||||||
histogram
|
histogram
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
#[cfg(feature = "postgres")]
|
||||||
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("./migrations_postgres");
|
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("./migrations_postgres");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::sync::RwLock;
|
use std::sync::{LazyLock, RwLock};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@ -20,9 +20,8 @@ use crate::helpers::tls::get_root_certs;
|
|||||||
pub type AsyncPgPool = DeadpoolPool<AsyncPgConnection>;
|
pub type AsyncPgPool = DeadpoolPool<AsyncPgConnection>;
|
||||||
pub type AsyncPgPoolConnection = DeadpoolObject<AsyncPgConnection>;
|
pub type AsyncPgPoolConnection = DeadpoolObject<AsyncPgConnection>;
|
||||||
|
|
||||||
lazy_static! {
|
static ASYNC_PG_POOL: LazyLock<RwLock<Option<AsyncPgPool>>> = LazyLock::new(|| RwLock::new(None));
|
||||||
static ref ASYNC_PG_POOL: RwLock<Option<AsyncPgPool>> = RwLock::new(None);
|
static STORAGE_PG_CONN_GET: LazyLock<Histogram> = LazyLock::new(|| {
|
||||||
static ref STORAGE_PG_CONN_GET: Histogram = {
|
|
||||||
let histogram = Histogram::new(exponential_buckets(0.001, 2.0, 12));
|
let histogram = Histogram::new(exponential_buckets(0.001, 2.0, 12));
|
||||||
prometheus::register(
|
prometheus::register(
|
||||||
"storage_pg_conn_get_duration_seconds",
|
"storage_pg_conn_get_duration_seconds",
|
||||||
@ -30,8 +29,7 @@ lazy_static! {
|
|||||||
histogram.clone(),
|
histogram.clone(),
|
||||||
);
|
);
|
||||||
histogram
|
histogram
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
pub fn setup(conf: &config::Postgresql) -> Result<()> {
|
pub fn setup(conf: &config::Postgresql) -> Result<()> {
|
||||||
info!("Setting up PostgreSQL connection pool");
|
info!("Setting up PostgreSQL connection pool");
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
@ -8,9 +9,7 @@ use uuid::Uuid;
|
|||||||
use super::{error::Error, fields, get_async_db_conn};
|
use super::{error::Error, fields, get_async_db_conn};
|
||||||
use lrwn::EUI64;
|
use lrwn::EUI64;
|
||||||
|
|
||||||
lazy_static! {
|
static SEARCH_TAG_RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"([^ ]+):([^ ]+)").unwrap());
|
||||||
static ref SEARCH_TAG_RE: Regex = Regex::new(r"([^ ]+):([^ ]+)").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(QueryableByName, PartialEq, Debug)]
|
#[derive(QueryableByName, PartialEq, Debug)]
|
||||||
pub struct SearchResult {
|
pub struct SearchResult {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::sync::RwLock;
|
use std::sync::{LazyLock, RwLock};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@ -19,9 +19,9 @@ use crate::config;
|
|||||||
pub type AsyncSqlitePool = DeadpoolPool<SyncConnectionWrapper<SqliteConnection>>;
|
pub type AsyncSqlitePool = DeadpoolPool<SyncConnectionWrapper<SqliteConnection>>;
|
||||||
pub type AsyncSqlitePoolConnection = DeadpoolObject<SyncConnectionWrapper<SqliteConnection>>;
|
pub type AsyncSqlitePoolConnection = DeadpoolObject<SyncConnectionWrapper<SqliteConnection>>;
|
||||||
|
|
||||||
lazy_static! {
|
static ASYNC_SQLITE_POOL: LazyLock<RwLock<Option<AsyncSqlitePool>>> =
|
||||||
static ref ASYNC_SQLITE_POOL: RwLock<Option<AsyncSqlitePool>> = RwLock::new(None);
|
LazyLock::new(|| RwLock::new(None));
|
||||||
static ref STORAGE_SQLITE_CONN_GET: Histogram = {
|
static STORAGE_SQLITE_CONN_GET: LazyLock<Histogram> = LazyLock::new(|| {
|
||||||
let histogram = Histogram::new(exponential_buckets(0.001, 2.0, 12));
|
let histogram = Histogram::new(exponential_buckets(0.001, 2.0, 12));
|
||||||
prometheus::register(
|
prometheus::register(
|
||||||
"storage_sqlite_conn_get_duration_seconds",
|
"storage_sqlite_conn_get_duration_seconds",
|
||||||
@ -29,8 +29,7 @@ lazy_static! {
|
|||||||
histogram.clone(),
|
histogram.clone(),
|
||||||
);
|
);
|
||||||
histogram
|
histogram
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
pub fn setup(conf: &config::Sqlite) -> Result<()> {
|
pub fn setup(conf: &config::Sqlite) -> Result<()> {
|
||||||
info!("Setting up SQLite connection pool");
|
info!("Setting up SQLite connection pool");
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
use std::sync::LazyLock;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
@ -17,9 +18,7 @@ use crate::storage::{
|
|||||||
use chirpstack_api::{gw, integration as integration_pb, internal, stream};
|
use chirpstack_api::{gw, integration as integration_pb, internal, stream};
|
||||||
use lrwn::EUI64;
|
use lrwn::EUI64;
|
||||||
|
|
||||||
lazy_static! {
|
static LAST_DOWNLINK_ID: LazyLock<RwLock<u32>> = LazyLock::new(|| RwLock::new(0));
|
||||||
static ref LAST_DOWNLINK_ID: RwLock<u32> = RwLock::new(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type Validator = Box<dyn Fn() -> Pin<Box<dyn Future<Output = ()>>>>;
|
pub type Validator = Box<dyn Fn() -> Pin<Box<dyn Future<Output = ()>>>>;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::sync::{Mutex, Once};
|
use std::sync::{LazyLock, Mutex, Once};
|
||||||
|
|
||||||
use crate::{adr, config, region, storage};
|
use crate::{adr, config, region, storage};
|
||||||
|
|
||||||
@ -17,9 +17,7 @@ mod relay_otaa_test;
|
|||||||
|
|
||||||
static TRACING_INIT: Once = Once::new();
|
static TRACING_INIT: Once = Once::new();
|
||||||
|
|
||||||
lazy_static! {
|
static TEST_MUX: LazyLock<Mutex<()>> = LazyLock::new(|| Mutex::new(()));
|
||||||
static ref TEST_MUX: Mutex<()> = Mutex::new(());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn prepare<'a>() -> std::sync::MutexGuard<'a, ()> {
|
pub async fn prepare<'a>() -> std::sync::MutexGuard<'a, ()> {
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
|
@ -2,6 +2,7 @@ use std::collections::HashMap;
|
|||||||
use std::convert::{TryFrom, TryInto};
|
use std::convert::{TryFrom, TryInto};
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use std::sync::LazyLock;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
@ -41,8 +42,7 @@ struct UplinkLabels {
|
|||||||
m_type: String,
|
m_type: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
static UPLINK_COUNTER: LazyLock<Family<UplinkLabels, Counter>> = LazyLock::new(|| {
|
||||||
static ref UPLINK_COUNTER: Family<UplinkLabels, Counter> = {
|
|
||||||
let counter = Family::<UplinkLabels, Counter>::default();
|
let counter = Family::<UplinkLabels, Counter>::default();
|
||||||
prometheus::register(
|
prometheus::register(
|
||||||
"uplink_count",
|
"uplink_count",
|
||||||
@ -50,8 +50,8 @@ lazy_static! {
|
|||||||
counter.clone(),
|
counter.clone(),
|
||||||
);
|
);
|
||||||
counter
|
counter
|
||||||
};
|
});
|
||||||
static ref DEDUPLICATE_LOCKED_COUNTER: Counter = {
|
static DEDUPLICATE_LOCKED_COUNTER: LazyLock<Counter> = LazyLock::new(|| {
|
||||||
let counter = Counter::default();
|
let counter = Counter::default();
|
||||||
prometheus::register(
|
prometheus::register(
|
||||||
"deduplicate_locked_count",
|
"deduplicate_locked_count",
|
||||||
@ -59,8 +59,8 @@ lazy_static! {
|
|||||||
counter.clone(),
|
counter.clone(),
|
||||||
);
|
);
|
||||||
counter
|
counter
|
||||||
};
|
});
|
||||||
static ref DEDUPLICATE_NO_LOCK_COUNTER: Counter = {
|
static DEDUPLICATE_NO_LOCK_COUNTER: LazyLock<Counter> = LazyLock::new(|| {
|
||||||
let counter = Counter::default();
|
let counter = Counter::default();
|
||||||
prometheus::register(
|
prometheus::register(
|
||||||
"deduplicate_no_lock_count",
|
"deduplicate_no_lock_count",
|
||||||
@ -68,8 +68,7 @@ lazy_static! {
|
|||||||
counter.clone(),
|
counter.clone(),
|
||||||
);
|
);
|
||||||
counter
|
counter
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct RelayContext {
|
pub struct RelayContext {
|
||||||
|
Reference in New Issue
Block a user