mirror of
https://github.com/maplibre/martin.git
synced 2024-12-19 12:51:37 +03:00
Fix martin --auto-bounds
silently ignored with --config
(#1223)
When starting martin with both `--auto-bounds` and `--config`, the auto-bounds param was silently ignored, but now it will notify of the override. Also includes a few minor formatting changes
This commit is contained in:
parent
b492145bc8
commit
fcaffcbe49
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2106,6 +2106,7 @@ dependencies = [
|
|||||||
"criterion",
|
"criterion",
|
||||||
"ctor",
|
"ctor",
|
||||||
"deadpool-postgres",
|
"deadpool-postgres",
|
||||||
|
"enum-display",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"flate2",
|
"flate2",
|
||||||
"futures",
|
"futures",
|
||||||
|
@ -79,11 +79,13 @@ bit-set = { workspace = true, optional = true }
|
|||||||
brotli.workspace = true
|
brotli.workspace = true
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
deadpool-postgres = { workspace = true, optional = true }
|
deadpool-postgres = { workspace = true, optional = true }
|
||||||
|
enum-display.workspace = true
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
flate2.workspace = true
|
flate2.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
json-patch = { workspace = true, optional = true }
|
json-patch = { workspace = true, optional = true }
|
||||||
|
lambda-web = { workspace = true, optional = true }
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
martin-tile-utils.workspace = true
|
martin-tile-utils.workspace = true
|
||||||
mbtiles = { workspace = true, optional = true }
|
mbtiles = { workspace = true, optional = true }
|
||||||
@ -92,8 +94,8 @@ num_cpus.workspace = true
|
|||||||
pbf_font_tools = { workspace = true, optional = true }
|
pbf_font_tools = { workspace = true, optional = true }
|
||||||
pmtiles = { workspace = true, optional = true }
|
pmtiles = { workspace = true, optional = true }
|
||||||
postgis = { workspace = true, optional = true }
|
postgis = { workspace = true, optional = true }
|
||||||
postgres-protocol = { workspace = true, optional = true }
|
|
||||||
postgres = { workspace = true, optional = true }
|
postgres = { workspace = true, optional = true }
|
||||||
|
postgres-protocol = { workspace = true, optional = true }
|
||||||
regex.workspace = true
|
regex.workspace = true
|
||||||
rustls-native-certs.workspace = true
|
rustls-native-certs.workspace = true
|
||||||
rustls-pemfile.workspace = true
|
rustls-pemfile.workspace = true
|
||||||
@ -110,7 +112,6 @@ tilejson.workspace = true
|
|||||||
tokio = { workspace = true, features = ["io-std"] }
|
tokio = { workspace = true, features = ["io-std"] }
|
||||||
tokio-postgres-rustls = { workspace = true, optional = true }
|
tokio-postgres-rustls = { workspace = true, optional = true }
|
||||||
url.workspace = true
|
url.workspace = true
|
||||||
lambda-web = { workspace = true, optional = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
cargo-husky.workspace = true
|
cargo-husky.workspace = true
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use clap::ValueEnum;
|
use clap::ValueEnum;
|
||||||
|
use enum_display::EnumDisplay;
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -13,8 +14,11 @@ use crate::utils::{OptBoolObj, OptOneMany};
|
|||||||
// Must match the help string for BoundsType::Quick
|
// Must match the help string for BoundsType::Quick
|
||||||
pub const DEFAULT_BOUNDS_TIMEOUT: Duration = Duration::from_secs(5);
|
pub const DEFAULT_BOUNDS_TIMEOUT: Duration = Duration::from_secs(5);
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Default, Debug, Clone, Copy, Serialize, Deserialize, ValueEnum)]
|
#[derive(
|
||||||
|
PartialEq, Eq, Default, Debug, Clone, Copy, Serialize, Deserialize, ValueEnum, EnumDisplay,
|
||||||
|
)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
|
#[enum_display(case = "Kebab")]
|
||||||
pub enum BoundsCalcType {
|
pub enum BoundsCalcType {
|
||||||
/// Compute table geometry bounds, but abort if it takes longer than 5 seconds.
|
/// Compute table geometry bounds, but abort if it takes longer than 5 seconds.
|
||||||
#[default]
|
#[default]
|
||||||
@ -37,7 +41,7 @@ pub struct PgArgs {
|
|||||||
/// If a spatial PG table has SRID 0, then this default SRID will be used as a fallback.
|
/// If a spatial PG table has SRID 0, then this default SRID will be used as a fallback.
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub default_srid: Option<i32>,
|
pub default_srid: Option<i32>,
|
||||||
#[arg(help = format!("Maximum Postgres connections pool size [DEFAULT: {}]", POOL_SIZE_DEFAULT), short, long)]
|
#[arg(help = format!("Maximum Postgres connections pool size [DEFAULT: {POOL_SIZE_DEFAULT}]"), short, long)]
|
||||||
pub pool_size: Option<usize>,
|
pub pool_size: Option<usize>,
|
||||||
/// Limit the number of features in a tile from a PG table source.
|
/// Limit the number of features in a tile from a PG table source.
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
@ -76,29 +80,35 @@ impl PgArgs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Apply CLI parameters from `self` to the configuration loaded from the config file `pg_config`
|
||||||
pub fn override_config<'a>(self, pg_config: &mut OptOneMany<PgConfig>, env: &impl Env<'a>) {
|
pub fn override_config<'a>(self, pg_config: &mut OptOneMany<PgConfig>, env: &impl Env<'a>) {
|
||||||
if self.default_srid.is_some() {
|
if let Some(default_srid) = self.default_srid {
|
||||||
info!("Overriding configured default SRID to {} on all Postgres connections because of a CLI parameter", self.default_srid.unwrap());
|
info!("Overriding configured default SRID to {default_srid} on all Postgres connections because of a CLI parameter");
|
||||||
pg_config.iter_mut().for_each(|c| {
|
pg_config.iter_mut().for_each(|c| {
|
||||||
c.default_srid = self.default_srid;
|
c.default_srid = self.default_srid;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if self.pool_size.is_some() {
|
if let Some(pool_size) = self.pool_size {
|
||||||
info!("Overriding configured pool size to {} on all Postgres connections because of a CLI parameter", self.pool_size.unwrap());
|
info!("Overriding configured pool size to {pool_size} on all Postgres connections because of a CLI parameter");
|
||||||
pg_config.iter_mut().for_each(|c| {
|
pg_config.iter_mut().for_each(|c| {
|
||||||
c.pool_size = self.pool_size;
|
c.pool_size = self.pool_size;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if self.max_feature_count.is_some() {
|
if let Some(auto_bounds) = self.auto_bounds {
|
||||||
info!("Overriding maximum feature count to {} on all Postgres connections because of a CLI parameter", self.max_feature_count.unwrap());
|
info!("Overriding auto_bounds to {auto_bounds} on all Postgres connections because of a CLI parameter");
|
||||||
|
pg_config.iter_mut().for_each(|c| {
|
||||||
|
c.auto_bounds = self.auto_bounds;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if let Some(max_feature_count) = self.max_feature_count {
|
||||||
|
info!("Overriding maximum feature count to {max_feature_count} on all Postgres connections because of a CLI parameter");
|
||||||
pg_config.iter_mut().for_each(|c| {
|
pg_config.iter_mut().for_each(|c| {
|
||||||
c.max_feature_count = self.max_feature_count;
|
c.max_feature_count = self.max_feature_count;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if let Some(ref ca_root_file) = self.ca_root_file {
|
||||||
if self.ca_root_file.is_some() {
|
|
||||||
info!("Overriding root certificate file to {} on all Postgres connections because of a CLI parameter",
|
info!("Overriding root certificate file to {} on all Postgres connections because of a CLI parameter",
|
||||||
self.ca_root_file.as_ref().unwrap().display());
|
ca_root_file.display());
|
||||||
pg_config.iter_mut().for_each(|c| {
|
pg_config.iter_mut().for_each(|c| {
|
||||||
c.ssl_certificates.ssl_root_cert = self.ca_root_file.clone();
|
c.ssl_certificates.ssl_root_cert = self.ca_root_file.clone();
|
||||||
});
|
});
|
||||||
|
@ -6,9 +6,9 @@ use crate::srv::{SrvConfig, KEEP_ALIVE_DEFAULT, LISTEN_ADDRESSES_DEFAULT};
|
|||||||
#[derive(clap::Args, Debug, PartialEq, Default)]
|
#[derive(clap::Args, Debug, PartialEq, Default)]
|
||||||
#[command(about, version)]
|
#[command(about, version)]
|
||||||
pub struct SrvArgs {
|
pub struct SrvArgs {
|
||||||
#[arg(help = format!("Connection keep alive timeout. [DEFAULT: {}]", KEEP_ALIVE_DEFAULT), short, long)]
|
#[arg(help = format!("Connection keep alive timeout. [DEFAULT: {KEEP_ALIVE_DEFAULT}]"), short, long)]
|
||||||
pub keep_alive: Option<u64>,
|
pub keep_alive: Option<u64>,
|
||||||
#[arg(help = format!("The socket address to bind. [DEFAULT: {}]", LISTEN_ADDRESSES_DEFAULT), short, long)]
|
#[arg(help = format!("The socket address to bind. [DEFAULT: {LISTEN_ADDRESSES_DEFAULT}]"), short, long)]
|
||||||
pub listen_addresses: Option<String>,
|
pub listen_addresses: Option<String>,
|
||||||
/// Set TileJSON URL path prefix, ignoring X-Rewrite-URL header. Must begin with a `/`. Examples: `/`, `/tiles`
|
/// Set TileJSON URL path prefix, ignoring X-Rewrite-URL header. Must begin with a `/`. Examples: `/`, `/tiles`
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
|
Loading…
Reference in New Issue
Block a user