Skip to content

Commit

Permalink
feat(proxy): enable configuring worker threads through env/command/co…
Browse files Browse the repository at this point in the history
…nfig
  • Loading branch information
luizfonseca committed May 15, 2024
1 parent e23c521 commit 6af3f5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,17 @@ pub(crate) struct Config {
#[clap(short, long, default_value = "proksi")]
pub service_name: String,

/// The PATH to the configuration file to be used. The configuration file
/// should be named either `proksi.toml`, `proksi.yaml` or `proksi.yml`
/// and be present in that path.
/// The number of worker threads to be used by the HTTPS proxy service.
///
/// For background services the default is always (1) and cannot be changed.
#[clap(short, long, default_value = "1")]
pub worker_threads: Option<usize>,

/// The PATH to the configuration file to be used.
///
/// The configuration file should be named either `proksi.toml`, `proksi.yaml` or `proksi.yml`
///
/// and be present in that path. Defaults to the current directory.
#[serde(skip)]
#[clap(short, long, default_value = "./")]
pub config_path: String,
Expand All @@ -205,6 +213,7 @@ impl Default for Config {
Config {
config_path: "/etc/proksi/config".to_string(),
service_name: "proksi".to_string(),
worker_threads: Some(1),
routes: vec![],
logging: ConfigLogging {
level: LogLevel::Info,
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ fn main() -> Result<(), anyhow::Error> {
let mut https_service = http_proxy_service(&pingora_server.configuration, router);
http_service.add_tcp("0.0.0.0:80");

// Worker threads per configuration
https_service.threads = proxy_config.worker_threads;
https_service.add_tls_with_settings("0.0.0.0:443", None, tls_settings);

pingora_server.add_service(http_service);
Expand Down

0 comments on commit 6af3f5c

Please sign in to comment.