Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select links based on message Priority & Reliability #1360

Closed
wants to merge 37 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cbe6d2a
Add wip `QoS`-based priority-to-link dispatch impl
fuzzypixelz Aug 26, 2024
5cfcf55
Improve `QoS` state machine
fuzzypixelz Sep 4, 2024
1c9ee29
Add `PriorityRange` negotiation tests
fuzzypixelz Sep 4, 2024
162e356
Refactor link selection function
fuzzypixelz Sep 4, 2024
2f3b821
Minor edits
fuzzypixelz Sep 4, 2024
8b3eff1
Add Link selectioh tests
fuzzypixelz Sep 4, 2024
22e7807
Minor edits
fuzzypixelz Sep 4, 2024
3c9af4c
More minor edits
fuzzypixelz Sep 4, 2024
20a6169
Never disobey Clippy
fuzzypixelz Sep 4, 2024
8ac3ea8
Implement Reliability negotiation
fuzzypixelz Sep 4, 2024
af43d88
Apply negotiated Reliability to Link config
fuzzypixelz Sep 5, 2024
7e26110
Document Endpoint `reliability` metadata
fuzzypixelz Sep 5, 2024
b559fa7
I'm sorry Clippy
fuzzypixelz Sep 5, 2024
e98fb4f
Make `PriorityRange` inclusive
fuzzypixelz Sep 5, 2024
02a6cba
Clippy lints are inevitable
fuzzypixelz Sep 5, 2024
1758b20
Make Reliability negotiation stricter
fuzzypixelz Sep 5, 2024
c5078bd
Refactor negotiation tests
fuzzypixelz Sep 5, 2024
d374992
We are still not `core::error::Error`
fuzzypixelz Sep 5, 2024
ab64d0f
Use `RangeInclusive`
fuzzypixelz Sep 5, 2024
2f9edc1
Clippy at it again
fuzzypixelz Sep 5, 2024
a941021
Split `State` into `StateOpen` and `StateAccept`
fuzzypixelz Sep 6, 2024
fd7b050
Remove `NewLinkUnicast`
fuzzypixelz Sep 6, 2024
2e3285d
Fix test typos
fuzzypixelz Sep 6, 2024
3c2d578
Patch `Link::src` and `Link::dst` with negotiated metadata
fuzzypixelz Sep 6, 2024
877f61d
Optimize `QoS` extension overhead
fuzzypixelz Sep 6, 2024
50a4333
Implement `Display` instead of `ToString` for `PriorityRange`
fuzzypixelz Sep 6, 2024
d07275a
Fix typo (metdata -> metadata)
fuzzypixelz Sep 6, 2024
5083b94
Fix `n_exts` in `INIT` codec
fuzzypixelz Sep 6, 2024
ed4b555
Add missing `'static` lifetime in const
fuzzypixelz Sep 6, 2024
4ec1396
Don't compare `Link` to `TransportLinkUnicast`
fuzzypixelz Sep 9, 2024
3e32185
Don't set Link Reliability if not configured
fuzzypixelz Sep 9, 2024
8889d1a
Update DEFAULT_CONFIG
fuzzypixelz Sep 16, 2024
c91a052
Move metadata docs to `Endpoint`
fuzzypixelz Sep 17, 2024
00ae24b
Add Endpoint examples
fuzzypixelz Sep 17, 2024
e14c023
Fix doc list items without indentation
fuzzypixelz Sep 17, 2024
a80e035
Update Endpoint links in DEFAULT_CONFIG
fuzzypixelz Sep 20, 2024
b18e8d5
Change `x..=y` syntax to `x-y`
fuzzypixelz Sep 23, 2024
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
Prev Previous commit
Next Next commit
Implement Reliability negotiation
  • Loading branch information
fuzzypixelz committed Sep 23, 2024
commit 8ac3ea83737667ce88ec981f970713cfe507c399
51 changes: 50 additions & 1 deletion commons/zenoh-protocol/src/core/mod.rs
Original file line number Diff line number Diff line change
@@ -19,10 +19,11 @@ use alloc::{
};
use core::{
convert::{From, TryFrom, TryInto},
fmt,
fmt::{self, Display},
hash::Hash,
str::FromStr,
};
use std::error::Error;

use serde::Serialize;
pub use uhlc::{Timestamp, NTP64};
@@ -406,6 +407,14 @@ pub enum Reliability {
impl Reliability {
pub const DEFAULT: Self = Self::Reliable;

/// Returns `true` is `self` implies `other`.
pub fn implies(self, other: Self) -> bool {
match (self, other) {
(Reliability::Reliable, Reliability::BestEffort) => false,
_ => true,
}
}

#[cfg(feature = "test")]
pub fn rand() -> Self {
use rand::Rng;
@@ -430,6 +439,46 @@ impl From<bool> for Reliability {
}
}

impl From<Reliability> for bool {
fn from(value: Reliability) -> Self {
match value {
Reliability::BestEffort => false,
Reliability::Reliable => true,
}
}
}

#[derive(Debug)]
pub struct InvalidReliability {
found: String,
}

impl Display for InvalidReliability {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"invalid Reliability string, expected `best_effort` or `reliable` but found {}",
self.found
)
}
}

impl Error for InvalidReliability {}

impl FromStr for Reliability {
type Err = InvalidReliability;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"reliable" => Ok(Reliability::Reliable),
"best_effort" => Ok(Reliability::BestEffort),
other => Err(InvalidReliability {
found: other.to_string(),
}),
}
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
pub struct Channel {
pub priority: Priority,
Loading