remove src/lib.rs

This commit is contained in:
Charles Hall 2024-04-27 21:08:22 -07:00
parent 0f7b6d482c
commit c097e79e52
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
3 changed files with 32 additions and 37 deletions

View file

@ -128,14 +128,6 @@ jemalloc = ["tikv-jemalloc-ctl", "tikv-jemallocator"]
sqlite = ["rusqlite", "parking_lot", "tokio/signal"]
systemd = ["sd-notify"]
[[bin]]
name = "conduit"
path = "src/main.rs"
[lib]
name = "conduit"
path = "src/lib.rs"
[package.metadata.deb]
name = "matrix-conduit"
maintainer = "Paul van Tilburg <paul@luon.net>"

View file

@ -1,26 +0,0 @@
pub mod api;
pub mod clap;
mod config;
mod database;
mod service;
mod utils;
// Not async due to services() being used in many closures, and async closures are not stable as of writing
// This is the case for every other occurence of sync Mutex/RwLock, except for database related ones, where
// the current maintainer (Timo) has asked to not modify those
use std::sync::RwLock;
pub use api::ruma_wrapper::{Ruma, RumaResponse};
pub use config::Config;
pub use database::KeyValueDatabase;
pub use service::{pdu::PduEvent, Services};
pub use utils::error::{Error, Result};
pub static SERVICES: RwLock<Option<&'static Services>> = RwLock::new(None);
pub fn services() -> &'static Services {
SERVICES
.read()
.unwrap()
.expect("SERVICES should be initialized when this is called")
}

View file

@ -1,4 +1,10 @@
use std::{future::Future, io, net::SocketAddr, sync::atomic, time::Duration};
use std::{
future::Future,
io,
net::SocketAddr,
sync::{atomic, RwLock},
time::Duration,
};
use axum::{
extract::{DefaultBodyLimit, FromRequestParts, MatchedPath},
@ -7,7 +13,6 @@ use axum::{
Router,
};
use axum_server::{bind, bind_rustls, tls_rustls::RustlsConfig, Handle as ServerHandle};
use conduit::api::{client_server, server_server};
use figment::{
providers::{Env, Format, Toml},
Figment,
@ -33,7 +38,19 @@ use tower_http::{
use tracing::{debug, error, info, warn};
use tracing_subscriber::{prelude::*, EnvFilter};
pub use conduit::*; // Re-export everything from the library crate
pub mod api;
pub mod clap;
mod config;
mod database;
mod service;
mod utils;
pub use api::ruma_wrapper::{Ruma, RumaResponse};
use api::{client_server, server_server};
pub use config::Config;
pub use database::KeyValueDatabase;
pub use service::{pdu::PduEvent, Services};
pub use utils::error::{Error, Result};
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
use tikv_jemallocator::Jemalloc;
@ -42,6 +59,18 @@ use tikv_jemallocator::Jemalloc;
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
pub static SERVICES: RwLock<Option<&'static Services>> = RwLock::new(None);
// Not async due to services() being used in many closures, and async closures are not stable as of writing
// This is the case for every other occurence of sync Mutex/RwLock, except for database related ones, where
// the current maintainer (Timo) has asked to not modify those
pub fn services() -> &'static Services {
SERVICES
.read()
.unwrap()
.expect("SERVICES should be initialized when this is called")
}
#[tokio::main]
async fn main() {
clap::parse();