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

Mark replier_id accessor as unstable #1226

Merged
merged 3 commits into from
Jul 16, 2024
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
9 changes: 7 additions & 2 deletions zenoh/src/api/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ use std::{
time::Duration,
};

#[cfg(feature = "unstable")]
use zenoh_config::ZenohId;
use zenoh_core::{Resolvable, Wait};
use zenoh_keyexpr::OwnedKeyExpr;
use zenoh_protocol::core::{CongestionControl, Parameters, ZenohIdProto};
#[cfg(feature = "unstable")]
use zenoh_protocol::core::ZenohIdProto;
use zenoh_protocol::core::{CongestionControl, Parameters};
use zenoh_result::ZResult;

#[zenoh_macros::unstable]
#[cfg(feature = "unstable")]
use super::{
builders::sample::SampleBuilderTrait, bytes::OptionZBytes, sample::SourceInfo,
selector::ZenohParameters,
Expand Down Expand Up @@ -118,6 +121,7 @@ impl From<Value> for ReplyError {
#[derive(Clone, Debug)]
pub struct Reply {
pub(crate) result: Result<Sample, ReplyError>,
#[cfg(feature = "unstable")]
pub(crate) replier_id: Option<ZenohIdProto>,
}

Expand All @@ -137,6 +141,7 @@ impl Reply {
self.result
}

#[zenoh_macros::unstable]
/// Gets the id of the zenoh instance that answered this Reply.
pub fn replier_id(&self) -> Option<ZenohId> {
self.replier_id.map(Into::into)
Expand Down
8 changes: 7 additions & 1 deletion zenoh/src/api/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,7 @@ impl Session {
self.task_controller
.spawn_with_rt(zenoh_runtime::ZRuntime::Net, {
let state = self.state.clone();
#[cfg(feature = "unstable")]
let zid = self.runtime.zid();
async move {
tokio::select! {
Expand All @@ -1775,6 +1776,7 @@ impl Session {
}
(query.callback)(Reply {
result: Err(Value::new("Timeout", Encoding::ZENOH_STRING).into()),
#[cfg(feature = "unstable")]
replier_id: Some(zid.into()),
});
}
Expand Down Expand Up @@ -1874,6 +1876,7 @@ impl Session {
tracing::debug!("Timeout on liveliness query {}! Send error and close.", id);
(query.callback)(Reply {
result: Err(Value::new("Timeout", Encoding::ZENOH_STRING).into()),
#[cfg(feature = "unstable")]
replier_id: Some(zid.into()),
});
}
Expand Down Expand Up @@ -2238,6 +2241,7 @@ impl Primitives for Session {
#[cfg(feature = "unstable")]
attachment: None,
}),
#[cfg(feature = "unstable")]
replier_id: None,
};

Expand Down Expand Up @@ -2404,8 +2408,9 @@ impl Primitives for Session {
encoding: e.encoding.into(),
};
let new_reply = Reply {
replier_id: e.ext_sinfo.map(|info| info.id.zid),
result: Err(value.into()),
#[cfg(feature = "unstable")]
replier_id: e.ext_sinfo.map(|info| info.id.zid),
};
callback(new_reply);
}
Expand Down Expand Up @@ -2487,6 +2492,7 @@ impl Primitives for Session {
let sample = info.into_sample(key_expr.into_owned(), payload, attachment);
let new_reply = Reply {
result: Ok(sample),
#[cfg(feature = "unstable")]
replier_id: None,
};
let callback =
Expand Down
Loading