Skip to content

Commit

Permalink
add application_name to PG connection (#1325)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik authored May 26, 2024
1 parent 8c82423 commit c49648c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion martin/src/pg/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
2 changes: 1 addition & 1 deletion martin/src/srv/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions martin/src/srv/tiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion martin/src/srv/tiles_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c49648c

Please sign in to comment.