Skip to content
Open
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
20 changes: 16 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ restate-service-protocol-v4 = { path = "crates/service-protocol-v4" }
restate-storage-api = { path = "crates/storage-api" }
restate-storage-query-datafusion = { path = "crates/storage-query-datafusion" }
restate-test-util = { path = "crates/test-util" }
restate-time-util = { path = "crates/time-util" }
restate-timer = { path = "crates/timer" }
restate-timer-queue = { path = "crates/timer-queue" }
restate-tracing-instrumentation = { path = "crates/tracing-instrumentation" }
Expand Down Expand Up @@ -194,10 +195,10 @@ reqwest = { version = "0.12.5", default-features = false, features = [
"stream",
] }
rlimit = { version = "0.10.1" }
rocksdb = { version = "0.43.0", package = "rust-rocksdb", features = [
rocksdb = { version = "0.43.1", package = "rust-rocksdb", features = [
"multi-threaded-cf",
"jemalloc",
], git = "https://github.com/restatedev/rust-rocksdb", rev = "8873ba40ae687862dbe177e645e7b03c5ce025e3" }
], git = "https://github.com/restatedev/rust-rocksdb", rev = "041bd0dee97c913dc0df2e1e78d5f5715b58e9cf" }
rstest = "0.24.0"
rustls = { version = "0.23.26", default-features = false, features = ["ring"] }
schemars = { version = "0.8", features = ["bytes", "enumset"] }
Expand Down
3 changes: 2 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ restate-admin-rest-model = { workspace = true }
restate-cli-util = { workspace = true }
restate-cloud-tunnel-client = { workspace = true }
restate-serde-util = { workspace = true }
restate-time-util = { workspace = true }
restate-types = { workspace = true }

anyhow = { workspace = true }
Expand Down Expand Up @@ -95,4 +96,4 @@ bench = false

[[bin]]
name = "restate"
path = "src/main.rs"
path = "src/main.rs"
8 changes: 2 additions & 6 deletions cli/src/commands/services/config/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ async fn edit(env: &CliEnv, opts: &Edit) -> Result<()> {
)
.context("Cannot parse the edited config file")?;

super::patch::apply_service_configuration_patch(
opts.service.clone(),
admin_client,
modify_request,
)
.await
super::patch::apply_service_configuration_patch(&opts.service, admin_client, modify_request)
.await
}

// TODO generate this file from the JsonSchema
Expand Down
71 changes: 24 additions & 47 deletions cli/src/commands/services/config/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use anyhow::{Context, Result};
use anyhow::Result;
use cling::prelude::*;
use comfy_table::Table;
use const_format::concatcp;

use restate_admin_rest_model::services::ModifyServiceRequest;
use restate_cli_util::c_println;
use restate_cli_util::ui::console::{StyledTable, confirm_or_exit};
use restate_serde_util::DurationString;
use restate_time_util::{DurationExt, FriendlyDuration};

use crate::cli_env::CliEnv;
use crate::clients::{AdminClient, AdminClientInterface};

pub(super) const DURATION_EDIT_DESCRIPTION: &str = "Can be configured using the jiff \
friendly format (https://docs.rs/jiff/latest/jiff/fmt/friendly/index.html) or ISO8601.";
pub(super) const DURATION_EDIT_DESCRIPTION: &str = "Can be configured using a human friendly \
duration format (e.g. 5d 1h 30m 15s) or ISO8601.";
pub(super) const IDEMPOTENCY_RETENTION_EDIT_DESCRIPTION: &str = concatcp!(
super::view::IDEMPOTENCY_RETENTION,
"\n",
Expand Down Expand Up @@ -53,19 +53,19 @@ pub struct Patch {
public: Option<bool>,

#[clap(long, alias = "idempotency_retention", help = IDEMPOTENCY_RETENTION_EDIT_DESCRIPTION)]
idempotency_retention: Option<String>,
idempotency_retention: Option<FriendlyDuration>,

#[clap(long, alias = "workflow_completion_retention", help = WORKFLOW_RETENTION_EDIT_DESCRIPTION)]
workflow_completion_retention: Option<String>,
workflow_completion_retention: Option<FriendlyDuration>,

#[clap(long, alias = "journal_retention", help = JOURNAL_RETENTION_EDIT_DESCRIPTION)]
journal_retention: Option<String>,
journal_retention: Option<FriendlyDuration>,

#[clap(long, alias = "inactivity_retention", help = INACTIVITY_TIMEOUT_EDIT_DESCRIPTION)]
inactivity_timeout: Option<String>,
#[clap(long, alias = "inactivity_timeout", help = INACTIVITY_TIMEOUT_EDIT_DESCRIPTION)]
inactivity_timeout: Option<FriendlyDuration>,

#[clap(long, alias = "abort_retention", help = ABORT_TIMEOUT_EDIT_DESCRIPTION)]
abort_timeout: Option<String>,
#[clap(long, alias = "abort_timeout", help = ABORT_TIMEOUT_EDIT_DESCRIPTION)]
abort_timeout: Option<FriendlyDuration>,

/// Service name
service: String,
Expand All @@ -79,43 +79,20 @@ async fn patch(env: &CliEnv, opts: &Patch) -> Result<()> {
let admin_client = AdminClient::new(env).await?;
let modify_request = ModifyServiceRequest {
public: opts.public,
idempotency_retention: opts
.idempotency_retention
.as_ref()
.map(|s| {
DurationString::parse_duration(s).context("Cannot parse idempotency_retention")
})
.transpose()?,
idempotency_retention: opts.idempotency_retention.map(FriendlyDuration::to_std),
workflow_completion_retention: opts
.workflow_completion_retention
.as_ref()
.map(|s| {
DurationString::parse_duration(s)
.context("Cannot parse workflow_completion_retention")
})
.transpose()?,
journal_retention: opts
.journal_retention
.as_ref()
.map(|s| DurationString::parse_duration(s).context("Cannot parse journal_retention"))
.transpose()?,
inactivity_timeout: opts
.inactivity_timeout
.as_ref()
.map(|s| DurationString::parse_duration(s).context("Cannot parse inactivity_timeout"))
.transpose()?,
abort_timeout: opts
.abort_timeout
.as_ref()
.map(|s| DurationString::parse_duration(s).context("Cannot parse abort_timeout"))
.transpose()?,
.map(FriendlyDuration::to_std),
journal_retention: opts.journal_retention.map(FriendlyDuration::to_std),
inactivity_timeout: opts.inactivity_timeout.map(FriendlyDuration::to_std),
abort_timeout: opts.abort_timeout.map(FriendlyDuration::to_std),
};

apply_service_configuration_patch(opts.service.clone(), admin_client, modify_request).await
apply_service_configuration_patch(&opts.service, admin_client, modify_request).await
}

pub(super) async fn apply_service_configuration_patch(
service_name: String,
service_name: &str,
admin_client: AdminClient,
modify_request: ModifyServiceRequest,
) -> Result<()> {
Expand All @@ -139,35 +116,35 @@ pub(super) async fn apply_service_configuration_patch(
if let Some(idempotency_retention) = &modify_request.idempotency_retention {
table.add_kv_row(
"Idempotent requests retention:",
DurationString::display(*idempotency_retention),
idempotency_retention.friendly().to_days_span(),
);
}
if let Some(workflow_completion_retention) = &modify_request.workflow_completion_retention {
table.add_kv_row(
"Workflow retention:",
DurationString::display(*workflow_completion_retention),
workflow_completion_retention.friendly().to_days_span(),
);
}
if let Some(journal_retention) = &modify_request.journal_retention {
table.add_kv_row(
"Journal retention:",
DurationString::display(*journal_retention),
journal_retention.friendly().to_days_span(),
);
}
if let Some(inactivity_timeout) = &modify_request.inactivity_timeout {
table.add_kv_row(
"Inactivity timeout:",
DurationString::display(*inactivity_timeout),
inactivity_timeout.friendly().to_days_span(),
);
}
if let Some(abort_timeout) = &modify_request.abort_timeout {
table.add_kv_row("Abort timeout:", DurationString::display(*abort_timeout));
table.add_kv_row("Abort timeout:", abort_timeout.friendly().to_days_span());
}
c_println!("{table}");
confirm_or_exit("Are you sure you want to apply these changes?")?;

let _ = admin_client
.patch_service(&service_name, modify_request)
.patch_service(service_name, modify_request)
.await?
.into_body()
.await?;
Expand Down
31 changes: 13 additions & 18 deletions cli/src/commands/services/config/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use crate::cli_env::CliEnv;
use crate::clients::{AdminClient, AdminClientInterface};
use anyhow::Result;
use cling::prelude::*;
use comfy_table::Table;
use indoc::indoc;

use restate_cli_util::ui::console::StyledTable;
use restate_cli_util::{c_println, c_tip};
use restate_serde_util::DurationString;
use restate_time_util::DurationExt;
use restate_types::invocation::ServiceType;

use crate::cli_env::CliEnv;
use crate::clients::{AdminClient, AdminClientInterface};

// TODO we could infer this text from the OpenAPI docs!
pub(super) const PUBLIC_DESCRIPTION: &str = indoc! {
"Whether the service is publicly available or not.
Expand Down Expand Up @@ -94,7 +96,7 @@ async fn view(env: &CliEnv, opts: &View) -> Result<()> {
let mut table = Table::new_styled();
table.add_kv_row(
"Idempotent requests retention:",
DurationString::display(service.idempotency_retention),
service.idempotency_retention.friendly(),
);
c_println!("{table}");
c_tip!("{}", IDEMPOTENCY_RETENTION);
Expand All @@ -104,11 +106,10 @@ async fn view(env: &CliEnv, opts: &View) -> Result<()> {
let mut table = Table::new_styled();
table.add_kv_row(
"Workflow retention time:",
DurationString::display(
service
.workflow_completion_retention
.expect("Workflows must have a well defined retention"),
),
service
.workflow_completion_retention
.expect("Workflows must have a well defined retention")
.friendly(),
);
c_println!("{table}");
c_tip!("{}", WORKFLOW_RETENTION);
Expand All @@ -120,27 +121,21 @@ async fn view(env: &CliEnv, opts: &View) -> Result<()> {
"Journal retention:",
service
.journal_retention
.map(DurationString::display)
.map(|d| d.friendly().to_string())
.unwrap_or_else(|| "<UNSET>".to_string()),
);
c_println!("{table}");
c_tip!("{}", JOURNAL_RETENTION);
c_println!();

let mut table = Table::new_styled();
table.add_kv_row(
"Inactivity timeout:",
DurationString::display(service.inactivity_timeout),
);
table.add_kv_row("Inactivity timeout:", service.inactivity_timeout.friendly());
c_println!("{table}");
c_tip!("{}", INACTIVITY_TIMEOUT);
c_println!();

let mut table = Table::new_styled();
table.add_kv_row(
"Abort timeout:",
DurationString::display(service.abort_timeout),
);
table.add_kv_row("Abort timeout:", service.abort_timeout.friendly());
c_println!("{table}");
c_tip!("{}", ABORT_TIMEOUT);
c_println!();
Expand Down
1 change: 1 addition & 0 deletions crates/admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ restate-serde-util = { workspace = true }
restate-service-client = { workspace = true }
restate-service-protocol = { workspace = true, features = ["discovery"] }
restate-storage-query-datafusion = { workspace = true }
restate-time-util = { workspace = true }
restate-types = { workspace = true }
restate-wal-protocol = { workspace = true }
restate-web-ui = { git = "https://github.com/restatedev/restate-web-ui-crate", optional = true, version = "0.1.3", tag = "v0.1.3" }
Expand Down
6 changes: 3 additions & 3 deletions crates/admin/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use restate_admin_rest_model::version::AdminApiVersion;
use restate_bifrost::Bifrost;
use restate_core::MetadataWriter;
use restate_core::network::net_util;
use restate_serde_util::DurationString;
use restate_service_client::HttpClient;
use restate_service_protocol::discovery::ServiceDiscovery;
use restate_time_util::DurationExt;
use restate_types::config::AdminOptions;
use restate_types::invocation::client::InvocationClient;
use restate_types::live::LiveLoad;
Expand Down Expand Up @@ -134,7 +134,7 @@ where
name: "access-log",
target: "restate_admin::api",
parent: span,
{ http.response.status_code = response.status().as_u16(), http.response.latency = DurationString::display(latency) },
{ http.response.status_code = response.status().as_u16(), http.response.latency = %latency.friendly().to_seconds_span() },
"Replied"
)
},
Expand All @@ -150,7 +150,7 @@ where
name: "access-log",
target: "restate_admin::api",
parent: span,
{ error.type = error_string, http.response.latency = DurationString::display(latency) },
{ error.type = error_string, http.response.latency = %latency.friendly().to_seconds_span() },
"Failed processing"
)
}
Expand Down
3 changes: 2 additions & 1 deletion crates/ingress-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ restate-workspace-hack = { workspace = true }
restate-core = { workspace = true }
restate-errors = { workspace = true }
restate-serde-util = { workspace = true }
restate-time-util = { workspace = true }
restate-tracing-instrumentation = { workspace = true }
restate-types = { workspace = true }

Expand Down Expand Up @@ -60,4 +61,4 @@ hyper = { workspace = true, features = ["full"] }
hyper-util = { workspace = true, features = ["full"] }
tracing-test = { workspace = true }
tracing-subscriber = { workspace = true }
googletest = { workspace = true }
googletest = { workspace = true }
Loading
Loading