Skip to content

Commit 49d7938

Browse files
Feedback
1 parent 3226a75 commit 49d7938

File tree

8 files changed

+69
-37
lines changed

8 files changed

+69
-37
lines changed

cli/src/clients/admin_interface.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub trait AdminClientInterface {
6565
id: &str,
6666
) -> impl Future<Output = reqwest::Result<Envelope<()>>> + Send + 'static;
6767

68-
async fn resume_invocation(
68+
fn resume_invocation(
6969
&self,
7070
id: &str,
7171
deployment: Option<&str>,
@@ -180,6 +180,18 @@ impl AdminClientInterface for AdminClient {
180180
)
181181
}
182182

183+
fn resume_invocation(
184+
&self,
185+
id: &str,
186+
deployment: Option<&str>,
187+
) -> impl Future<Output = reqwest::Result<Envelope<()>>> + Send + 'static {
188+
let mut url = self.versioned_url(["invocations", id, "resume"]);
189+
if let Some(deployment) = deployment {
190+
url.set_query(Some(&format!("deployment={deployment}")));
191+
}
192+
self.run(reqwest::Method::PATCH, url)
193+
}
194+
183195
fn kill_invocation(
184196
&self,
185197
id: &str,
@@ -209,18 +221,6 @@ impl AdminClientInterface for AdminClient {
209221
self.run(reqwest::Method::PATCH, url)
210222
}
211223

212-
fn resume_invocation(
213-
&self,
214-
id: &str,
215-
deployment: Option<&str>,
216-
) -> impl Future<Output = reqwest::Result<Envelope<()>>> + Send + 'static {
217-
let mut url = self.versioned_url(["invocations", id, "resume"]);
218-
if let Some(deployment) = deployment {
219-
url.set_query(Some(&format!("deployment={deployment}")));
220-
}
221-
self.run(reqwest::Method::PATCH, url)
222-
}
223-
224224
fn pause_invocation(
225225
&self,
226226
id: &str,

cli/src/commands/invocations/cancel.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use crate::clients::batch_execute;
2020
use crate::clients::datafusion_helpers::find_active_invocations_simple;
2121
use crate::clients::{self, AdminClientInterface};
2222
use crate::commands::invocations::{
23-
DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT, create_query_filter,
23+
DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT, DEFAULT_BATCH_INVOCATIONS_OPERATION_PRINT_LIMIT,
24+
create_query_filter,
2425
};
2526
use crate::ui::invocations::render_simple_invocation_list;
2627
use crate::ui::with_progress;
@@ -43,7 +44,7 @@ pub struct Cancel {
4344
#[clap(long)]
4445
pub(super) kill: bool,
4546
/// Limit the number of fetched invocations
46-
#[clap(long, default_value = "DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT")]
47+
#[clap(long, default_value_t = DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT)]
4748
pub(super) limit: usize,
4849
}
4950

@@ -70,7 +71,10 @@ pub async fn run_cancel(State(env): State<CliEnv>, opts: &Cancel) -> Result<()>
7071
);
7172
};
7273

73-
render_simple_invocation_list(&invocations, DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT);
74+
render_simple_invocation_list(
75+
&invocations,
76+
DEFAULT_BATCH_INVOCATIONS_OPERATION_PRINT_LIMIT,
77+
);
7478

7579
// Get the invocation and confirm
7680
let prompt = format!(

cli/src/commands/invocations/kill.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// As of the Change Date specified in that file, in accordance with
88
// the Business Source License, use of this software will be governed
99
// by the Apache License, Version 2.0.
10+
11+
use super::DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT;
12+
1013
use anyhow::Result;
1114
use cling::prelude::*;
1215

@@ -28,7 +31,7 @@ pub struct Kill {
2831
/// * `workflowName/key/handler`
2932
query: String,
3033
/// Limit the number of fetched invocations
31-
#[clap(long, default_value = "500")]
34+
#[clap(long, default_value_t = DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT)]
3235
limit: usize,
3336
}
3437

cli/src/commands/invocations/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ mod resume;
2020
use cling::prelude::*;
2121
use restate_types::identifiers::InvocationId;
2222

23-
const DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT: usize = 100;
23+
const DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT: usize = 500;
24+
const DEFAULT_BATCH_INVOCATIONS_OPERATION_PRINT_LIMIT: usize =
25+
DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT;
2426

2527
#[derive(Run, Subcommand, Clone)]
2628
pub enum Invocations {

cli/src/commands/invocations/pause.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use crate::clients::datafusion_helpers::find_active_invocations_simple;
1313
use crate::clients::{self, AdminClientInterface, batch_execute};
1414
use crate::ui::invocations::render_simple_invocation_list;
1515

16-
use crate::commands::invocations::DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT;
16+
use crate::commands::invocations::{
17+
DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT, DEFAULT_BATCH_INVOCATIONS_OPERATION_PRINT_LIMIT,
18+
};
1719
use anyhow::{Result, anyhow, bail};
1820
use cling::prelude::*;
1921
use comfy_table::{Cell, Color, Table};
@@ -33,7 +35,7 @@ pub struct Pause {
3335
/// * `virtualObjectName/key/handler`
3436
query: String,
3537
/// Limit the number of fetched invocations
36-
#[clap(long, default_value = "DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT")]
38+
#[clap(long, default_value_t = DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT)]
3739
limit: usize,
3840
}
3941

@@ -67,7 +69,10 @@ pub async fn run_pause(State(env): State<CliEnv>, opts: &Pause) -> Result<()> {
6769
);
6870
};
6971

70-
render_simple_invocation_list(&invocations, DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT);
72+
render_simple_invocation_list(
73+
&invocations,
74+
DEFAULT_BATCH_INVOCATIONS_OPERATION_PRINT_LIMIT,
75+
);
7176

7277
// Get the invocation and confirm
7378
confirm_or_exit("Are you sure you want to pause these invocations?")?;

cli/src/commands/invocations/purge.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use crate::cli_env::CliEnv;
1212
use crate::clients::datafusion_helpers::find_active_invocations_simple;
1313
use crate::clients::{self, AdminClientInterface, batch_execute};
1414
use crate::commands::invocations::{
15-
DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT, create_query_filter,
15+
DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT, DEFAULT_BATCH_INVOCATIONS_OPERATION_PRINT_LIMIT,
16+
create_query_filter,
1617
};
1718
use crate::ui::invocations::render_simple_invocation_list;
1819

@@ -38,7 +39,7 @@ pub struct Purge {
3839
/// * `workflowName/key/handler`
3940
query: String,
4041
/// Limit the number of fetched invocations
41-
#[clap(long, default_value = "DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT")]
42+
#[clap(long, default_value_t = DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT)]
4243
limit: usize,
4344
}
4445

@@ -61,7 +62,10 @@ pub async fn run_purge(State(env): State<CliEnv>, opts: &Purge) -> Result<()> {
6162
);
6263
};
6364

64-
render_simple_invocation_list(&invocations, DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT);
65+
render_simple_invocation_list(
66+
&invocations,
67+
DEFAULT_BATCH_INVOCATIONS_OPERATION_PRINT_LIMIT,
68+
);
6569

6670
// Get the invocation and confirm
6771
confirm_or_exit("Are you sure you want to purge these invocations?")?;

cli/src/commands/invocations/restart_as_new.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ use crate::clients::{self, AdminClientInterface, batch_execute};
1414
use crate::ui::invocations::render_simple_invocation_list;
1515

1616
use crate::commands::invocations::{
17-
DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT, create_query_filter,
17+
DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT, DEFAULT_BATCH_INVOCATIONS_OPERATION_PRINT_LIMIT,
18+
create_query_filter,
1819
};
1920
use anyhow::{Result, anyhow, bail};
2021
use cling::prelude::*;
@@ -35,7 +36,7 @@ pub struct RestartAsNew {
3536
/// * `virtualObjectName/key/handler`
3637
query: String,
3738
/// Limit the number of fetched invocations
38-
#[clap(long, default_value = "DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT")]
39+
#[clap(long, default_value_t = DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT)]
3940
limit: usize,
4041
}
4142

@@ -57,7 +58,10 @@ pub async fn run_restart_as_new(State(env): State<CliEnv>, opts: &RestartAsNew)
5758
);
5859
};
5960

60-
render_simple_invocation_list(&invocations, DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT);
61+
render_simple_invocation_list(
62+
&invocations,
63+
DEFAULT_BATCH_INVOCATIONS_OPERATION_PRINT_LIMIT,
64+
);
6165

6266
// Get the invocation and confirm
6367
confirm_or_exit("Are you sure you want to restart these invocations?")?;

cli/src/commands/invocations/resume.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ use crate::clients::{self, AdminClientInterface, batch_execute};
1414
use crate::ui::invocations::render_simple_invocation_list;
1515

1616
use crate::commands::invocations::{
17-
DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT, create_query_filter,
17+
DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT, DEFAULT_BATCH_INVOCATIONS_OPERATION_PRINT_LIMIT,
18+
create_query_filter,
1819
};
1920
use anyhow::{Result, anyhow, bail};
2021
use cling::prelude::*;
@@ -41,7 +42,7 @@ pub struct Resume {
4142
#[clap(long)]
4243
deployment: Option<String>,
4344
/// Limit the number of fetched invocations
44-
#[clap(long, default_value = "DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT")]
45+
#[clap(long, default_value_t = DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT)]
4546
limit: usize,
4647
}
4748

@@ -64,21 +65,30 @@ pub async fn run_resume(State(env): State<CliEnv>, opts: &Resume) -> Result<()>
6465
);
6566
};
6667

67-
render_simple_invocation_list(&invocations, DEFAULT_BATCH_INVOCATIONS_OPERATION_LIMIT);
68+
render_simple_invocation_list(
69+
&invocations,
70+
DEFAULT_BATCH_INVOCATIONS_OPERATION_PRINT_LIMIT,
71+
);
6872

6973
// Get the invocation and confirm
7074
confirm_or_exit("Are you sure you want to resume these invocations?")?;
7175

7276
// Resume invocations
73-
let deployment = opts.deployment.as_deref();
74-
let (resumed, failed_to_resume) =
75-
batch_execute(client, invocations, |client, invocation| async move {
77+
let deployment = opts.deployment.clone();
78+
let (resumed, failed_to_resume) = batch_execute(
79+
client,
80+
invocations
81+
.into_iter()
82+
.map(|i| (i, deployment.clone()))
83+
.collect(),
84+
|client, (invocation, deployment)| async move {
7685
client
77-
.resume_invocation(&invocation.id, deployment)
86+
.resume_invocation(&invocation.id, deployment.as_deref())
7887
.await
7988
.map_err(anyhow::Error::from)
80-
})
81-
.await;
89+
},
90+
)
91+
.await;
8292
let succeeded_count = resumed.len();
8393
let failed_count = failed_to_resume.len();
8494

@@ -90,7 +100,7 @@ pub async fn run_resume(State(env): State<CliEnv>, opts: &Resume) -> Result<()>
90100
c_warn!("Failed to resume:");
91101
let mut failed_to_restart_table = Table::new_styled();
92102
failed_to_restart_table.set_styled_header(vec!["ID", "REASON"]);
93-
for (inv, reason) in failed_to_resume {
103+
for ((inv, _), reason) in failed_to_resume {
94104
failed_to_restart_table.add_row(vec![
95105
Cell::new(&inv.id),
96106
Cell::new(reason).fg(Color::DarkRed),

0 commit comments

Comments
 (0)