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

Clean-up of QoS defaults #727

Closed
wants to merge 3 commits into from
Closed
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
1 change: 0 additions & 1 deletion commons/zenoh-codec/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@
// ZettaScale Zenoh Team, <[email protected]>
//
pub mod extension;
mod priority;
66 changes: 0 additions & 66 deletions commons/zenoh-codec/src/common/priority.rs

This file was deleted.

15 changes: 0 additions & 15 deletions commons/zenoh-protocol/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ pub use extension::*;
/*************************************/
// Inner Message IDs
pub mod imsg {
pub mod id {
// Zenoh Messages
pub const DECLARE: u8 = 0x0b;
pub const DATA: u8 = 0x0c;
pub const QUERY: u8 = 0x0d;
pub const PULL: u8 = 0x0e;
pub const UNIT: u8 = 0x0f;
pub const LINK_STATE_LIST: u8 = 0x10;

// Message decorators
pub const PRIORITY: u8 = 0x1c;
pub const ROUTING_CONTEXT: u8 = 0x1d;
pub const REPLY_CONTEXT: u8 = 0x1e;
}

// Header mask
pub const HEADER_BITS: u8 = 5;
pub const HEADER_MASK: u8 = !(0xff << HEADER_BITS);
Expand Down
2 changes: 2 additions & 0 deletions commons/zenoh-protocol/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ pub enum Priority {
}

impl Priority {
/// Default
pub const DEFAULT: Self = Self::Data;
/// The lowest Priority
pub const MIN: Self = Self::Background;
/// The highest Priority
Expand Down
32 changes: 8 additions & 24 deletions commons/zenoh-protocol/src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ pub mod ext {
const D_FLAG: u8 = 0b00001000;
const E_FLAG: u8 = 0b00010000;

pub const DECLARE: Self = Self::new(Priority::DEFAULT, 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::DEFAULT, CongestionControl::Block, false);

pub const fn new(
priority: Priority,
congestion_control: CongestionControl,
Expand Down Expand Up @@ -275,30 +283,6 @@ pub mod ext {
let inner: u8 = rng.gen();
Self { inner }
}

pub fn declare_default() -> Self {
Self::new(Priority::default(), CongestionControl::Block, false)
}

pub fn push_default() -> Self {
Self::new(Priority::default(), CongestionControl::Drop, false)
}

pub fn request_default() -> Self {
Self::new(Priority::default(), CongestionControl::Block, false)
}

pub fn response_default() -> Self {
Self::new(Priority::default(), CongestionControl::Block, false)
}

pub fn response_final_default() -> Self {
Self::new(Priority::default(), CongestionControl::Block, false)
}

pub fn oam_default() -> Self {
Self::new(Priority::default(), CongestionControl::Block, false)
}
}

impl<const ID: u8> Default for QoSType<{ ID }> {
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/key_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ impl SyncResolve for KeyExprUndeclaration<'_> {
let primitives = state.primitives.as_ref().unwrap().clone();
drop(state);
primitives.send_declare(zenoh_protocol::network::Declare {
ext_qos: declare::ext::QoSType::declare_default(),
ext_qos: declare::ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: declare::ext::NodeIdType::default(),
body: DeclareBody::UndeclareKeyExpr(UndeclareKeyExpr { id: expr_id }),
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ pub fn pull_data(tables_ref: &RwLock<Tables>, face: &Arc<FaceState>, expr: WireE
for (key_expr, payload) in route {
face.primitives.send_push(Push {
wire_expr: key_expr,
ext_qos: ext::QoSType::push_default(),
ext_qos: ext::QoSType::PUSH,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
payload,
Expand Down
16 changes: 8 additions & 8 deletions zenoh/src/net/routing/dispatcher/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ pub fn route_query(
rid: qid,
wire_expr: wexpr,
payload,
ext_qos: response::ext::QoSType::declare_default(),
ext_qos: response::ext::QoSType::DECLARE,
ext_tstamp: None,
ext_respid: Some(response::ext::ResponderIdType {
zid,
Expand All @@ -583,7 +583,7 @@ pub fn route_query(
.send_response_final(RoutingContext::with_expr(
ResponseFinal {
rid: qid,
ext_qos: response::ext::QoSType::response_final_default(),
ext_qos: response::ext::QoSType::RESPONSE_FINAL,
ext_tstamp: None,
},
expr.full_expr().to_string(),
Expand Down Expand Up @@ -614,7 +614,7 @@ pub fn route_query(
Request {
id: *qid,
wire_expr: key_expr.into(),
ext_qos: ext::QoSType::request_default(),
ext_qos: ext::QoSType::REQUEST,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType { node_id: *context },
ext_target: *t,
Expand Down Expand Up @@ -650,7 +650,7 @@ pub fn route_query(
Request {
id: *qid,
wire_expr: key_expr.into(),
ext_qos: ext::QoSType::request_default(),
ext_qos: ext::QoSType::REQUEST,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType { node_id: *context },
ext_target: target,
Expand All @@ -671,7 +671,7 @@ pub fn route_query(
.send_response_final(RoutingContext::with_expr(
ResponseFinal {
rid: qid,
ext_qos: response::ext::QoSType::response_final_default(),
ext_qos: response::ext::QoSType::RESPONSE_FINAL,
ext_tstamp: None,
},
expr.full_expr().to_string(),
Expand All @@ -689,7 +689,7 @@ pub fn route_query(
.send_response_final(RoutingContext::with_expr(
ResponseFinal {
rid: qid,
ext_qos: response::ext::QoSType::response_final_default(),
ext_qos: response::ext::QoSType::RESPONSE_FINAL,
ext_tstamp: None,
},
"".to_string(),
Expand Down Expand Up @@ -736,7 +736,7 @@ pub(crate) fn route_send_response(
rid: query.src_qid,
wire_expr: key_expr.to_owned(),
payload: body,
ext_qos: response::ext::QoSType::response_default(),
ext_qos: response::ext::QoSType::RESPONSE,
ext_tstamp: None,
ext_respid,
},
Expand Down Expand Up @@ -796,7 +796,7 @@ pub(crate) fn finalize_pending_query(query: Arc<Query>) {
.send_response_final(RoutingContext::with_expr(
ResponseFinal {
rid: query.src_qid,
ext_qos: response::ext::QoSType::response_final_default(),
ext_qos: response::ext::QoSType::RESPONSE_FINAL,
ext_tstamp: None,
},
"".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ impl Resource {
.insert(expr_id, nonwild_prefix.clone());
face.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::DeclareKeyExpr(DeclareKeyExpr {
Expand Down
8 changes: 4 additions & 4 deletions zenoh/src/net/routing/hat/client/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn propagate_simple_subscription_to(
let key_expr = Resource::decl_key(res, dst_face);
dst_face.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::DeclareSubscriber(DeclareSubscriber {
Expand Down Expand Up @@ -137,7 +137,7 @@ fn declare_client_subscription(
.primitives
.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::DeclareSubscriber(DeclareSubscriber {
Expand Down Expand Up @@ -171,7 +171,7 @@ fn propagate_forget_simple_subscription(tables: &mut Tables, res: &Arc<Resource>
let wire_expr = Resource::get_best_key(res, "", face.id);
face.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::UndeclareSubscriber(UndeclareSubscriber {
Expand Down Expand Up @@ -209,7 +209,7 @@ pub(super) fn undeclare_client_subscription(
let wire_expr = Resource::get_best_key(res, "", face.id);
face.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::UndeclareSubscriber(UndeclareSubscriber {
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/net/routing/hat/client/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn propagate_simple_queryable(
let key_expr = Resource::decl_key(res, &mut dst_face);
dst_face.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::DeclareQueryable(DeclareQueryable {
Expand Down Expand Up @@ -166,7 +166,7 @@ fn propagate_forget_simple_queryable(tables: &mut Tables, res: &mut Arc<Resource
let wire_expr = Resource::get_best_key(res, "", face.id);
face.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::UndeclareQueryable(UndeclareQueryable {
Expand Down Expand Up @@ -207,7 +207,7 @@ pub(super) fn undeclare_client_queryable(
let wire_expr = Resource::get_best_key(res, "", face.id);
face.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::UndeclareQueryable(UndeclareQueryable {
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/hat/linkstate_peer/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl Network {
Ok(NetworkBody::OAM(Oam {
id: OAM_LINKSTATE,
body: ZExtBody::ZBuf(buf),
ext_qos: oam::ext::QoSType::oam_default(),
ext_qos: oam::ext::QoSType::OAM,
ext_tstamp: None,
})
.into())
Expand Down
12 changes: 6 additions & 6 deletions zenoh/src/net/routing/hat/linkstate_peer/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn send_sourced_subscription_to_net_childs(

someface.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType {
node_id: routing_context,
Expand Down Expand Up @@ -94,7 +94,7 @@ fn propagate_simple_subscription_to(
let key_expr = Resource::decl_key(res, dst_face);
dst_face.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::DeclareSubscriber(DeclareSubscriber {
Expand Down Expand Up @@ -291,7 +291,7 @@ fn send_forget_sourced_subscription_to_net_childs(

someface.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType {
node_id: routing_context.unwrap_or(0),
Expand All @@ -317,7 +317,7 @@ fn propagate_forget_simple_subscription(tables: &mut Tables, res: &Arc<Resource>
let wire_expr = Resource::get_best_key(res, "", face.id);
face.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::UndeclareSubscriber(UndeclareSubscriber {
Expand Down Expand Up @@ -431,7 +431,7 @@ pub(super) fn undeclare_client_subscription(
let wire_expr = Resource::get_best_key(res, "", face.id);
face.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::UndeclareSubscriber(UndeclareSubscriber {
Expand Down Expand Up @@ -467,7 +467,7 @@ pub(super) fn pubsub_new_face(tables: &mut Tables, face: &mut Arc<FaceState>) {
let key_expr = Resource::decl_key(sub, face);
face.primitives.send_declare(RoutingContext::with_expr(
Declare {
ext_qos: ext::QoSType::declare_default(),
ext_qos: ext::QoSType::DECLARE,
ext_tstamp: None,
ext_nodeid: ext::NodeIdType::default(),
body: DeclareBody::DeclareSubscriber(DeclareSubscriber {
Expand Down
Loading