From 99384e3b32e045da896c9535852bb68507b28db1 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 9 Mar 2023 13:21:26 +0100 Subject: [PATCH] Remove iceoryx dependency We now have our own shared memory implementation. --- Cargo.lock | 71 -------- .../communication-layer/pub-sub/Cargo.toml | 7 +- .../pub-sub/src/iceoryx.rs | 158 ------------------ .../communication-layer/pub-sub/src/lib.rs | 5 - libraries/core/src/config.rs | 11 -- 5 files changed, 1 insertion(+), 251 deletions(-) delete mode 100644 libraries/communication-layer/pub-sub/src/iceoryx.rs diff --git a/Cargo.lock b/Cargo.lock index e87386c1..4f66a7ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -567,8 +567,6 @@ name = "communication-layer-pub-sub" version = "0.1.3" dependencies = [ "eyre", - "iceoryx-rs", - "iceoryx-sys", "zenoh", "zenoh-config", ] @@ -611,56 +609,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" -[[package]] -name = "cpp" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec5e86d4f6547f0218ad923d9508244a71ef83b763196e6698b4f70f3595185" -dependencies = [ - "cpp_macros", -] - -[[package]] -name = "cpp_build" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f4d303b8ec35fb3afd7e963e2c898117f1e49930becb703e4a7ac528ad2dd0" -dependencies = [ - "cc", - "cpp_common", - "lazy_static", - "proc-macro2", - "regex", - "syn", - "unicode-xid", -] - -[[package]] -name = "cpp_common" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76071bb9c8c4dd2b5eb209907deab7b031323cf1be3dfdc6ec5d37f4f187d8a1" -dependencies = [ - "lazy_static", - "proc-macro2", - "syn", -] - -[[package]] -name = "cpp_macros" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdaa01904c12a8989dbfa110b41ef27efc432ac9934f691b9732f01cb64dc01" -dependencies = [ - "aho-corasick", - "byteorder", - "cpp_common", - "lazy_static", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "cpufeatures" version = "0.2.2" @@ -1713,25 +1661,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "iceoryx-rs" -version = "0.1.0" -source = "git+https://github.com/eclipse-iceoryx/iceoryx-rs.git#68fbd034a77c6ed98cb75a939d406429ef26b0dd" -dependencies = [ - "iceoryx-sys", - "thiserror", -] - -[[package]] -name = "iceoryx-sys" -version = "0.1.0" -source = "git+https://github.com/eclipse-iceoryx/iceoryx-rs.git#68fbd034a77c6ed98cb75a939d406429ef26b0dd" -dependencies = [ - "cpp", - "cpp_build", - "thiserror", -] - [[package]] name = "idna" version = "0.2.3" diff --git a/libraries/communication-layer/pub-sub/Cargo.toml b/libraries/communication-layer/pub-sub/Cargo.toml index 8eb1c92e..39cdca15 100644 --- a/libraries/communication-layer/pub-sub/Cargo.toml +++ b/libraries/communication-layer/pub-sub/Cargo.toml @@ -4,19 +4,14 @@ version.workspace = true edition = "2021" [features] -default = ["zenoh", "iceoryx"] +default = ["zenoh"] zenoh = ["dep:zenoh", "dep:zenoh-config"] -iceoryx = ["dep:iceoryx-rs", "dep:iceoryx-sys"] [dependencies] eyre = "0.6.8" zenoh = { git = "https://github.com/eclipse-zenoh/zenoh.git", rev = "79a136e4fd90b11ff5d775ced981af53c4f1071b", optional = true } zenoh-config = { git = "https://github.com/eclipse-zenoh/zenoh.git", rev = "79a136e4fd90b11ff5d775ced981af53c4f1071b", optional = true } -[target.'cfg(unix)'.dependencies] -iceoryx-rs = { git = "https://github.com/eclipse-iceoryx/iceoryx-rs.git", optional = true } -iceoryx-sys = { git = "https://github.com/eclipse-iceoryx/iceoryx-rs.git", optional = true } - [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] diff --git a/libraries/communication-layer/pub-sub/src/iceoryx.rs b/libraries/communication-layer/pub-sub/src/iceoryx.rs deleted file mode 100644 index 34fdcfa1..00000000 --- a/libraries/communication-layer/pub-sub/src/iceoryx.rs +++ /dev/null @@ -1,158 +0,0 @@ -//! Provides [`IceoryxCommunicationLayer`] to communicate over `iceoryx`. - -use super::{CommunicationLayer, Publisher, Subscriber}; -use crate::{BoxError, ReceivedSample}; -use eyre::Context; -use std::{borrow::Cow, collections::HashMap, sync::Arc, time::Duration}; - -/// Enables local communication based on `iceoryx`. -pub struct IceoryxCommunicationLayer { - group_name: String, - instance_name: String, - publishers: HashMap>>, -} - -impl IceoryxCommunicationLayer { - /// Initializes a new `iceoryx` connection with default configuration. - /// - /// The given `app_name` must be unique. The `group_name` and - /// `instance_name` arguments are used to create an `iceoryx` - /// `ServiceDescription` in combination wiith topic names given to the - /// [`publisher`][Self::publisher] and [`subscriber`][Self::subscribe] - /// methods. See the - /// [`iceoryx` documentation](https://iceoryx.io/v2.0.1/getting-started/overview/#creating-service-descriptions-for-topics) - /// for details. - /// - /// Note: In order to use iceoryx, you need to start its broker deamon called - /// [_RouDi_](https://iceoryx.io/v2.0.2/getting-started/overview/#roudi) first. - /// Its executable name is `iox-roudi`. See the - /// [`iceoryx` installation chapter](https://iceoryx.io/v2.0.2/getting-started/installation/) - /// for ways to install it. - pub fn init( - app_name: String, - group_name: String, - instance_name: String, - ) -> Result { - iceoryx_rs::Runtime::init(&app_name); - - Ok(Self { - group_name, - instance_name, - publishers: Default::default(), - }) - } -} - -impl IceoryxCommunicationLayer { - fn get_or_create_publisher( - &mut self, - topic: &str, - ) -> eyre::Result>> { - match self.publishers.get(topic) { - Some(p) => Ok(p.clone()), - None => { - let publisher = - Self::create_publisher(&self.group_name, &self.instance_name, topic) - .context("failed to create iceoryx publisher")?; - - let publisher = Arc::new(publisher); - self.publishers.insert(topic.to_owned(), publisher.clone()); - Ok(publisher) - } - } - } - - fn create_publisher( - group: &str, - instance: &str, - topic: &str, - ) -> Result, iceoryx_rs::IceoryxError> { - iceoryx_rs::PublisherBuilder::new(group, instance, topic).create() - } -} - -impl CommunicationLayer for IceoryxCommunicationLayer { - fn publisher(&mut self, topic: &str) -> Result, crate::BoxError> { - let publisher = self - .get_or_create_publisher(topic) - .map_err(BoxError::from)?; - - Ok(Box::new(IceoryxPublisher { publisher })) - } - - fn subscribe(&mut self, topic: &str) -> Result, crate::BoxError> { - let (subscriber, token) = - iceoryx_rs::SubscriberBuilder::new(&self.group_name, &self.instance_name, topic) - .queue_capacity(5) - .create_mt() - .context("failed to create iceoryx subscriber") - .map_err(BoxError::from)?; - let receiver = subscriber.get_sample_receiver(token); - - Ok(Box::new(IceoryxReceiver { receiver })) - } -} - -#[derive(Clone)] -struct IceoryxPublisher { - publisher: Arc>, -} - -impl Publisher for IceoryxPublisher { - fn prepare(&self, len: usize) -> Result, BoxError> { - let sample = self - .publisher - .loan_slice(len) - .context("failed to loan iceoryx slice for publishing") - .map_err(BoxError::from)?; - Ok(Box::new(IceoryxPublishSample { - sample, - publisher: self.publisher.clone(), - })) - } - - fn dyn_clone(&self) -> Box { - Box::new(self.clone()) - } -} - -struct IceoryxPublishSample<'a> { - publisher: Arc>, - sample: iceoryx_rs::SampleMut<'a, [u8]>, -} - -impl<'a> crate::PublishSample<'a> for IceoryxPublishSample<'a> { - fn as_mut_slice(&mut self) -> &mut [u8] { - &mut self.sample - } - - fn publish(self: Box) -> Result<(), BoxError> { - self.publisher.publish(self.sample); - Ok(()) - } -} - -struct IceoryxReceiver { - receiver: iceoryx_rs::mt::SampleReceiver<[u8]>, -} - -impl Subscriber for IceoryxReceiver { - fn recv(&mut self) -> Result>, BoxError> { - self.receiver - .wait_for_samples(Duration::from_secs(u64::MAX)); - match self.receiver.take() { - Some(sample) => Ok(Some(Box::new(IceoryxReceivedSample { sample }))), - None => Ok(None), - } - } -} - -struct IceoryxReceivedSample { - sample: iceoryx_rs::Sample<[u8], iceoryx_sys::SubscriberArc>, -} - -impl ReceivedSample for IceoryxReceivedSample { - fn get(&self) -> Cow<[u8]> { - Cow::Borrowed(&self.sample) - } -} diff --git a/libraries/communication-layer/pub-sub/src/lib.rs b/libraries/communication-layer/pub-sub/src/lib.rs index 91fe66a9..2d4822f1 100644 --- a/libraries/communication-layer/pub-sub/src/lib.rs +++ b/libraries/communication-layer/pub-sub/src/lib.rs @@ -9,14 +9,9 @@ //! - **[Zenoh](https://zenoh.io/):** The zenoh project implements a distributed //! publisher/subscriber system with automated routing. To use zenoh, use the //! [`ZenohCommunicationLayer`][zenoh::ZenohCommunicationLayer] struct. -//! - **[Iceoryx](https://iceoryx.io/):** The Eclipse iceoryxâ„¢ project provides an IPC middleware -//! based on shared memory. It is very fast, but it only supports local communication. To use -//! iceoryx, use the [`IceoryxCommunicationLayer`][iceoryx::IceoryxCommunicationLayer] struct. use std::borrow::Cow; -#[cfg(all(unix, feature = "iceoryx"))] -pub mod iceoryx; #[cfg(feature = "zenoh")] pub mod zenoh; diff --git a/libraries/core/src/config.rs b/libraries/core/src/config.rs index c6170e19..55a5c616 100644 --- a/libraries/core/src/config.rs +++ b/libraries/core/src/config.rs @@ -257,11 +257,6 @@ pub enum CommunicationConfig { config: Box, prefix: String, }, - Iceoryx { - app_name_prefix: String, - #[serde(default)] - topic_prefix: String, - }, } impl CommunicationConfig { @@ -273,12 +268,6 @@ impl CommunicationConfig { } => { write!(zenoh_prefix, "/{}", prefix).unwrap(); } - CommunicationConfig::Iceoryx { topic_prefix, .. } => { - if !topic_prefix.is_empty() { - topic_prefix.push('-'); - } - topic_prefix.push_str(prefix); - } } } }