♻️ Integrate futures library with the database
This commit is contained in:
parent
941b7ae57b
commit
fefb3ed249
4 changed files with 23 additions and 15 deletions
|
|
@ -27,7 +27,7 @@ name = "pagetop"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
database = ["sea-orm", "sea-schema"]
|
database = ["futures", "sea-orm", "sea-schema"]
|
||||||
mysql = ["database", "sea-orm/sqlx-mysql"]
|
mysql = ["database", "sea-orm/sqlx-mysql"]
|
||||||
postgres = ["database", "sea-orm/sqlx-postgres"]
|
postgres = ["database", "sea-orm/sqlx-postgres"]
|
||||||
sqlite = ["database", "sea-orm/sqlx-sqlite"]
|
sqlite = ["database", "sea-orm/sqlx-sqlite"]
|
||||||
|
|
@ -37,8 +37,6 @@ async-trait = "0.1.68"
|
||||||
concat-string = "1.0.1"
|
concat-string = "1.0.1"
|
||||||
figlet-rs = "0.1.5"
|
figlet-rs = "0.1.5"
|
||||||
itoa = "1.0.6"
|
itoa = "1.0.6"
|
||||||
futures = "0.3.28"
|
|
||||||
futures-util = "0.3.28"
|
|
||||||
nom = "7.1.3"
|
nom = "7.1.3"
|
||||||
once_cell = "1.17.2"
|
once_cell = "1.17.2"
|
||||||
paste = "1.0.12"
|
paste = "1.0.12"
|
||||||
|
|
@ -67,6 +65,10 @@ pagetop-macros = { version = "0.0", path = "../pagetop-macros" }
|
||||||
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|
||||||
|
[dependencies.futures]
|
||||||
|
version = "0.3.28"
|
||||||
|
optional = true
|
||||||
|
|
||||||
[dependencies.sea-orm]
|
[dependencies.sea-orm]
|
||||||
version = "0.11.3"
|
version = "0.11.3"
|
||||||
features = ["debug-print", "macros", "runtime-async-std-native-tls"]
|
features = ["debug-print", "macros", "runtime-async-std-native-tls"]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::core::theme::all::THEMES;
|
||||||
use crate::{service, trace, LazyStatic};
|
use crate::{service, trace, LazyStatic};
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
use crate::{db::*, run_now};
|
use crate::{db::*};
|
||||||
|
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//! Acceso unificado y normalizado a base de datos.
|
//! Acceso unificado y normalizado a base de datos.
|
||||||
|
|
||||||
use crate::{config, run_now, trace, LazyStatic, ResultExt};
|
use crate::{config, trace, LazyStatic, ResultExt};
|
||||||
|
|
||||||
pub use url::Url as DbUri;
|
pub use url::Url as DbUri;
|
||||||
|
|
||||||
|
|
@ -8,6 +8,8 @@ pub use sea_orm::{DatabaseConnection as DbConn, ExecResult, QueryResult};
|
||||||
|
|
||||||
use sea_orm::{ConnectOptions, ConnectionTrait, Database, DatabaseBackend, Statement};
|
use sea_orm::{ConnectOptions, ConnectionTrait, Database, DatabaseBackend, Statement};
|
||||||
|
|
||||||
|
pub(crate) use futures::executor::block_on as run_now;
|
||||||
|
|
||||||
pub(crate) static DBCONN: LazyStatic<DbConn> = LazyStatic::new(|| {
|
pub(crate) static DBCONN: LazyStatic<DbConn> = LazyStatic::new(|| {
|
||||||
trace::info!(
|
trace::info!(
|
||||||
"Connecting to database \"{}\" using a pool of {} connections",
|
"Connecting to database \"{}\" using a pool of {} connections",
|
||||||
|
|
|
||||||
|
|
@ -98,28 +98,32 @@
|
||||||
//! PageTop a estructurar e inicializar modularmente la aplicación.
|
//! PageTop a estructurar e inicializar modularmente la aplicación.
|
||||||
|
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
// GLOBAL.
|
// RE-EXPORTED MACROS.
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
|
|
||||||
pub use concat_string::concat_string;
|
pub use concat_string::concat_string;
|
||||||
pub use once_cell::sync::Lazy as LazyStatic;
|
|
||||||
pub use paste::paste;
|
|
||||||
pub use static_files::Resource as StaticResource;
|
|
||||||
pub use tracing_unwrap::ResultExt;
|
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
/// Enables flexible identifier concatenation in macros, allowing new items with pasted identifiers.
|
||||||
pub(crate) use futures::executor::block_on as run_now;
|
pub use paste::paste;
|
||||||
|
|
||||||
pub use pagetop_macros::fn_builder;
|
pub use pagetop_macros::fn_builder;
|
||||||
|
|
||||||
pub type HashMapResources = std::collections::HashMap<&'static str, StaticResource>;
|
// *************************************************************************************************
|
||||||
|
// GLOBAL.
|
||||||
|
// *************************************************************************************************
|
||||||
|
|
||||||
|
pub use once_cell::sync::Lazy as LazyStatic;
|
||||||
|
pub use static_files::Resource as StaticResource;
|
||||||
|
pub use tracing_unwrap::ResultExt;
|
||||||
|
|
||||||
pub type Handle = u64;
|
pub type Handle = u64;
|
||||||
|
pub type Weight = i8;
|
||||||
|
pub type HashMapResources = std::collections::HashMap<&'static str, StaticResource>;
|
||||||
|
|
||||||
static_locales!(LOCALES_PAGETOP);
|
static_locales!(LOCALES_PAGETOP);
|
||||||
|
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
// APIs PÚBLICAS.
|
// PUBLIC API.
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
|
|
||||||
// Gestión de la configuración.
|
// Gestión de la configuración.
|
||||||
|
|
@ -151,7 +155,7 @@ pub mod util;
|
||||||
pub mod app;
|
pub mod app;
|
||||||
|
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
// RE-EXPORTA API ÚNICA.
|
// The PageTop Prelude.
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
|
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue