Prevent race conditions
- This is a massive cope, I don't know how to code Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
15
src/main.rs
15
src/main.rs
@@ -5,15 +5,18 @@ mod config;
|
||||
mod data;
|
||||
mod database;
|
||||
mod routes;
|
||||
mod state;
|
||||
mod types;
|
||||
mod utils;
|
||||
|
||||
use crate::utils::cleanup;
|
||||
use config::Config;
|
||||
use dotenv::dotenv;
|
||||
use log4rs::config::Deserializers;
|
||||
use state::BroadcastMessage;
|
||||
use std::error::Error;
|
||||
use tokio::{spawn, sync::broadcast};
|
||||
use types::{BroadcastMessage, Class};
|
||||
use types::Class;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
@@ -22,21 +25,23 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
let app_config = Config::arc_from_env();
|
||||
let mut threads = Vec::new();
|
||||
|
||||
let (broadcast_sender, _) = broadcast::channel::<BroadcastMessage>(100);
|
||||
cleanup(&app_config.clickhouse_client).await;
|
||||
|
||||
let (broadcast_bus, _) = broadcast::channel::<BroadcastMessage>(100);
|
||||
|
||||
threads.push(spawn(data::market::run(
|
||||
app_config.clone(),
|
||||
Class::UsEquity,
|
||||
broadcast_sender.clone(),
|
||||
broadcast_bus.clone(),
|
||||
)));
|
||||
|
||||
threads.push(spawn(data::market::run(
|
||||
app_config.clone(),
|
||||
Class::Crypto,
|
||||
broadcast_sender.clone(),
|
||||
broadcast_bus.clone(),
|
||||
)));
|
||||
|
||||
threads.push(spawn(routes::run(app_config.clone(), broadcast_sender)));
|
||||
threads.push(spawn(routes::run(app_config.clone(), broadcast_bus)));
|
||||
|
||||
for thread in threads {
|
||||
thread.await?;
|
||||
|
Reference in New Issue
Block a user