@@ -5,15 +5,21 @@ use tokio::sync::Mutex;
55use uuid:: Uuid ;
66use crate :: config:: SERVER_CONFIG ;
77use crate :: database:: memory:: MemoryDB ;
8+ #[ cfg( feature = "mysql" ) ]
89use crate :: database:: mysql:: MySql ;
910use crate :: database:: none:: NoneDB ;
11+ #[ cfg( feature = "postgres" ) ]
1012use crate :: database:: postgres:: Postgres ;
13+ #[ cfg( feature = "sqlite" ) ]
1114use crate :: database:: sqlite:: SQLite ;
1215use crate :: results:: TelemetryData ;
1316
17+ #[ cfg( feature = "mysql" ) ]
1418mod mysql;
1519mod none;
20+ #[ cfg( feature = "postgres" ) ]
1621mod postgres;
22+ #[ cfg( feature = "sqlite" ) ]
1723mod sqlite;
1824mod memory;
1925
@@ -34,16 +40,19 @@ pub fn generate_uuid () -> String {
3440pub fn init ( ) -> std:: io:: Result < Arc < Mutex < dyn Database + Send > > > {
3541 let config = SERVER_CONFIG . get ( ) . unwrap ( ) ;
3642 match config. database_type . as_str ( ) {
43+ #[ cfg( feature = "mysql" ) ]
3744 "mysql" => {
3845 let mysql_setup = mysql:: init ( & config. database_username , & config. database_password , & config. database_hostname , & config. database_name ) ?;
3946 info ! ( "Database {} initialized successfully" , "Mysql" ) ;
4047 Ok ( Arc :: new ( Mutex :: new ( MySql { connection : mysql_setup} ) ) )
4148 }
49+ #[ cfg( feature = "postgres" ) ]
4250 "postgres" => {
4351 let postgres_setup = postgres:: init ( & config. database_username , & config. database_password , & config. database_hostname , & config. database_name ) ?;
4452 info ! ( "Database {} initialized successfully" , "Postgres" ) ;
4553 Ok ( Arc :: new ( Mutex :: new ( Postgres { connection : postgres_setup} ) ) )
4654 }
55+ #[ cfg( feature = "sqlite" ) ]
4756 "sqlite" => {
4857 let sqlite_setup = sqlite:: init ( & config. database_file ) ?;
4958 info ! ( "Database {} initialized successfully" , "Sqlite" ) ;
0 commit comments