Skip to content

Commit 2f27e18

Browse files
authored
stabilize liveliness API (#1646)
* Remove unstable feature flags from liveliness examples and API * compile errors partially fixed * compilation error fixed * clippy fix * cargo doc fix * code simplified, unstable from liveliness tests removed * explicitly enable internal_config access for tests only * clippy fix, internal config global for liveliness test * compile error fix * compile fix correction * corrected shm test * cargo fmt * zenoh-ext requires internal_config * internal_config for zenohd * liveliness functionality moved from unstable * clippy fix * cargo fmt
1 parent 49ed08a commit 2f27e18

File tree

15 files changed

+31
-150
lines changed

15 files changed

+31
-150
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ jobs:
143143
uses: taiki-e/install-action@nextest
144144

145145
- name: Run tests
146-
run: cargo nextest run -F test --exclude zenoh-examples --exclude zenoh-plugin-example --workspace
146+
run: cargo nextest run -F test -F internal_config --exclude zenoh-examples --exclude zenoh-plugin-example --workspace
147147

148148
- name: Run tests with SHM
149149
if: ${{ matrix.os == 'macOS-latest' || matrix.os == 'windows-latest' }}
150-
run: cargo nextest run -F test -F shared-memory -F unstable -E 'not (test(test_default_features))' --exclude zenoh-examples --exclude zenoh-plugin-example --workspace
150+
run: cargo nextest run -F test -F shared-memory -F unstable -F internal_config -E 'not (test(test_default_features))' --exclude zenoh-examples --exclude zenoh-plugin-example --workspace
151151

152152
- name: Run tests with SHM + unixpipe
153153
if: ${{ matrix.os == 'ubuntu-latest' }}
154-
run: cargo nextest run -F test -F shared-memory -F unstable -F transport_unixpipe -E 'not (test(test_default_features))' --exclude zenoh-examples --exclude zenoh-plugin-example --workspace
154+
run: cargo nextest run -F test -F shared-memory -F unstable -F internal_config -F transport_unixpipe -E 'not (test(test_default_features))' --exclude zenoh-examples --exclude zenoh-plugin-example --workspace
155155

156156
- name: Check for feature leaks
157157
if: ${{ matrix.os == 'ubuntu-latest' }}

examples/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,14 @@ path = "examples/z_forward.rs"
127127
[[example]]
128128
name = "z_liveliness"
129129
path = "examples/z_liveliness.rs"
130-
required-features = ["unstable"]
131130

132131
[[example]]
133132
name = "z_sub_liveliness"
134133
path = "examples/z_sub_liveliness.rs"
135-
required-features = ["unstable"]
136134

137135
[[example]]
138136
name = "z_get_liveliness"
139137
path = "examples/z_get_liveliness.rs"
140-
required-features = ["unstable"]
141138

142139
[[example]]
143140
name = "z_pub_thr"

zenoh-ext/examples/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ default = []
3434
[dependencies]
3535
tokio = { workspace = true, features = ["rt", "sync", "time", "macros", "io-std"] }
3636
futures = { workspace = true }
37-
zenoh = { workspace = true, features = ["unstable"], default-features = false }
37+
zenoh = { workspace = true, features = ["unstable", "internal_config"], default-features = false }
3838
clap = { workspace = true, features = ["derive"] }
3939
zenoh-ext = { workspace = true, features = ["unstable"] }
4040

zenoh/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ transport_udp = ["zenoh-transport/transport_udp"]
6464
transport_unixsock-stream = ["zenoh-transport/transport_unixsock-stream"]
6565
transport_ws = ["zenoh-transport/transport_ws"]
6666
transport_vsock = ["zenoh-transport/transport_vsock"]
67-
unstable = ["internal_config", "zenoh-keyexpr/unstable", "zenoh-config/unstable"]
67+
unstable = ["zenoh-keyexpr/unstable", "zenoh-config/unstable"]
6868
internal_config = []
6969

7070
[dependencies]

zenoh/src/api/liveliness.rs

+1-35
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,10 @@ use crate::{
9393
/// }
9494
/// # }
9595
/// ```
96-
97-
#[zenoh_macros::unstable]
9896
pub struct Liveliness<'a> {
9997
pub(crate) session: &'a Session,
10098
}
10199

102-
#[zenoh_macros::unstable]
103100
impl<'a> Liveliness<'a> {
104101
/// Create a [`LivelinessToken`](LivelinessToken) for the given key expression.
105102
///
@@ -120,7 +117,6 @@ impl<'a> Liveliness<'a> {
120117
/// .unwrap();
121118
/// # }
122119
/// ```
123-
#[zenoh_macros::unstable]
124120
pub fn declare_token<'b, TryIntoKeyExpr>(
125121
&self,
126122
key_expr: TryIntoKeyExpr,
@@ -157,7 +153,6 @@ impl<'a> Liveliness<'a> {
157153
/// }
158154
/// # }
159155
/// ```
160-
#[zenoh_macros::unstable]
161156
pub fn declare_subscriber<'b, TryIntoKeyExpr>(
162157
&self,
163158
key_expr: TryIntoKeyExpr,
@@ -194,7 +189,6 @@ impl<'a> Liveliness<'a> {
194189
/// }
195190
/// # }
196191
/// ```
197-
#[zenoh_macros::unstable]
198192
pub fn get<'b, TryIntoKeyExpr>(
199193
&self,
200194
key_expr: TryIntoKeyExpr,
@@ -205,7 +199,7 @@ impl<'a> Liveliness<'a> {
205199
{
206200
let key_expr = key_expr.try_into().map_err(Into::into);
207201
let timeout = {
208-
let conf = self.session.0.runtime.config().lock();
202+
let conf = &self.session.0.runtime.config().lock().0;
209203
Duration::from_millis(unwrap_or_default!(conf.queries_default_timeout()))
210204
};
211205
LivelinessGetBuilder {
@@ -233,19 +227,16 @@ impl<'a> Liveliness<'a> {
233227
/// # }
234228
/// ```
235229
#[must_use = "Resolvables do nothing unless you resolve them using `.await` or `zenoh::Wait::wait`"]
236-
#[zenoh_macros::unstable]
237230
#[derive(Debug)]
238231
pub struct LivelinessTokenBuilder<'a, 'b> {
239232
pub(crate) session: &'a Session,
240233
pub(crate) key_expr: ZResult<KeyExpr<'b>>,
241234
}
242235

243-
#[zenoh_macros::unstable]
244236
impl Resolvable for LivelinessTokenBuilder<'_, '_> {
245237
type To = ZResult<LivelinessToken>;
246238
}
247239

248-
#[zenoh_macros::unstable]
249240
impl Wait for LivelinessTokenBuilder<'_, '_> {
250241
#[inline]
251242
fn wait(self) -> <Self as Resolvable>::To {
@@ -262,7 +253,6 @@ impl Wait for LivelinessTokenBuilder<'_, '_> {
262253
}
263254
}
264255

265-
#[zenoh_macros::unstable]
266256
impl IntoFuture for LivelinessTokenBuilder<'_, '_> {
267257
type Output = <Self as Resolvable>::To;
268258
type IntoFuture = Ready<<Self as Resolvable>::To>;
@@ -296,7 +286,6 @@ impl IntoFuture for LivelinessTokenBuilder<'_, '_> {
296286
/// .unwrap();
297287
/// # }
298288
/// ```
299-
#[zenoh_macros::unstable]
300289
#[must_use = "Liveliness tokens will be immediately dropped and undeclared if not bound to a variable"]
301290
#[derive(Debug)]
302291
pub struct LivelinessToken {
@@ -323,22 +312,18 @@ pub struct LivelinessToken {
323312
/// # }
324313
/// ```
325314
#[must_use = "Resolvables do nothing unless you resolve them using `.await` or `zenoh::Wait::wait`"]
326-
#[zenoh_macros::unstable]
327315
pub struct LivelinessTokenUndeclaration(LivelinessToken);
328316

329-
#[zenoh_macros::unstable]
330317
impl Resolvable for LivelinessTokenUndeclaration {
331318
type To = ZResult<()>;
332319
}
333320

334-
#[zenoh_macros::unstable]
335321
impl Wait for LivelinessTokenUndeclaration {
336322
fn wait(mut self) -> <Self as Resolvable>::To {
337323
self.0.undeclare_impl()
338324
}
339325
}
340326

341-
#[zenoh_macros::unstable]
342327
impl IntoFuture for LivelinessTokenUndeclaration {
343328
type Output = <Self as Resolvable>::To;
344329
type IntoFuture = Ready<<Self as Resolvable>::To>;
@@ -348,7 +333,6 @@ impl IntoFuture for LivelinessTokenUndeclaration {
348333
}
349334
}
350335

351-
#[zenoh_macros::unstable]
352336
impl LivelinessToken {
353337
/// Undeclare the [`LivelinessToken`].
354338
///
@@ -379,7 +363,6 @@ impl LivelinessToken {
379363
}
380364
}
381365

382-
#[zenoh_macros::unstable]
383366
impl UndeclarableSealed<()> for LivelinessToken {
384367
type Undeclaration = LivelinessTokenUndeclaration;
385368

@@ -388,7 +371,6 @@ impl UndeclarableSealed<()> for LivelinessToken {
388371
}
389372
}
390373

391-
#[zenoh_macros::unstable]
392374
impl Drop for LivelinessToken {
393375
fn drop(&mut self) {
394376
if self.undeclare_on_drop {
@@ -415,7 +397,6 @@ impl Drop for LivelinessToken {
415397
/// # }
416398
/// ```
417399
#[must_use = "Resolvables do nothing unless you resolve them using `.await` or `zenoh::Wait::wait`"]
418-
#[zenoh_macros::unstable]
419400
#[derive(Debug)]
420401
pub struct LivelinessSubscriberBuilder<'a, 'b, Handler, const BACKGROUND: bool = false> {
421402
pub session: &'a Session,
@@ -424,7 +405,6 @@ pub struct LivelinessSubscriberBuilder<'a, 'b, Handler, const BACKGROUND: bool =
424405
pub history: bool,
425406
}
426407

427-
#[zenoh_macros::unstable]
428408
impl<'a, 'b> LivelinessSubscriberBuilder<'a, 'b, DefaultHandler> {
429409
/// Receive the samples for this liveliness subscription with a callback.
430410
///
@@ -443,7 +423,6 @@ impl<'a, 'b> LivelinessSubscriberBuilder<'a, 'b, DefaultHandler> {
443423
/// # }
444424
/// ```
445425
#[inline]
446-
#[zenoh_macros::unstable]
447426
pub fn callback<F>(self, callback: F) -> LivelinessSubscriberBuilder<'a, 'b, Callback<Sample>>
448427
where
449428
F: Fn(Sample) + Send + Sync + 'static,
@@ -472,7 +451,6 @@ impl<'a, 'b> LivelinessSubscriberBuilder<'a, 'b, DefaultHandler> {
472451
/// # }
473452
/// ```
474453
#[inline]
475-
#[zenoh_macros::unstable]
476454
pub fn callback_mut<F>(
477455
self,
478456
callback: F,
@@ -503,7 +481,6 @@ impl<'a, 'b> LivelinessSubscriberBuilder<'a, 'b, DefaultHandler> {
503481
/// # }
504482
/// ```
505483
#[inline]
506-
#[zenoh_macros::unstable]
507484
pub fn with<Handler>(self, handler: Handler) -> LivelinessSubscriberBuilder<'a, 'b, Handler>
508485
where
509486
Handler: IntoHandler<Sample>,
@@ -556,14 +533,12 @@ impl<'a, 'b> LivelinessSubscriberBuilder<'a, 'b, Callback<Sample>> {
556533

557534
impl<Handler, const BACKGROUND: bool> LivelinessSubscriberBuilder<'_, '_, Handler, BACKGROUND> {
558535
#[inline]
559-
#[zenoh_macros::unstable]
560536
pub fn history(mut self, history: bool) -> Self {
561537
self.history = history;
562538
self
563539
}
564540
}
565541

566-
#[zenoh_macros::unstable]
567542
impl<Handler> Resolvable for LivelinessSubscriberBuilder<'_, '_, Handler>
568543
where
569544
Handler: IntoHandler<Sample> + Send,
@@ -572,13 +547,11 @@ where
572547
type To = ZResult<Subscriber<Handler::Handler>>;
573548
}
574549

575-
#[zenoh_macros::unstable]
576550
impl<Handler> Wait for LivelinessSubscriberBuilder<'_, '_, Handler>
577551
where
578552
Handler: IntoHandler<Sample> + Send,
579553
Handler::Handler: Send,
580554
{
581-
#[zenoh_macros::unstable]
582555
fn wait(self) -> <Self as Resolvable>::To {
583556
use super::subscriber::SubscriberKind;
584557

@@ -606,7 +579,6 @@ where
606579
}
607580
}
608581

609-
#[zenoh_macros::unstable]
610582
impl<Handler> IntoFuture for LivelinessSubscriberBuilder<'_, '_, Handler>
611583
where
612584
Handler: IntoHandler<Sample> + Send,
@@ -615,20 +587,16 @@ where
615587
type Output = <Self as Resolvable>::To;
616588
type IntoFuture = Ready<<Self as Resolvable>::To>;
617589

618-
#[zenoh_macros::unstable]
619590
fn into_future(self) -> Self::IntoFuture {
620591
std::future::ready(self.wait())
621592
}
622593
}
623594

624-
#[zenoh_macros::unstable]
625595
impl Resolvable for LivelinessSubscriberBuilder<'_, '_, Callback<Sample>, true> {
626596
type To = ZResult<()>;
627597
}
628598

629-
#[zenoh_macros::unstable]
630599
impl Wait for LivelinessSubscriberBuilder<'_, '_, Callback<Sample>, true> {
631-
#[zenoh_macros::unstable]
632600
fn wait(self) -> <Self as Resolvable>::To {
633601
self.session.0.declare_liveliness_subscriber_inner(
634602
&self.key_expr?,
@@ -640,12 +608,10 @@ impl Wait for LivelinessSubscriberBuilder<'_, '_, Callback<Sample>, true> {
640608
}
641609
}
642610

643-
#[zenoh_macros::unstable]
644611
impl IntoFuture for LivelinessSubscriberBuilder<'_, '_, Callback<Sample>, true> {
645612
type Output = <Self as Resolvable>::To;
646613
type IntoFuture = Ready<<Self as Resolvable>::To>;
647614

648-
#[zenoh_macros::unstable]
649615
fn into_future(self) -> Self::IntoFuture {
650616
std::future::ready(self.wait())
651617
}

zenoh/src/api/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub(crate) mod encoding;
2222
pub(crate) mod handlers;
2323
pub(crate) mod info;
2424
pub(crate) mod key_expr;
25-
#[cfg(feature = "unstable")]
2625
pub(crate) mod liveliness;
2726
#[cfg(feature = "plugins")]
2827
pub(crate) mod loader;

zenoh/src/api/query.rs

-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ impl From<Reply> for Result<Sample, ReplyError> {
146146
}
147147
}
148148

149-
#[cfg(feature = "unstable")]
150149
pub(crate) struct LivelinessQueryState {
151150
pub(crate) callback: Callback<Reply>,
152151
}

0 commit comments

Comments
 (0)