Skip to content

Commit

Permalink
Doc and confguration update
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Feb 14, 2024
1 parent 814d701 commit d9e75ba
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 37 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ aes = "0.8.2"
ahash = "0.8.7"
anyhow = { version = "1.0.69", default-features = false } # Default features are disabled due to usage in no_std crates
async-executor = "1.5.0"
async-liveliness-monitor = "0.1.1"
async-global-executor = "2.3.1"
async-io = "=1.13.0"
async-rustls = "0.4.0"
Expand Down
33 changes: 13 additions & 20 deletions DEFAULT_CONFIG.json5
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,19 @@
// ],
// },

// /// The declarations downsampling strategy.
// downsampling: {
// items:
// [
// {
// strategy: "ratelimit",
// // A list of key expressions, only messages matching this expression will be processed, the rest will be passed as is.
// keyexprs: [
// // key_expression
// ],
// // A list of network interfaces messages will be processed on, the rest will be passed as is.
// interfaces: [
// // network interface name
// ],
// // Threshold indicates the minimum interval between messages.
// // All messages arriving with a smaller interval will be skipped
// threshold_ms: 1000,
// },
// ],
// },
// /// The downsampling declaration.
// downsampling: [
// {
// /// A list of network interfaces messages will be processed on, the rest will be passed as is.
// interfaces: [ "wlan0" ],
// /// Data flow messages will be processed on. ("egress" or "ingress")
// flow: "egress",
// /// A list of downsampling rules: key_expression and the rate (maximum frequency in Hertz)
// rules: [
// { key_expr: "demo/example/zenoh-rs-pub", rate: 0.1 },
// ],
// },
// ],

/// Configure internal transport parameters
transport: {
Expand Down
2 changes: 1 addition & 1 deletion commons/zenoh-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub enum DownsamplingFlow {
pub struct DownsamplingRuleConf {
/// A list of key-expressions to which the downsampling will be applied.
/// Downsampling will be applied for all key extensions if the parameter is None
pub keyexpr: OwnedKeyExpr,
pub key_expr: OwnedKeyExpr,
/// The maximum frequency in Hertz;
pub rate: f64,
}
Expand Down
1 change: 0 additions & 1 deletion zenoh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ default = [

[dependencies]
async-global-executor = { workspace = true }
async-liveliness-monitor = { workspace = true }
async-std = { workspace = true, features = ["attributes"] }
async-trait = { workspace = true }
base64 = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/net/routing/interceptor/downsampling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ impl InterceptorTrait for DownsamplingInterceptor {
ctx: RoutingContext<NetworkMessage>,
) -> Option<RoutingContext<NetworkMessage>> {
if matches!(ctx.msg.body, NetworkBody::Push(_)) {
if let Some(keyexpr) = ctx.full_key_expr() {
if let Some(key_expr) = ctx.full_key_expr() {
let mut ke_state = zlock!(self.ke_state);
if let Some(state) = ke_state.weight_at_mut(&keyexpr.clone()) {
if let Some(state) = ke_state.weight_at_mut(&key_expr.clone()) {
let timestamp = std::time::Instant::now();

if timestamp - state.latest_message_timestamp >= state.threshold {
Expand Down Expand Up @@ -152,7 +152,7 @@ impl DownsamplingInterceptor {
latest_message_timestamp -= threshold;
}
ke_state.insert(
&rule.keyexpr,
&rule.key_expr,
Timestate {
threshold,
latest_message_timestamp,
Expand Down
8 changes: 4 additions & 4 deletions zenoh/tests/interceptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ fn downsampling_by_keyexpr() {
{
flow: "egress",
rules: [
{ keyexpr: "test/downsamples_by_keyexp/r100", rate: 10, },
{ keyexpr: "test/downsamples_by_keyexp/r50", rate: 20, }
{ key_expr: "test/downsamples_by_keyexp/r100", rate: 10, },
{ key_expr: "test/downsamples_by_keyexp/r50", rate: 20, }
],
},
]
Expand Down Expand Up @@ -173,14 +173,14 @@ fn downsampling_by_interface() {
interfaces: ["lo", "lo0"],
flow: "egress",
rules: [
{ keyexpr: "test/downsamples_by_interface/r100", rate: 10, },
{ key_expr: "test/downsamples_by_interface/r100", rate: 10, },
],
},
{
interfaces: ["some_unknown_interface"],
flow: "egress",
rules: [
{ keyexpr: "test/downsamples_by_interface/all", rate: 10, },
{ key_expr: "test/downsamples_by_interface/all", rate: 10, },
],
},
]
Expand Down

0 comments on commit d9e75ba

Please sign in to comment.