Skip to content
Snippets Groups Projects
Commit d0646eb5 authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon:
Browse files

chore: remove lazy-static from dependencies

lazy-static crate is deprecated and is only used in 2 places, where it
can be easily replaced with something simpler.
parent f4becf3c
No related branches found
No related tags found
1 merge request!445chore: remove lazy-static from dependencies
......@@ -808,7 +808,6 @@ dependencies = [
"futures",
"indoc",
"inventory",
"lazy_static",
"libc",
"linkme",
"nix 0.23.2",
......
......@@ -22,7 +22,6 @@ thiserror = "1.0"
indoc = "1.0"
nix = "0.23.1"
base64 = "0.13"
lazy_static = "1.4"
uuid = {version = "1.0", features = ["v3"]}
linkme = "0.2.10"
futures = "0.3.25"
......
......@@ -372,27 +372,30 @@ pub trait ContextCoercion: Serialize + DeserializeOwned {
}
///////////////////////////////////////////////////////////////////////////////
lazy_static::lazy_static! {
static ref NAMESPACE_INSTANCE_UUID: Uuid =
Uuid::new_v3(&Uuid::nil(), "INSTANCE_UUID".as_bytes());
static ref NAMESPACE_REPLICASET_UUID: Uuid =
Uuid::new_v3(&Uuid::nil(), "REPLICASET_UUID".as_bytes());
}
/// Generate UUID for an instance from `instance_id` (String).
/// Use Version-3 (MD5) UUID.
pub fn instance_uuid(instance_id: &str) -> String {
let uuid = Uuid::new_v3(&NAMESPACE_INSTANCE_UUID, instance_id.as_bytes());
static mut NAMESPACE_INSTANCE_UUID: Option<Uuid> = None;
let ns = unsafe { NAMESPACE_INSTANCE_UUID.get_or_insert_with(|| uuid_v3("INSTANCE_UUID")) };
let uuid = Uuid::new_v3(ns, instance_id.as_bytes());
uuid.hyphenated().to_string()
}
/// Generate UUID for a replicaset from `replicaset_id` (String).
/// Use Version-3 (MD5) UUID.
pub fn replicaset_uuid(replicaset_id: &str) -> String {
let uuid = Uuid::new_v3(&NAMESPACE_REPLICASET_UUID, replicaset_id.as_bytes());
static mut NAMESPACE_REPLICASET_UUID: Option<Uuid> = None;
let ns = unsafe { NAMESPACE_REPLICASET_UUID.get_or_insert_with(|| uuid_v3("REPLICASET_UUID")) };
let uuid = Uuid::new_v3(ns, replicaset_id.as_bytes());
uuid.hyphenated().to_string()
}
#[inline(always)]
fn uuid_v3(name: &str) -> Uuid {
Uuid::new_v3(&Uuid::nil(), name.as_bytes())
}
////////////////////////////////////////////////////////////////////////////////
/// Migration
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment