@@ -5,7 +5,6 @@ use std::sync::{Arc, Mutex};
5
5
use std:: time:: Duration ;
6
6
use tokio:: sync:: { OwnedSemaphorePermit , Semaphore } ;
7
7
8
- pub mod both;
9
8
pub mod postgres;
10
9
pub mod sqlite;
11
10
@@ -160,43 +159,19 @@ where
160
159
pub enum Pool {
161
160
Sqlite ( ConnectionPool < sqlite:: Sqlite > ) ,
162
161
Postgres ( ConnectionPool < postgres:: Postgres > ) ,
163
- Both {
164
- sqlite : ConnectionPool < sqlite:: Sqlite > ,
165
- postgres : ConnectionPool < postgres:: Postgres > ,
166
- } ,
167
162
}
168
163
169
164
impl Pool {
170
165
pub async fn connection ( & self ) -> Box < dyn Connection > {
171
166
match self {
172
167
Pool :: Sqlite ( p) => Box :: new ( sqlite:: SqliteConnection :: new ( p. get ( ) . await ) ) ,
173
168
Pool :: Postgres ( p) => Box :: new ( p. get ( ) . await ) ,
174
- Pool :: Both { sqlite, postgres } => Box :: new ( both:: BothConnection :: new (
175
- sqlite:: SqliteConnection :: new ( sqlite. get ( ) . await ) ,
176
- postgres. get ( ) . await ,
177
- ) ) ,
178
169
}
179
170
}
180
171
181
172
pub fn open ( uri : & str ) -> Pool {
182
173
if uri. starts_with ( "postgres" ) {
183
174
Pool :: Postgres ( ConnectionPool :: new ( postgres:: Postgres :: new ( uri. into ( ) ) ) )
184
- } else if uri. starts_with ( "both://" ) {
185
- let mut parts = uri[ "both://" . len ( ) ..] . rsplitn ( 2 , ';' ) ;
186
- let p1 = parts. next ( ) . unwrap ( ) ;
187
- let p2 = parts. next ( ) . unwrap ( ) ;
188
- match ( Pool :: open ( p1) , Pool :: open ( p2) ) {
189
- ( Pool :: Sqlite ( s) , Pool :: Postgres ( p) ) | ( Pool :: Postgres ( p) , Pool :: Sqlite ( s) ) => {
190
- Pool :: Both {
191
- sqlite : s,
192
- postgres : p,
193
- }
194
- }
195
- _ => panic ! (
196
- "unsupported inputs, must be sqlite and postgres: {} and {}" ,
197
- p1, p2
198
- ) ,
199
- }
200
175
} else {
201
176
Pool :: Sqlite ( ConnectionPool :: new ( sqlite:: Sqlite :: new ( uri. into ( ) ) ) )
202
177
}
0 commit comments