Skip to content

Conversation

@wyfo
Copy link
Contributor

@wyfo wyfo commented Dec 23, 2025

A history depth of zero makes no sense, both on publisher cache side, and on subscriber query side.

There was a bug in the subscriber, as not having sample_depth set was preventing proper buffering. It has been fixed by considering that no sample_depth set means an arbitrary number of responses to the query, so responses must be buffered till the end.

A history depth of zero makes no sense, both on publisher cache side,
and on subscriber query side.

There was a bug in the subscriber, as not having `sample_depth` set
was preventing proper buffering. It has been fixed by considering that
no `sample_depth` set means an arbitrary number of responses to the
query, so responses must be buffered till the end.
@github-actions
Copy link

PR missing one of the required labels: {'dependencies', 'bug', 'enhancement', 'ci', 'new feature', 'documentation', 'api-sync', 'internal', 'breaking-change'}

@wyfo wyfo added the enhancement Existing things could work better label Dec 23, 2025
@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 73.07692% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.86%. Comparing base (a4ee16f) to head (2ee437b).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
zenoh-ext/src/advanced_subscriber.rs 45.45% 6 Missing ⚠️
zenoh-ext/src/advanced_cache.rs 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2333      +/-   ##
==========================================
- Coverage   72.97%   72.86%   -0.12%     
==========================================
  Files         388      388              
  Lines       62200    62196       -4     
==========================================
- Hits        45391    45317      -74     
- Misses      16809    16879      +70     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

///
/// Panics if `depth` is zero.
#[zenoh_macros::unstable]
pub fn max_samples(mut self, depth: usize) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not accept depth as NonZeroUsize and avoid panicking inside the setter ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it would make the API not so nice: I don't think that people like writing NonZero::new(x).unwrap()/x.try_into().unwrap() everywhere. Panicking on zero would give exactly the same result as users' unwrap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by removing the panic

retransmission: bool,
period: Option<Period>,
history_depth: usize,
history_depth: Option<NonZeroUsize>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not keep unwrap_or'ed value of history depth here, instead unwrapping it every time in handle_sample ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I don't think it matters a lot, but I will do the change.

@wyfo wyfo changed the title Panic when sample_depth is zero in advanced pub/sub Raise an error if max_samples is zero in advanced pub/sub Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Existing things could work better

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants