diff options
author | Matt Fleming <[email protected]> | 2024-10-21 11:05:28 -0400 |
---|---|---|
committer | Kevin Guthrie <[email protected]> | 2024-10-28 11:51:38 -0400 |
commit | e94c0a345f587801ac5d1a84281ac90b717cd088 (patch) | |
tree | 56c9a926930374af5ceb464a546235a53d8c20e2 | |
parent | e9c319197e47b30a97429c57ed263abfc73f910b (diff) | |
download | pingora-e94c0a345f587801ac5d1a84281ac90b717cd088.tar.gz pingora-e94c0a345f587801ac5d1a84281ac90b717cd088.zip |
Make opt optional for frontends
Allow frontends to avoid jumping through hoops to create an Opt object,
for example, when configuration is handled by a config file.
Includes-commit: 8204820b217b6d60906b8361d2e077ed743b970b
Replicated-from: https://github.com/cloudflare/pingora/pull/390
-rw-r--r-- | .bleep | 2 | ||||
-rw-r--r-- | pingora-core/src/server/mod.rs | 12 |
2 files changed, 8 insertions, 6 deletions
@@ -1 +1 @@ -e7a903e2509b977352e40d5f0be884a04379c066
\ No newline at end of file +986270b9e07bce082ff02c86ca183b8c81d7abb8
\ No newline at end of file diff --git a/pingora-core/src/server/mod.rs b/pingora-core/src/server/mod.rs index 9762dc8..3622354 100644 --- a/pingora-core/src/server/mod.rs +++ b/pingora-core/src/server/mod.rs @@ -194,11 +194,13 @@ impl Server { /// /// If a configuration file path is provided as part of `opt`, it will be ignored /// and a warning will be logged. - pub fn new_with_opt_and_conf(opt: Opt, mut conf: ServerConf) -> Server { - if let Some(c) = opt.conf.as_ref() { - warn!("Ignoring command line argument using '{c}' as configuration, and using provided configuration instead."); + pub fn new_with_opt_and_conf(opt: Option<Opt>, mut conf: ServerConf) -> Server { + if let Some(opt) = &opt { + if let Some(c) = opt.conf.as_ref() { + warn!("Ignoring command line argument using '{c}' as configuration, and using provided configuration instead."); + } + conf.merge_with_opt(&opt); } - conf.merge_with_opt(&opt); let (tx, rx) = watch::channel(false); @@ -209,7 +211,7 @@ impl Server { shutdown_watch: tx, shutdown_recv: rx, configuration: Arc::new(conf), - options: Some(opt), + options: opt, #[cfg(feature = "sentry")] sentry: None, } |