mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
hide global services jank in service module
Mainly to make it easier to initialize the SERVICES global correctly in more than one place. Also this stuff really shouldn't live at the crate root anyway.
This commit is contained in:
parent
1fd20cdeba
commit
032e1ca3c6
3 changed files with 22 additions and 20 deletions
15
src/main.rs
15
src/main.rs
|
|
@ -2,7 +2,7 @@
|
|||
// work anyway
|
||||
#![cfg_attr(not(any(feature = "sqlite", feature = "rocksdb")), allow(unused))]
|
||||
|
||||
use std::{process::ExitCode, sync::RwLock};
|
||||
use std::process::ExitCode;
|
||||
|
||||
use clap::Parser;
|
||||
use tracing::error;
|
||||
|
|
@ -18,7 +18,7 @@ mod utils;
|
|||
|
||||
pub(crate) use api::ruma_wrapper::{Ar, Ra};
|
||||
pub(crate) use config::Config;
|
||||
pub(crate) use service::{pdu::PduEvent, Services};
|
||||
pub(crate) use service::{pdu::PduEvent, services, Services};
|
||||
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
|
||||
use tikv_jemallocator::Jemalloc;
|
||||
pub(crate) use utils::error::{Error, Result};
|
||||
|
|
@ -27,17 +27,6 @@ pub(crate) use utils::error::{Error, Result};
|
|||
#[global_allocator]
|
||||
static GLOBAL: Jemalloc = Jemalloc;
|
||||
|
||||
pub(crate) static SERVICES: RwLock<Option<&'static Services>> =
|
||||
RwLock::new(None);
|
||||
|
||||
/// Convenient access to the global [`Services`] instance
|
||||
pub(crate) fn services() -> &'static Services {
|
||||
SERVICES
|
||||
.read()
|
||||
.unwrap()
|
||||
.expect("SERVICES should be initialized when this is called")
|
||||
}
|
||||
|
||||
/// Returns the current version of the crate with extra info if supplied
|
||||
///
|
||||
/// Set the environment variable `GRAPEVINE_VERSION_EXTRA` to any UTF-8 string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue