Skip to content
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
4 changes: 2 additions & 2 deletions cargo-prosa/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-prosa"
version = "0.4.0"
version = "0.4.1"
authors.workspace = true
description = "ProSA utility to package and deliver a builded ProSA"
homepage.workspace = true
Expand All @@ -19,7 +19,7 @@ clap = "4"
clap_complete = "4"
serde.workspace = true
toml.workspace = true
toml_edit = { version = "0.23", features = ["serde"] }
toml_edit = { version = "0.25", features = ["serde"] }
serde_json = "1"
tera = "1"

Expand Down
14 changes: 6 additions & 8 deletions cargo-prosa/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,22 @@ fn init_prosa(path: &str, context: &tera::Context) -> io::Result<()> {
metadata_table.insert("generate-rpm", toml_edit::Item::Table(rpm_table));
}
} else {
let mut metadata_table = toml_edit::Table::new();
metadata_table.set_implicit(true);

if deb_pkg {
let mut deb_table = toml_edit::Table::new();
DebPkg::add_deb_pkg_metadata(&mut deb_table, name);

let mut metadata_table = toml_edit::Table::new();
metadata_table.set_implicit(true);
metadata_table.insert("deb", toml_edit::Item::Table(deb_table));

package_table.insert("metadata", toml_edit::Item::Table(metadata_table));
}

if rpm_pkg {
let mut rpm_table = toml_edit::Table::new();
RpmPkg::add_rpm_pkg_metadata(&mut rpm_table, name);

let mut metadata_table = toml_edit::Table::new();
metadata_table.set_implicit(true);
metadata_table.insert("generate-rpm", toml_edit::Item::Table(rpm_table));
}

if deb_pkg || rpm_pkg {
package_table.insert("metadata", toml_edit::Item::Table(metadata_table));
}
}
Expand Down
4 changes: 2 additions & 2 deletions prosa/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prosa"
version = "0.4.1"
version = "0.4.2"
authors.workspace = true
description = "ProSA core"
homepage.workspace = true
Expand Down Expand Up @@ -46,7 +46,7 @@ log.workspace = true
tracing = "0.1"
thiserror.workspace = true
url = { version = "2", features = ["serde"] }
rlimit = "0.10"
rlimit = "0.11"

aquamarine.workspace = true

Expand Down
4 changes: 2 additions & 2 deletions prosa/src/core/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ where
/// Can be call only by the main task to modify the service table
pub fn remove_service(&mut self, name: &str, proc_id: u32, queue_id: u32) {
if let Some((services, _)) = self.table.get_mut(name) {
services.retain(|s| s.proc_id != proc_id && s.queue_id != queue_id);
services.retain(|s| s.proc_id != proc_id || s.queue_id != queue_id);
}
}

Expand All @@ -138,7 +138,7 @@ where
pub fn remove_proc_queue_services(&mut self, proc_id: u32, queue_id: u32) {
// This will let service with empty processors
for (services, _) in self.table.values_mut() {
services.retain(|s| s.proc_id != proc_id && s.queue_id != queue_id);
services.retain(|s| s.proc_id != proc_id || s.queue_id != queue_id);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion prosa/src/event/queue/timed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ macro_rules! spmc {
impl<T, const N: usize> $sender<T, N> {
/// Method to check if timer are still on existing items
fn timers_retain(&mut self, head: $p, id: $p) {
let tail = id + 1 % self.queue.max_capacity();
let tail = (id + 1) % self.queue.max_capacity();
self.timers.retain(|t| prosa_utils::id_in_queue!(t, head, tail));
}

Expand Down
19 changes: 12 additions & 7 deletions prosa/src/event/speed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,18 @@ impl Speed {
}
}

/// Getter of the duration time it must wait since the last event to target the given TPS (Transaction Per Seconds) rate
/// Consider an overhead to get a lasy duration to not overwhelmed a distant
/// TPS should be superior to 0 otherwise it'll panic
/// Duration equal 0 if the result is negative
/// Returns the duration to wait since the last event to achieve the target TPS (Transactions Per Second).
/// Includes a small overhead to ensure a conservative duration and avoid overwhelming a remote system.
/// If TPS is not positive or finite, returns `Duration::MAX`.
/// Returns `Duration::ZERO` if the calculated duration is negative.
///
/// <math><mfrac><mi>1000 × <msub><mi>N</mi><mn>t</mn></msub></mi><mi>TPS</mi></mfrac> + overhead − <msub><mi>Σ</mi><mn>t</mn></msub> = duration</math>
pub fn get_duration_overhead(&self, tps: f64, overhead: Option<Duration>) -> Duration {
// Guard against invalid TPS values to prevent division by zero or invalid computation
if tps <= 0.0 || !tps.is_finite() {
return Duration::MAX;
}

let duration =
Duration::from_millis(((1000 * self.event_speeds.len()) as f64 / tps) as u64);
let sum_duration = self.accumulate_event_speeds();
Expand All @@ -135,9 +140,9 @@ impl Speed {
}
}

/// Getter of the duration time it must wait since the last event to target the given TPS (Transaction Per Seconds) rate
/// TPS should be superior to 0 otherwise it'll panic
/// Duration equal 0 if the result is negative
/// Returns the duration to wait since the last event to achieve the target TPS (Transactions Per Second).
/// If TPS is not positive or finite, returns `Duration::MAX`.
/// Returns `Duration::ZERO` if the calculated duration is negative.
///
/// <math><mfrac><mi>1000 × <msub><mi>N</mi><mn>t</mn></msub></mi><mi>TPS</mi></mfrac> − <msub><mi>Σ</mi><mn>t</mn></msub> = duration</math>
pub fn get_duration(&self, tps: f64) -> Duration {
Expand Down
2 changes: 1 addition & 1 deletion prosa_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ openssl = { workspace = true, optional = true }
# Config Observability
log = { workspace = true, optional = true }
tracing-core = { version = "0.1", optional = true }
tracing-subscriber = { version = "0.3", features = ["std", "env-filter"], optional = true }
tracing-subscriber = { version = ">=0.3.20, < 0.4", features = ["std", "env-filter"], optional = true }
tracing-opentelemetry = { version = "0.32.1", optional = true }
opentelemetry = { workspace = true, optional = true }
opentelemetry_sdk = { workspace = true, optional = true }
Expand Down
Loading