mirror of https://git.42l.fr/neil/sncf.git
adding feature flags
This commit is contained in:
parent
a69642ac11
commit
cab8136e1e
28
src/main.rs
28
src/main.rs
|
@ -26,9 +26,28 @@ mod forward;
|
|||
mod sniff;
|
||||
mod templates;
|
||||
|
||||
type DbPool = r2d2::Pool<ConnectionManager<SqliteConnection>>;
|
||||
// default to postgres
|
||||
#[cfg(feature = "default")]
|
||||
type DbConn = PgConnection;
|
||||
#[cfg(feature = "default")]
|
||||
embed_migrations!("migrations/postgres");
|
||||
|
||||
embed_migrations!();
|
||||
#[cfg(feature = "postgres")]
|
||||
type DbConn = PgConnection;
|
||||
#[cfg(feature = "postgres")]
|
||||
embed_migrations!("migrations/postgres");
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
type DbConn = SqliteConnection;
|
||||
#[cfg(feature = "sqlite")]
|
||||
embed_migrations!("migrations/sqlite");
|
||||
|
||||
#[cfg(feature = "mysql")]
|
||||
type DbConn = MysqlConnection;
|
||||
#[cfg(feature = "mysql")]
|
||||
embed_migrations!("migrations/mysql");
|
||||
|
||||
type DbPool = r2d2::Pool<ConnectionManager<DbConn>>;
|
||||
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
|
@ -40,8 +59,11 @@ async fn main() -> std::io::Result<()> {
|
|||
println!("Checking configuration file...");
|
||||
CONFIG.check_version();
|
||||
|
||||
if CONFIG.database_path.len() == 0 {
|
||||
println!("No database specified. Please enter a MySQL, PostgreSQL or SQLite connection string in config.toml.");
|
||||
}
|
||||
println!("Opening database {}", CONFIG.database_path);
|
||||
let manager = ConnectionManager::<SqliteConnection>::new(&CONFIG.database_path);
|
||||
let manager = ConnectionManager::<DbConn>::new(&CONFIG.database_path);
|
||||
let pool = r2d2::Pool::builder()
|
||||
.build(manager)
|
||||
.expect("ERROR: main: Failed to create the database pool.");
|
||||
|
|
Loading…
Reference in New Issue