Macro toolforge::connection_info
source · macro_rules! connection_info { ( $dbname:expr ) => { ... }; ( $dbname:expr, $cluster:ident ) => { ... }; }
Available on crate feature
mysql
only.Expand description
Get connection information for the Toolforge databases.
The first argument is the database name, with or without a _p
suffix.
The second (optional) argument is which cluster to connect to, either
WEB
(default) or ANALYTICS
.
You can also connect to the the meta_p
database this way.
assert_eq!(
"mysql://user:pass@enwiki.web.db.svc.eqiad.wmflabs:3306/enwiki_p".to_string(),
toolforge::connection_info!("enwiki")?.to_string()
);
assert_eq!(
"mysql://user:pass@enwiki.analytics.db.svc.eqiad.wmflabs:3306/enwiki_p".to_string(),
toolforge::connection_info!(
"enwiki",
ANALYTICS
)?.to_string()
);
Local development
It is possible to set up a SSH tunnel to the wiki replicas to allow for
local testing of MySQL connections. Copy your replica.my.cnf
to your
machine, and add local='true'
to it. With that set, this library
will automatically connect to port 3306 on your local machine.