server/src/main.rs

48 lines
1.3 KiB
Rust

#![doc = include_str!("../README.md")]
extern crate core;
mod cli;
mod ingest_protocol;
mod ingest_socket_server;
mod utils;
mod web_server;
use clap::Parser;
use cli::{Cli, MyCommand};
use fred::{
clients::RedisClient,
prelude::ClientLike,
types::{
ConnectionConfig, PerformanceConfig, ReconnectPolicy, RedisConfig, Server, ServerConfig,
},
};
use ingest_socket_server::socketserv_main;
use crate::web_server::server_main;
#[ntex::main]
async fn main() {
let result = Cli::parse();
let mut config = RedisConfig::default();
config.server = ServerConfig::Centralized {
server: Server::new(result.redis_host.clone(), result.redis_port.clone()),
};
let perf = PerformanceConfig::default();
let policy = ReconnectPolicy::default();
let connection_config = ConnectionConfig::default();
let redis = RedisClient::new(config, Some(perf), Some(connection_config), Some(policy));
redis.init().await.unwrap();
match &result.command {
MyCommand::WebServer(specific_args) => {
server_main(result.clone(), specific_args.clone(), redis).await;
}
MyCommand::SocketServer(specific_args) => {
socketserv_main(result.clone(), specific_args.clone(), redis).await;
}
};
}