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

feat: unify pub/sub and query/reply modules #1193

Merged
merged 6 commits into from
Jul 3, 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
5 changes: 4 additions & 1 deletion ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
use std::{convert::TryFrom, time::Duration};

use zenoh::{
config::Config, key_expr::KeyExpr, prelude::*, query::QueryTarget, selector::Selector,
config::Config,
key_expr::KeyExpr,
prelude::*,
query::{QueryTarget, Selector},
};

#[tokio::main]
Expand Down
4 changes: 2 additions & 2 deletions commons/zenoh-keyexpr/src/key_expr/borrowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use core::{

use zenoh_result::{bail, Error as ZError, ZResult};

use super::{canon::Canonizable, OwnedKeyExpr, FORBIDDEN_CHARS};
use super::{canon::Canonize, OwnedKeyExpr, FORBIDDEN_CHARS};

/// A [`str`] newtype that is statically known to be a valid key expression.
///
Expand Down Expand Up @@ -72,7 +72,7 @@ impl keyexpr {
pub fn autocanonize<'a, T, E>(t: &'a mut T) -> Result<&'a Self, E>
where
&'a Self: TryFrom<&'a T, Error = E>,
T: Canonizable + ?Sized,
T: Canonize + ?Sized,
{
t.canonize();
Self::new(t)
Expand Down
6 changes: 3 additions & 3 deletions commons/zenoh-keyexpr/src/key_expr/canon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use crate::key_expr::{
DELIMITER, DOUBLE_WILD, SINGLE_WILD,
};

pub trait Canonizable {
pub trait Canonize {
fn canonize(&mut self);
}

const DOLLAR_STAR: &[u8; 2] = b"$*";

impl Canonizable for &mut str {
impl Canonize for &mut str {
fn canonize(&mut self) {
let mut writer = Writer {
ptr: self.as_mut_ptr(),
Expand Down Expand Up @@ -114,7 +114,7 @@ impl Canonizable for &mut str {
}
}

impl Canonizable for String {
impl Canonize for String {
fn canonize(&mut self) {
let mut s = self.as_mut();
s.canonize();
Expand Down
4 changes: 2 additions & 2 deletions commons/zenoh-keyexpr/src/key_expr/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use core::{
str::FromStr,
};

use super::{canon::Canonizable, keyexpr};
use super::{canon::Canonize, keyexpr};

/// A [`Arc<str>`] newtype that is statically known to be a valid key expression.
///
Expand Down Expand Up @@ -60,7 +60,7 @@ impl OwnedKeyExpr {
pub fn autocanonize<T, E>(mut t: T) -> Result<Self, E>
where
Self: TryFrom<T, Error = E>,
T: Canonizable,
T: Canonize,
{
t.canonize();
Self::new(t)
Expand Down
2 changes: 1 addition & 1 deletion commons/zenoh-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ fn keformat_support(source: &str) -> proc_macro2::TokenStream {
let formatter_doc = format!("And instance of a formatter for `{source}`.");

quote! {
use ::zenoh::core::Result as ZResult;
use ::zenoh::Result as ZResult;
const FORMAT_INNER: ::zenoh::key_expr::format::KeFormat<'static, [::zenoh::key_expr::format::Segment<'static>; #len]> = unsafe {
::zenoh::key_expr::format::macro_support::const_new(#source, [#(#segments)*])
};
Expand Down
5 changes: 4 additions & 1 deletion examples/examples/z_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
use std::time::Duration;

use clap::Parser;
use zenoh::{query::QueryTarget, selector::Selector, Config};
use zenoh::{
query::{QueryTarget, Selector},
Config,
};
use zenoh_examples::CommonArgs;

#[tokio::main]
Expand Down
3 changes: 1 addition & 2 deletions examples/examples/z_get_shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use std::time::Duration;

use clap::Parser;
use zenoh::{
query::QueryTarget,
selector::Selector,
query::{QueryTarget, Selector},
shm::{
zshm, BlockOn, GarbageCollect, PosixShmProviderBackend, ShmProviderBuilder,
POSIX_PROTOCOL_ID,
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// ZettaScale Zenoh Team, <[email protected]>
//
use clap::Parser;
use zenoh::{info::ZenohId, prelude::*};
use zenoh::{prelude::*, session::ZenohId};
use zenoh_examples::CommonArgs;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use std::time::{Duration, Instant};

use clap::Parser;
use zenoh::{bytes::ZBytes, key_expr::keyexpr, prelude::*, publisher::CongestionControl, Config};
use zenoh::{bytes::ZBytes, key_expr::keyexpr, prelude::*, qos::CongestionControl, Config};
use zenoh_examples::CommonArgs;

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_ping_shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh::{
bytes::ZBytes,
key_expr::keyexpr,
prelude::*,
publisher::CongestionControl,
qos::CongestionControl,
shm::{PosixShmProviderBackend, ShmProviderBuilder, POSIX_PROTOCOL_ID},
Config,
};
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// ZettaScale Zenoh Team, <[email protected]>
//
use clap::Parser;
use zenoh::{key_expr::keyexpr, prelude::*, publisher::CongestionControl, Config};
use zenoh::{key_expr::keyexpr, prelude::*, qos::CongestionControl, Config};
use zenoh_examples::CommonArgs;

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use std::time::Duration;

use clap::Parser;
use zenoh::{encoding::Encoding, key_expr::KeyExpr, prelude::*, Config};
use zenoh::{bytes::Encoding, key_expr::KeyExpr, prelude::*, Config};
use zenoh_examples::CommonArgs;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/z_pub_shm_thr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use clap::Parser;
use zenoh::{
bytes::ZBytes,
prelude::*,
publisher::CongestionControl,
qos::CongestionControl,
shm::{PosixShmProviderBackend, ShmProviderBuilder, POSIX_PROTOCOL_ID},
Config,
};
Expand Down
6 changes: 5 additions & 1 deletion examples/examples/z_pub_thr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
use std::convert::TryInto;

use clap::Parser;
use zenoh::{bytes::ZBytes, core::Priority, prelude::*, publisher::CongestionControl};
use zenoh::{
bytes::ZBytes,
prelude::*,
qos::{CongestionControl, Priority},
};
use zenoh_examples::CommonArgs;

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion plugins/zenoh-backend-traits/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use derive_more::{AsMut, AsRef};
use schemars::JsonSchema;
use serde_json::{Map, Value};
use zenoh::{
core::Result as ZResult,
key_expr::{keyexpr, OwnedKeyExpr},
Result as ZResult,
};
use zenoh_plugin_trait::{PluginStartArgs, StructVersion};
use zenoh_result::{bail, zerror, Error};
Expand Down
2 changes: 1 addition & 1 deletion plugins/zenoh-backend-traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@
use async_trait::async_trait;
use const_format::concatcp;
use zenoh::{
core::Result as ZResult,
internal::Value,
key_expr::{keyexpr, OwnedKeyExpr},
time::Timestamp,
Result as ZResult,
};
use zenoh_plugin_trait::{PluginControl, PluginInstance, PluginStatusRec, StructVersion};
use zenoh_util::concat_enabled_features;
Expand Down
4 changes: 3 additions & 1 deletion plugins/zenoh-plugin-rest/examples/z_serve_sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ use std::time::Duration;

use clap::{arg, Command};
use zenoh::{
config::Config, key_expr::keyexpr, publisher::CongestionControl, sample::QoSBuilderTrait,
config::Config,
key_expr::keyexpr,
qos::{CongestionControl, QoSBuilderTrait},
session::SessionDeclarations,
};

Expand Down
10 changes: 4 additions & 6 deletions plugins/zenoh-plugin-rest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ use http_types::Method;
use serde::{Deserialize, Serialize};
use tide::{http::Mime, sse::Sender, Request, Response, Server, StatusCode};
use zenoh::{
bytes::ZBytes,
encoding::Encoding,
bytes::{Encoding, ZBytes},
internal::{
bail,
plugins::{RunningPluginTrait, ZenohPlugin},
Expand All @@ -36,16 +35,15 @@ use zenoh::{
},
key_expr::{keyexpr, KeyExpr},
prelude::*,
query::{QueryConsolidation, Reply},
sample::{EncodingBuilderTrait, Sample, SampleKind},
selector::{Parameters, Selector, ZenohParameters},
query::{Parameters, QueryConsolidation, Reply, Selector, ZenohParameters},
sample::{Sample, SampleKind},
session::{Session, SessionDeclarations},
};
use zenoh_plugin_trait::{plugin_long_version, plugin_version, Plugin, PluginControl};

mod config;
pub use config::Config;
use zenoh::query::ReplyError;
use zenoh::{bytes::EncodingBuilderTrait, query::ReplyError};

const GIT_VERSION: &str = git_version::git_version!(prefix = "v", cargo_prefix = "v");
lazy_static::lazy_static! {
Expand Down
2 changes: 1 addition & 1 deletion plugins/zenoh-plugin-storage-manager/src/backends_mgt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use std::sync::Arc;

use flume::Sender;
use zenoh::{core::Result as ZResult, session::Session};
use zenoh::{session::Session, Result as ZResult};
use zenoh_backend_traits::{config::StorageConfig, Capability, VolumeInstance};

use super::storages_mgt::*;
Expand Down
2 changes: 1 addition & 1 deletion plugins/zenoh-plugin-storage-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use flume::Sender;
use memory_backend::MemoryBackend;
use storages_mgt::StorageMessage;
use zenoh::{
core::Result as ZResult,
internal::{
plugins::{Response, RunningPlugin, RunningPluginTrait, ZenohPlugin},
runtime::Runtime,
Expand All @@ -39,6 +38,7 @@ use zenoh::{
key_expr::{keyexpr, KeyExpr},
prelude::Wait,
session::Session,
Result as ZResult,
};
use zenoh_backend_traits::{
config::{ConfigDiff, PluginConfig, StorageConfig, VolumeConfig},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{collections::HashMap, sync::Arc};

use async_std::sync::RwLock;
use async_trait::async_trait;
use zenoh::{core::Result as ZResult, internal::Value, key_expr::OwnedKeyExpr, time::Timestamp};
use zenoh::{internal::Value, key_expr::OwnedKeyExpr, time::Timestamp, Result as ZResult};
use zenoh_backend_traits::{
config::{StorageConfig, VolumeConfig},
*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::{

use async_std::sync::Arc;
use zenoh::{
internal::Value, key_expr::OwnedKeyExpr, prelude::*, sample::Sample, selector::Parameters,
internal::Value, key_expr::OwnedKeyExpr, prelude::*, query::Parameters, sample::Sample,
time::Timestamp, Session,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use zenoh::{
internal::Value,
key_expr::{KeyExpr, OwnedKeyExpr},
prelude::*,
query::Selector,
sample::{Sample, SampleBuilder},
selector::Selector,
time::Timestamp,
Session,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use async_std::{
};
use flume::Receiver;
use futures::join;
use zenoh::{info::ZenohId, key_expr::OwnedKeyExpr, time::Timestamp};
use zenoh::{key_expr::OwnedKeyExpr, session::ZenohId, time::Timestamp};
use zenoh_backend_traits::config::ReplicaConfig;

use super::{Digest, DigestConfig, LogEntry};
Expand Down
5 changes: 3 additions & 2 deletions plugins/zenoh-plugin-storage-manager/src/replica/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use async_trait::async_trait;
use flume::{Receiver, Sender};
use futures::select;
use zenoh::{
core::Result as ZResult,
bytes::EncodingBuilderTrait,
internal::{
bail,
buffers::{SplitBuffer, ZBuf},
Expand All @@ -35,9 +35,10 @@ use zenoh::{
KeyExpr, OwnedKeyExpr,
},
query::{ConsolidationMode, QueryTarget},
sample::{EncodingBuilderTrait, Sample, SampleBuilder, SampleKind, TimestampBuilderTrait},
sample::{Sample, SampleBuilder, SampleKind, TimestampBuilderTrait},
session::{Session, SessionDeclarations},
time::{new_timestamp, Timestamp, NTP64},
Result as ZResult,
};
use zenoh_backend_traits::{
config::{GarbageCollectionConfig, StorageConfig},
Expand Down
2 changes: 1 addition & 1 deletion plugins/zenoh-plugin-storage-manager/src/storages_mgt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// ZettaScale Zenoh Team, <[email protected]>
//
use async_std::sync::Arc;
use zenoh::{core::Result as ZResult, session::Session};
use zenoh::{session::Session, Result as ZResult};
use zenoh_backend_traits::config::StorageConfig;

pub use super::replica::{Replica, StorageService};
Expand Down
4 changes: 2 additions & 2 deletions zenoh-ext/src/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ use serde::{Deserialize, Serialize};
use tokio::sync::Mutex;
use zenoh::{
bytes::ZBytesReader,
core::Priority,
internal::{bail, Condition, TaskController},
key_expr::{keyexpr, KeyExpr, OwnedKeyExpr},
prelude::*,
publisher::Publisher,
pubsub::Publisher,
qos::Priority,
Session,
};

Expand Down
2 changes: 1 addition & 1 deletion zenoh-ext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub use querying_subscriber::{
};
pub use session_ext::SessionExt;
pub use subscriber_ext::{SubscriberBuilderExt, SubscriberForward};
use zenoh::{core::Result as ZResult, internal::zerror, query::Reply, sample::Sample};
use zenoh::{internal::zerror, query::Reply, sample::Sample, Result as ZResult};

/// The space of keys to use in a [`FetchingSubscriber`].
pub enum KeySpace {
Expand Down
8 changes: 3 additions & 5 deletions zenoh-ext/src/publication_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ use std::{
};

use zenoh::{
core::{Error, Resolvable, Resolve, Result as ZResult},
internal::{bail, runtime::ZRuntime, ResolveFuture, TerminatableTask},
key_expr::{keyexpr, KeyExpr, OwnedKeyExpr},
prelude::Wait,
query::Query,
queryable::Queryable,
pubsub::FlumeSubscriber,
query::{Query, Queryable, ZenohParameters},
sample::{Locality, Sample},
selector::ZenohParameters,
session::{SessionDeclarations, SessionRef},
subscriber::FlumeSubscriber,
Error, Resolvable, Resolve, Result as ZResult,
};

/// The builder of PublicationCache, allowing to configure it.
Expand Down
7 changes: 3 additions & 4 deletions zenoh-ext/src/querying_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@ use std::{
};

use zenoh::{
core::{Error, Resolvable, Resolve, Result as ZResult},
handlers::{locked, DefaultHandler, IntoHandler},
internal::zlock,
key_expr::KeyExpr,
prelude::Wait,
query::{QueryConsolidation, QueryTarget, ReplyKeyExpr},
pubsub::{Reliability, Subscriber},
query::{QueryConsolidation, QueryTarget, ReplyKeyExpr, Selector},
sample::{Locality, Sample, SampleBuilder, TimestampBuilderTrait},
selector::Selector,
session::{SessionDeclarations, SessionRef},
subscriber::{Reliability, Subscriber},
time::{new_timestamp, Timestamp},
Error, Resolvable, Resolve, Result as ZResult,
};

use crate::ExtractSample;
Expand Down
Loading
Loading