pub enum DatabaseConfig {
Sqlite(SqliteConfig),
Mysql(MysqlConfig),
}Expand description
Database configuration for Tracker
Supports multiple database backends. Currently implemented:
SQLite(file-based, development and small deployments)MySQL(planned for production deployments)
§Examples
use torrust_tracker_deployer_lib::domain::tracker::{DatabaseConfig, SqliteConfig};
// SQLite configuration
let sqlite = DatabaseConfig::Sqlite(SqliteConfig::new("tracker.db").unwrap());
// MySQL configuration
// use torrust_tracker_deployer_lib::domain::tracker::MysqlConfig;
// use torrust_tracker_deployer_lib::shared::Password;
// let mysql = DatabaseConfig::Mysql(MysqlConfig::new(
// "localhost", 3306, "tracker", "tracker_user", Password::from("secure_password")
// ).unwrap());Variants§
Implementations§
Source§impl DatabaseConfig
impl DatabaseConfig
Sourcepub fn driver_name(&self) -> &str
pub fn driver_name(&self) -> &str
Returns the database driver name
§Examples
use torrust_tracker_deployer_lib::domain::tracker::{DatabaseConfig, SqliteConfig};
let config = DatabaseConfig::Sqlite(SqliteConfig::new("tracker.db").unwrap());
assert_eq!(config.driver_name(), "sqlite3");Sourcepub fn database_name(&self) -> &str
pub fn database_name(&self) -> &str
Returns the database name
§Examples
use torrust_tracker_deployer_lib::domain::tracker::{DatabaseConfig, SqliteConfig};
let config = DatabaseConfig::Sqlite(SqliteConfig::new("tracker.db").unwrap());
assert_eq!(config.database_name(), "tracker.db");Sourcepub fn docker_image(&self) -> Option<DockerImage>
pub fn docker_image(&self) -> Option<DockerImage>
Returns the Docker image for the database service container, if applicable.
Mysqlvariant returns theMySQLdocker imageSqlitereturnsNone—SQLiteruns in-process; no container is needed
§Examples
use torrust_tracker_deployer_lib::domain::tracker::{DatabaseConfig, SqliteConfig, MysqlConfig};
use torrust_tracker_deployer_lib::shared::Password;
let sqlite = DatabaseConfig::Sqlite(SqliteConfig::new("tracker.db").unwrap());
assert!(sqlite.docker_image().is_none());
let mysql = DatabaseConfig::Mysql(
MysqlConfig::new("localhost", 3306, "tracker", "user", "pass".to_string().into(), "root_pass".to_string().into()).unwrap()
);
assert_eq!(mysql.docker_image().unwrap().full_reference(), "mysql:8.4");Trait Implementations§
Source§impl Clone for DatabaseConfig
impl Clone for DatabaseConfig
Source§impl Debug for DatabaseConfig
impl Debug for DatabaseConfig
Source§impl<'de> Deserialize<'de> for DatabaseConfig
impl<'de> Deserialize<'de> for DatabaseConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for DatabaseConfig
impl PartialEq for DatabaseConfig
Source§impl Serialize for DatabaseConfig
impl Serialize for DatabaseConfig
impl StructuralPartialEq for DatabaseConfig
Source§impl TryFrom<DatabaseSection> for DatabaseConfig
impl TryFrom<DatabaseSection> for DatabaseConfig
Source§type Error = CreateConfigError
type Error = CreateConfigError
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl Freeze for DatabaseConfig
impl RefUnwindSafe for DatabaseConfig
impl Send for DatabaseConfig
impl Sync for DatabaseConfig
impl Unpin for DatabaseConfig
impl UnsafeUnpin for DatabaseConfig
impl UnwindSafe for DatabaseConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request