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 a Receiver.triggered method #328

Merged
merged 5 commits into from
Nov 5, 2024
Merged

Conversation

shsms
Copy link
Contributor

@shsms shsms commented Oct 8, 2024

This is an alternative to the selected_from method.

@shsms shsms requested a review from a team as a code owner October 8, 2024 09:53
@github-actions github-actions bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:synchronization Affects the synchronization of multiple sources (`select`, `merge`) part:core Affects the core types (`Sender`, `Receiver`, exceptions, etc.) labels Oct 8, 2024
@shsms shsms requested review from llucax and removed request for ela-kotulska-frequenz October 8, 2024 09:53
@github-actions github-actions bot added the part:docs Affects the documentation label Oct 8, 2024
@shsms
Copy link
Contributor Author

shsms commented Oct 8, 2024

Other naming options: matches, matches_selected

Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

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

OK, so the issue we had with TypeGuard as a member method was not it being a member method but about applying the type guard to self, this is why we can't do selected.source(receiver), because we want to narrow selected, not receiver, but when used as a member the variable to narrow is the second argument, not self.

So receiver.is_selected(selected) works and will narrow selected. OK. I don't like the fact that now part of select()is implemented inReceiverunless we have a considerable improvement in how the code is read, andreceiver.is_selected(selected)doesn't read much better thanselected_from(selected, receiver)`.

But maybe something like receiver.is_source_of(selected) could work. What do you think?

src/frequenz/channels/_receiver.py Show resolved Hide resolved
@shsms shsms force-pushed the selected branch 2 times, most recently from fc7064a to 7005e83 Compare October 31, 2024 11:42
@shsms shsms changed the title Add a Receiver.is_selected method Add a Receiver.matches method Oct 31, 2024
@shsms shsms changed the title Add a Receiver.matches method Add a Receiver.triggered method Oct 31, 2024
@shsms shsms requested a review from llucax October 31, 2024 13:14
RELEASE_NOTES.md Outdated Show resolved Hide resolved
src/frequenz/channels/_receiver.py Show resolved Hide resolved
src/frequenz/channels/_select.py Show resolved Hide resolved
@llucax llucax added this to the v1.3.0 milestone Nov 1, 2024
shsms added 5 commits November 5, 2024 15:03
Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
This is an alternative for the `selected_from` method and could
eventually replace it.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
@shsms shsms added this pull request to the merge queue Nov 5, 2024
Merged via the queue into frequenz-floss:v1.x.x with commit 486d1be Nov 5, 2024
14 checks passed
@shsms shsms deleted the selected branch November 5, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part:core Affects the core types (`Sender`, `Receiver`, exceptions, etc.) part:docs Affects the documentation part:synchronization Affects the synchronization of multiple sources (`select`, `merge`) part:tests Affects the unit, integration and performance (benchmarks) tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants