blob: 489a0006a8e352b9baf092280761f2fa690baaf4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
use serde::Serialize;
use sqlx::{PgPool, postgres::PgPoolOptions};
use tracing::{debug, info};
#[derive(Serialize, Debug)]
pub struct Device {
pub id: String,
pub mac: String,
pub broadcast_addr: String,
pub ip: String,
pub times: Option<Vec<i64>>
}
pub async fn init_db_pool(db_url: &str) -> PgPool {
debug!("attempt to connect dbPool to '{}'", db_url);
let pool = PgPoolOptions::new()
.max_connections(5)
.connect(db_url)
.await
.unwrap();
info!("dbPool successfully connected to '{}'", db_url);
pool
}
|