File tree Expand file tree Collapse file tree 7 files changed +21
-0
lines changed
Expand file tree Collapse file tree 7 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 11target
22.DS_Store
3+ .env
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ tokio-postgres = "0.7"
2424
2525[dev-dependencies ]
2626chrono = " 0.4"
27+ dotenvy = " 0.15"
2728macrotest = " 1.1"
2829serial_test = " 3.2"
2930tokio = { version = " 1.43" , features = [" full" ] }
Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ mod bucket_size {
1717use bucket_size:: * ;
1818
1919static DB_POOL : std:: sync:: LazyLock < std:: sync:: Arc < deadpool_postgres:: Pool > > = std:: sync:: LazyLock :: new ( || {
20+ if std:: path:: Path :: new ( ".env" ) . exists ( ) {
21+ dotenvy:: dotenv ( ) . unwrap ( ) ;
22+ }
2023 let url = std:: env:: var ( "DATABASE_URL" ) . unwrap_or ( "postgresql://localhost:5432/postgres" . to_string ( ) ) ;
2124 let pg_config = tokio_postgres:: Config :: from_str ( & url) . unwrap ( ) ;
2225 let mgr_config = deadpool_postgres:: ManagerConfig { recycling_method : deadpool_postgres:: RecyclingMethod :: Fast } ;
Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ mod comparison {
1818use comparison:: * ;
1919
2020static DB_POOL : std:: sync:: LazyLock < std:: sync:: Arc < deadpool_postgres:: Pool > > = std:: sync:: LazyLock :: new ( || {
21+ if std:: path:: Path :: new ( ".env" ) . exists ( ) {
22+ dotenvy:: dotenv ( ) . unwrap ( ) ;
23+ }
2124 let url = std:: env:: var ( "DATABASE_URL" ) . unwrap_or ( "postgresql://localhost:5432/postgres" . to_string ( ) ) ;
2225 let pg_config = tokio_postgres:: Config :: from_str ( & url) . unwrap ( ) ;
2326 let mgr_config = deadpool_postgres:: ManagerConfig { recycling_method : deadpool_postgres:: RecyclingMethod :: Fast } ;
Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ mod float {
1717use float:: * ;
1818
1919static DB_POOL : std:: sync:: LazyLock < std:: sync:: Arc < deadpool_postgres:: Pool > > = std:: sync:: LazyLock :: new ( || {
20+ if std:: path:: Path :: new ( ".env" ) . exists ( ) {
21+ dotenvy:: dotenv ( ) . unwrap ( ) ;
22+ }
2023 let url = std:: env:: var ( "DATABASE_URL" ) . unwrap_or ( "postgresql://localhost:5432/postgres" . to_string ( ) ) ;
2124 let pg_config = tokio_postgres:: Config :: from_str ( & url) . unwrap ( ) ;
2225 let mgr_config = deadpool_postgres:: ManagerConfig { recycling_method : deadpool_postgres:: RecyclingMethod :: Fast } ;
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ fn macrotest() {
1111}
1212
1313pub static DB_POOL : std:: sync:: LazyLock < std:: sync:: Arc < deadpool_postgres:: Pool > > = std:: sync:: LazyLock :: new ( || {
14+ if std:: path:: Path :: new ( ".env" ) . exists ( ) {
15+ dotenvy:: dotenv ( ) . unwrap ( ) ;
16+ }
1417 let url = std:: env:: var ( "DATABASE_URL" ) . unwrap_or ( "postgresql://localhost:5432/postgres" . to_string ( ) ) ;
1518 let pg_config = tokio_postgres:: Config :: from_str ( & url) . unwrap ( ) ;
1619 let mgr_config = deadpool_postgres:: ManagerConfig { recycling_method : deadpool_postgres:: RecyclingMethod :: Fast } ;
You can’t perform that action at this time.
0 commit comments