-
Notifications
You must be signed in to change notification settings - Fork 3
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
Allow adapted feeds to filter messages #123
Conversation
Signed-off-by: Michel Hidalgo <[email protected]>
TypeVar, | ||
Union, | ||
overload, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
black
decided it was time to reformat 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a line length limit for black.
""" | ||
super().__init__() | ||
self.fn = fn | ||
self.connection = upstream.registerCallback(self.add) | ||
|
||
def add(self, *messages: Any) -> None: | ||
"""Adds new `messages` to the adapter.""" | ||
self.signalMessage(self.fn(*messages)) | ||
result = self.fn(*messages) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amessing-bdai ended up going with the trivial implementation. There is a way, an async
way, for fn
to nicely embed complex, stateful logic in a functional way, but it was more trouble than it was worth. If one needs lots of bookkeeping and control flow for an adapter, it may be about time to write a new filter.
This patch adds a simple, generic mechanism for
AdaptedFeed
instances to drop messages.