add application_name to PG connection (#1325)

This commit is contained in:
Yuri Astrakhan 2024-05-26 12:27:47 -04:00 committed by GitHub
parent 8c82423fc3
commit c49648ca18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 5 deletions

View File

@ -50,10 +50,14 @@ pub fn parse_conn_str(conn_str: &str) -> PgResult<(Config, SslModeOverride)> {
} else {
Config::from_str(conn_str)
};
let pg_cfg = pg_cfg.map_err(|e| BadConnectionString(e, conn_str.to_string()))?;
let mut pg_cfg = pg_cfg.map_err(|e| BadConnectionString(e, conn_str.to_string()))?;
if let SslModeOverride::Unmodified(_) = mode {
mode = SslModeOverride::Unmodified(pg_cfg.get_ssl_mode());
}
let crate_ver = env!("CARGO_PKG_VERSION");
if pg_cfg.get_application_name().is_none() {
pg_cfg.application_name(&format!("Martin v{crate_ver} - pid={}", std::process::id()));
}
Ok((pg_cfg, mode))
}

View File

@ -113,7 +113,7 @@ pub fn new_server(config: SrvConfig, state: ServerState) -> MartinResult<(Server
let listen_addresses = config
.listen_addresses
.clone()
.unwrap_or_else(|| LISTEN_ADDRESSES_DEFAULT.to_owned());
.unwrap_or_else(|| LISTEN_ADDRESSES_DEFAULT.to_string());
let factory = move || {
let cors_middleware = Cors::default()

View File

@ -133,9 +133,9 @@ impl<'a> DynTileSource<'a> {
CacheValue::Tile,
s.get_tile(xyz, self.query_obj.as_ref()),
{
let id = s.get_id().to_owned();
let id = s.get_id().to_string();
if let Some(query_str) = self.query_str {
CacheKey::TileWithQuery(id, xyz, query_str.to_owned())
CacheKey::TileWithQuery(id, xyz, query_str.to_string())
} else {
CacheKey::Tile(id, xyz)
}

View File

@ -38,7 +38,7 @@ async fn get_source_info(
.get("x-rewrite-url")
.and_then(|v| v.to_str().ok())
.and_then(|v| v.parse::<Uri>().ok())
.map_or_else(|| req.path().to_owned(), |v| v.path().to_owned())
.map_or_else(|| req.path().to_string(), |v| v.path().to_string())
};
let query_string = req.query_string();