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

Add ability for sync::watch::Receiver to flag current item as unseen #5871

Closed
allada opened this issue Jul 16, 2023 · 2 comments · Fixed by #5962
Closed

Add ability for sync::watch::Receiver to flag current item as unseen #5871

allada opened this issue Jul 16, 2023 · 2 comments · Fixed by #5962
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. E-help-wanted Call for participation: Help is requested to fix this issue. M-sync Module: tokio/sync

Comments

@allada
Copy link

allada commented Jul 16, 2023

Is your feature request related to a problem? Please describe.
Currently there is no way for a sync::watch::Receiver to be created and mark the current item as unseen without notifying all Receivers.

Describe the solution you'd like
Add a function on Receiver that allows the next time the Receiver calls .has_changed() (or similar) it returns true.

Describe alternatives you've considered
Add similar function to Sender::subscribe() where newly created Receiver has a message pending and Receiver::clone()-like method that does the same thing.

Use case

  • Client connects with some request.
  • These requests can be multiplexed, so only 1 unique request is ever being processed, but clients all get notified of state changes (only most recent state matters).
  • When first client connects they are notified of a change 100% of the time because sync::watch::channel() always creates a Receiver with a pending message.
  • When a new client connects, we want to notify the client of the current state.

This is a very minor security concern for us because unless we hold a copy of the last seen data for every Receiver we are forced to re-send a bogus state change to every Receiver, which can then be used by the receiver client to get hints on when people are connecting and disconnecting (yes, this could be solved on a higher level, but requires a lot of needless work & memory).

@allada allada added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Jul 16, 2023
@Darksonn Darksonn added M-sync Module: tokio/sync E-help-wanted Call for participation: Help is requested to fix this issue. labels Jul 16, 2023
@victor-timofei
Copy link
Contributor

If no one is working on this I'd like to pick this up.

@Darksonn
Copy link
Contributor

Darksonn commented Aug 8, 2023

Go ahead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. E-help-wanted Call for participation: Help is requested to fix this issue. M-sync Module: tokio/sync
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants