Add parameter for db pool size
This commit is contained in:
		
							parent
							
								
									b14049b3f6
								
							
						
					
					
						commit
						f26e66d687
					
				
					 2 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -33,14 +33,14 @@ pub async fn run_migrations(pool: &Pool<Sqlite>) -> Result<(), EmgauwaError> {
 | 
			
		|||
	Ok(())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub async fn init(db: &str) -> Result<Pool<Sqlite>, EmgauwaError> {
 | 
			
		||||
pub async fn init(db: &str, pool_size: u32) -> Result<Pool<Sqlite>, EmgauwaError> {
 | 
			
		||||
	let options = SqliteConnectOptions::from_str(db)?
 | 
			
		||||
		.create_if_missing(true)
 | 
			
		||||
		.log_statements(log::LevelFilter::Trace);
 | 
			
		||||
 | 
			
		||||
	let pool: Pool<Sqlite> = SqlitePoolOptions::new()
 | 
			
		||||
		.acquire_timeout(std::time::Duration::from_secs(1))
 | 
			
		||||
		.max_connections(5)
 | 
			
		||||
		.max_connections(pool_size)
 | 
			
		||||
		.connect_with(options)
 | 
			
		||||
		.await?;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,7 +47,7 @@ impl From<&EmgauwaError> for String {
 | 
			
		|||
			EmgauwaError::Database(err) => String::from(err),
 | 
			
		||||
			EmgauwaError::Uid(_) => String::from("the uid is in a bad format"),
 | 
			
		||||
			EmgauwaError::Internal(_) => String::from("internal error"),
 | 
			
		||||
			EmgauwaError::Connection(_) => String::from("the target controller is not connected"),
 | 
			
		||||
			EmgauwaError::Connection(uid) => format!("unable to connect to controller with uid: {}", uid),
 | 
			
		||||
			EmgauwaError::Other(err) => format!("other error: {}", err),
 | 
			
		||||
			EmgauwaError::Hardware(err) => format!("hardware error: {}", err),
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue