Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli)!: configurable backoff #789

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions meta-cli/src/cli/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ pub struct DeploySubcommand {

#[command(flatten)]
options: DeployOptions,

#[clap(long)]
max_parallel_loads: Option<usize>,
}

impl DeploySubcommand {
Expand All @@ -38,14 +35,12 @@ impl DeploySubcommand {
target: String,
options: DeployOptions,
file: Option<PathBuf>,
max_parallel_loads: Option<usize>,
) -> Self {
Self {
node,
target,
options,
file,
max_parallel_loads,
}
}
}
Expand Down Expand Up @@ -82,6 +77,18 @@ pub struct DeployOptions {
/// Run a typegate with the current target configuration
#[clap(long)]
pub run_typegate: bool,

/// maximum number of concurrent deployment tasks
#[clap(long)]
pub threads: Option<usize>,

/// max retry count
#[clap(long)]
pub retry: Option<usize>,

/// initial retry interval in milliseconds
#[clap(long)]
pub retry_interval_ms: Option<u64>,
}

#[derive(Debug)]
Expand All @@ -94,7 +101,6 @@ pub struct Deploy {
options: DeployOptions,
secrets: RawSecrets,
file: Option<PathBuf>,
max_parallel_loads: Option<usize>,
}

impl Deploy {
Expand Down Expand Up @@ -129,7 +135,6 @@ impl Deploy {
options,
secrets,
file: file.clone(),
max_parallel_loads: deploy.max_parallel_loads,
})
}
}
Expand Down Expand Up @@ -188,6 +193,8 @@ enum ExitStatus {
mod default_mode {
//! non-watch mode

use std::time::Duration;

use task_manager::{TaskManagerInit, TaskSource};

use crate::config::PathOption;
Expand Down Expand Up @@ -224,10 +231,13 @@ mod default_mode {
TaskSource::Discovery(deploy.base_dir)
},
)
.retry(3, None);
.retry(
deploy.options.retry.unwrap_or(0),
deploy.options.retry_interval_ms.map(Duration::from_millis),
);

if let Some(max_parallel_loads) = deploy.max_parallel_loads {
init = init.max_parallel_tasks(max_parallel_loads);
if let Some(max_parallel_tasks) = deploy.options.threads {
init = init.max_parallel_tasks(max_parallel_tasks);
}
let report = init.run().await;

Expand Down Expand Up @@ -262,6 +272,8 @@ mod default_mode {
}

mod watch_mode {
use std::time::Duration;

use task_manager::{TaskManagerInit, TaskSource};

use crate::config::PathOption;
Expand Down Expand Up @@ -313,10 +325,13 @@ mod watch_mode {
console.clone(),
TaskSource::DiscoveryAndWatch(deploy.base_dir),
)
.retry(3, None);
.retry(
deploy.options.retry.unwrap_or(3),
deploy.options.retry_interval_ms.map(Duration::from_millis),
);

if let Some(max_parallel_loads) = deploy.max_parallel_loads {
init = init.max_parallel_tasks(max_parallel_loads);
if let Some(max_parallel_tasks) = deploy.options.threads {
init = init.max_parallel_tasks(max_parallel_tasks);
}
let report = init.run().await;

Expand Down
14 changes: 12 additions & 2 deletions meta-cli/src/cli/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct Dev {
run_destructive_migrations: bool,

#[clap(long)]
max_parallel_loads: Option<usize>,
threads: Option<usize>,

/// secrets overload
#[clap(long = "secret")]
Expand All @@ -32,6 +32,14 @@ pub struct Dev {
/// Do not run a typegate. By default a typegate is run with the current target configuration
#[clap(long)]
no_typegate: bool,

/// max retry count
#[clap(long)]
retry: Option<usize>,

/// initial retry interval
#[clap(long)]
retry_interval_ms: Option<u64>,
}

#[async_trait]
Expand All @@ -48,14 +56,16 @@ impl Action for Dev {
secrets: self.secrets.clone(),
#[cfg(feature = "typegate")]
run_typegate: !self.no_typegate,
threads: self.threads,
retry: self.retry,
retry_interval_ms: self.retry_interval_ms,
};

let deploy = DeploySubcommand::new(
self.node.clone(),
self.target.clone().unwrap_or("dev".to_string()),
options,
None,
self.max_parallel_loads,
);
deploy.run(args).await
}
Expand Down
Loading