rename telemetry mod to http

This commit is contained in:
Nikita Vilunov 2023-10-01 01:50:04 +02:00
parent dc0a101fe6
commit 2f034284cf
4 changed files with 14 additions and 27 deletions

View File

@ -31,7 +31,7 @@ pub async fn launch(
rooms: RoomRegistry, rooms: RoomRegistry,
storage: Storage, storage: Storage,
) -> Result<Terminator> { ) -> Result<Terminator> {
log::info!("Starting the telemetry service"); log::info!("Starting the http service");
let listener = TcpListener::bind(config.listen_on).await?; let listener = TcpListener::bind(config.listen_on).await?;
log::debug!("Listener started"); log::debug!("Listener started");
let terminator = Terminator::spawn(|rx| main_loop(listener, metrics, rooms, storage, rx.map(|_| ()))); let terminator = Terminator::spawn(|rx| main_loop(listener, metrics, rooms, storage, rx.map(|_| ())));
@ -67,7 +67,7 @@ async fn main_loop(
}, },
} }
} }
log::info!("Terminating the telemetry service"); log::info!("Terminating the http service");
Ok(()) Ok(())
} }

View File

@ -1,4 +1,4 @@
mod util; mod http;
use std::future::Future; use std::future::Future;
use std::path::Path; use std::path::Path;
@ -16,7 +16,7 @@ use lavina_core::room::RoomRegistry;
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
struct ServerConfig { struct ServerConfig {
telemetry: util::telemetry::ServerConfig, telemetry: http::ServerConfig,
irc: projection_irc::ServerConfig, irc: projection_irc::ServerConfig,
xmpp: projection_xmpp::ServerConfig, xmpp: projection_xmpp::ServerConfig,
storage: lavina_core::repo::StorageConfig, storage: lavina_core::repo::StorageConfig,
@ -25,7 +25,7 @@ struct ServerConfig {
#[derive(Parser)] #[derive(Parser)]
struct CliArgs { struct CliArgs {
#[arg(long)] #[arg(long)]
config: Box<Path>, config: Box<Path>,
} }
fn load_config() -> Result<ServerConfig> { fn load_config() -> Result<ServerConfig> {
@ -53,9 +53,15 @@ async fn main() -> Result<()> {
let storage = Storage::open(storage_config).await?; let storage = Storage::open(storage_config).await?;
let rooms = RoomRegistry::new(&mut metrics, storage.clone())?; let rooms = RoomRegistry::new(&mut metrics, storage.clone())?;
let mut players = PlayerRegistry::empty(rooms.clone(), &mut metrics)?; let mut players = PlayerRegistry::empty(rooms.clone(), &mut metrics)?;
let telemetry_terminator = let telemetry_terminator = http::launch(telemetry_config, metrics.clone(), rooms.clone(), storage.clone()).await?;
util::telemetry::launch(telemetry_config, metrics.clone(), rooms.clone(), storage.clone()).await?; let irc = projection_irc::launch(
let irc = projection_irc::launch(irc_config, players.clone(), rooms.clone(), metrics.clone(), storage.clone()).await?; irc_config,
players.clone(),
rooms.clone(),
metrics.clone(),
storage.clone(),
)
.await?;
let xmpp = projection_xmpp::launch(xmpp_config, players.clone(), rooms.clone(), metrics.clone()).await?; let xmpp = projection_xmpp::launch(xmpp_config, players.clone(), rooms.clone(), metrics.clone()).await?;
tracing::info!("Started"); tracing::info!("Started");

View File

@ -1,3 +0,0 @@
pub mod telemetry;
#[cfg(test)]
pub mod testkit;

View File

@ -1,16 +0,0 @@
use std::task::{Context, Poll};
use futures_util::task::noop_waker_ref;
use lavina_core::prelude::*;
pub fn sync_future<T>(future: impl Future<Output = T>) -> Result<T> {
let waker = noop_waker_ref();
let mut context = Context::from_waker(waker);
pin!(future);
if let Poll::Ready(a) = future.poll(&mut context) {
Ok(a)
} else {
Err(anyhow::Error::msg("Future has suspended"))
}
}