beteran-backend-server-edge/src/main.rs

83 lines
3.0 KiB
Rust

use std::env;
mod bank;
mod identity;
mod member;
mod member_bank_account;
mod member_bank_deposit;
mod member_bank_withdraw;
mod member_class;
mod member_game_setting;
mod member_level;
mod member_referrer;
mod member_settlement_setting;
mod site;
mod api;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let url_broker = match env::var_os("URL_BROKER") {
Some(v) => v.into_string().unwrap(),
None => "".to_string(),
};
let queue_broker = match env::var_os("QUEUE_BROKER") {
Some(v) => v.into_string().unwrap(),
None => "".to_string(),
};
let broker_opts = nats::asynk::Options::new();
let connection_broker = broker_opts.connect(url_broker).await?;
let bank_service = bank::service::Service::new(connection_broker.clone(), queue_broker.clone());
let identity_service =
identity::service::Service::new(connection_broker.clone(), queue_broker.clone());
let member_service =
member::service::Service::new(connection_broker.clone(), queue_broker.clone());
let member_bank_account_service =
member_bank_account::service::Service::new(connection_broker.clone(), queue_broker.clone());
let member_bank_deposit_service =
member_bank_deposit::service::Service::new(connection_broker.clone(), queue_broker.clone());
let member_bank_withdraw_service =
member_bank_withdraw::service::Service::new(connection_broker.clone(), queue_broker.clone());
let member_class_service =
member_class::service::Service::new(connection_broker.clone(), queue_broker.clone());
let member_game_setting_service =
member_game_setting::service::Service::new(connection_broker.clone(), queue_broker.clone());
let member_level_service =
member_level::service::Service::new(connection_broker.clone(), queue_broker.clone());
let member_referrer_service =
member_referrer::service::Service::new(connection_broker.clone(), queue_broker.clone());
let member_settlement_setting_service = member_settlement_setting::service::Service::new(
connection_broker.clone(),
queue_broker.clone(),
);
let site_service = site::service::Service::new(connection_broker.clone(), queue_broker.clone());
let api_vendor_service =
api::vendor::service::Service::new(connection_broker.clone(), queue_broker.clone());
let api_game_service =
api::game::service::Service::new(connection_broker.clone(), queue_broker.clone());
println!("Server edge[beteran-backend-server-edge] is started");
futures::try_join!(
bank_service.subscribe(),
identity_service.subscribe(),
member_service.subscribe(),
member_bank_account_service.subscribe(),
member_bank_deposit_service.subscribe(),
member_bank_withdraw_service.subscribe(),
member_class_service.subscribe(),
member_game_setting_service.subscribe(),
member_level_service.subscribe(),
member_referrer_service.subscribe(),
member_settlement_setting_service.subscribe(),
site_service.subscribe(),
api_vendor_service.subscribe(),
api_game_service.subscribe(),
)?;
Ok(())
}