Skip to content

sdk: refactor notification streams and add opt-in receiver gap reporting - #1489

Merged
yukibtc merged 2 commits into
masterfrom
sdk-streams
Oct 2, 2026
Merged

yukibtc merged 2 commits into
masterfrom
sdk-streams

Conversation

@yukibtc

@yukibtc yukibtc commented Oct 1, 2026

Copy link
Copy Markdown
Member

Description

Replaces #1482

CC @erskingardner

Checklist

  • I followed the contribution guidelines
  • I updated the relevant CHANGELOG.md (if applicable)
  • I understand and can explain all code in this PR

yukibtc and others added 2 commits October 1, 2026 08:55
Replace boxed streams with `NotificationStream<T>` in client and relay APIs.

Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
Introduce optional gap reporting in `NotificationStream`, allowing users to observe skipped notifications using `NotificationStream::with_gaps()` method.

Replaces #1482

Co-authored-by: Jeff Gardner <202880+erskingardner@users.noreply.github.com>
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
@yukibtc
yukibtc requested a review from TheAwiteb as a code owner October 1, 2026 09:04
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.54098% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
nostr-sdk/src/stream/notification.rs 97.05% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@yukibtc

yukibtc commented Oct 1, 2026

Copy link
Copy Markdown
Member Author

An alternative to NotificationStream::with_gaps may be to use NotificationStream::with_errors, which would return something like Result<T, NotificationStreamError> (for now with just a Lagged variant).

@TheAwiteb

Copy link
Copy Markdown
Member

How can this be useful? For example, when I know that I missed 7 events, what should I do? Should I have a general receiver that caches events, so I can ask it for the missed ones? Or should I re-subscribe? Or just log a warning so I try to handle events faster?

@TheAwiteb TheAwiteb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK

@yukibtc

yukibtc commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

How can this be useful? For example, when I know that I missed 7 events, what should I do? Should I have a general receiver that caches events, so I can ask it for the missed ones? Or should I re-subscribe? Or just log a warning so I try to handle events faster?

Yeah, I would say mainly the last one, to identity that the current way of handling notifications is too slow, so fix it somehow, or increase the notifications channel capacity.

@yukibtc
yukibtc merged commit 1c687bb into master Oct 2, 2026
43 checks passed
@yukibtc
yukibtc deleted the sdk-streams branch October 2, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants