Skip to content

Commit

Permalink
Expose different congestion control defaults as internal (#1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mallets authored Feb 12, 2025
1 parent bbb9689 commit 024bcf5
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 12 deletions.
3 changes: 2 additions & 1 deletion commons/zenoh-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ description = "Internal crate for zenoh."

[features]
default = ["std"]
internal = []
std = [
"rand?/std",
"rand?/std_rng",
Expand All @@ -33,9 +34,9 @@ std = [
"zenoh-keyexpr/std",
"zenoh-result/std",
]
test = ["rand", "zenoh-buffers/test"]
shared-memory = ["std", "zenoh-buffers/shared-memory"]
stats = []
test = ["rand", "zenoh-buffers/test"]

[dependencies]
const_format = { workspace = true }
Expand Down
25 changes: 25 additions & 0 deletions commons/zenoh-protocol/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,31 @@ pub enum CongestionControl {

impl CongestionControl {
pub const DEFAULT: Self = Self::Drop;

#[cfg(feature = "internal")]
pub const DEFAULT_PUSH: Self = Self::Drop;
#[cfg(not(feature = "internal"))]
pub(crate) const DEFAULT_PUSH: Self = Self::Drop;

#[cfg(feature = "internal")]
pub const DEFAULT_REQUEST: Self = Self::Block;
#[cfg(not(feature = "internal"))]
pub(crate) const DEFAULT_REQUEST: Self = Self::Block;

#[cfg(feature = "internal")]
pub const DEFAULT_RESPONSE: Self = Self::Block;
#[cfg(not(feature = "internal"))]
pub(crate) const DEFAULT_RESPONSE: Self = Self::Block;

#[cfg(feature = "internal")]
pub const DEFAULT_DECLARE: Self = Self::Block;
#[cfg(not(feature = "internal"))]
pub(crate) const DEFAULT_DECLARE: Self = Self::Block;

#[cfg(feature = "internal")]
pub const DEFAULT_OAM: Self = Self::Block;
#[cfg(not(feature = "internal"))]
pub(crate) const DEFAULT_OAM: Self = Self::Block;
}

#[cfg(test)]
Expand Down
23 changes: 16 additions & 7 deletions commons/zenoh-protocol/src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,22 @@ pub mod ext {

pub const DEFAULT: Self = Self::new(Priority::DEFAULT, CongestionControl::DEFAULT, false);

pub const DECLARE: Self = Self::new(Priority::Control, CongestionControl::Block, false);
pub const PUSH: Self = Self::new(Priority::DEFAULT, CongestionControl::Drop, false);
pub const REQUEST: Self = Self::new(Priority::DEFAULT, CongestionControl::Block, false);
pub const RESPONSE: Self = Self::new(Priority::DEFAULT, CongestionControl::Block, false);
pub const RESPONSE_FINAL: Self =
Self::new(Priority::DEFAULT, CongestionControl::Block, false);
pub const OAM: Self = Self::new(Priority::Control, CongestionControl::Block, false);
pub const DECLARE: Self =
Self::new(Priority::Control, CongestionControl::DEFAULT_DECLARE, false);
pub const PUSH: Self = Self::new(Priority::DEFAULT, CongestionControl::DEFAULT_PUSH, false);
pub const REQUEST: Self =
Self::new(Priority::DEFAULT, CongestionControl::DEFAULT_REQUEST, false);
pub const RESPONSE: Self = Self::new(
Priority::DEFAULT,
CongestionControl::DEFAULT_RESPONSE,
false,
);
pub const RESPONSE_FINAL: Self = Self::new(
Priority::DEFAULT,
CongestionControl::DEFAULT_RESPONSE,
false,
);
pub const OAM: Self = Self::new(Priority::Control, CongestionControl::DEFAULT_OAM, false);

pub const fn new(
priority: Priority,
Expand Down
19 changes: 15 additions & 4 deletions zenoh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ default = [
"transport_tls",
"transport_udp",
"transport_unixsock-stream",
"transport_ws"
"transport_ws",
]
internal = [
"zenoh-keyexpr/internal",
"zenoh-config/internal",
"zenoh-protocol/internal",
]
internal = ["zenoh-keyexpr/internal", "zenoh-config/internal"]
plugins = []
runtime_plugins = ["plugins"]
shared-memory = [
Expand All @@ -64,9 +68,16 @@ transport_udp = ["zenoh-transport/transport_udp"]
transport_unixsock-stream = ["zenoh-transport/transport_unixsock-stream"]
transport_ws = ["zenoh-transport/transport_ws"]
transport_vsock = ["zenoh-transport/transport_vsock"]
unstable = ["internal_config", "zenoh-keyexpr/unstable", "zenoh-config/unstable"]
unstable = [
"internal_config",
"zenoh-keyexpr/unstable",
"zenoh-config/unstable",
]
internal_config = []
tracing-instrument = ["zenoh-task/tracing-instrument", "zenoh-runtime/tracing-instrument"]
tracing-instrument = [
"zenoh-task/tracing-instrument",
"zenoh-runtime/tracing-instrument",
]

[dependencies]
tokio = { workspace = true, features = ["rt", "macros", "time"] }
Expand Down

0 comments on commit 024bcf5

Please sign in to comment.