-
Notifications
You must be signed in to change notification settings - Fork 452
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
[dev] Make Notifier
more general
#5652
Comments
Our You identified a few points for improvement, which is nice 👍 . I have a few comments:
A notifier, at least in my eyes, is a one-way channel. Therefore, I do not see the need for asynchronous support. Is there any specific use-case you envision?
Yes, this is not a very good design but again, it's legacy code. If you can improve it, please go ahead 👍 |
Related to #4953
I basically deleted the old implementation that was a horrible mess of thread-using code from even the pre-Twisted times and replaced that with a small stub-like thing. The idea there was to move as much stuff (e.g. configs, definition) into individual components, as possible. In that case, Notifications could become an object class. However, many Notifications are used in both GUI and Core. By our rules, we try to put common definitions into TriblerCommon package. As JSON util does not know how to serialize custom classes, we have to provide our own serialization definitions for this classes (e.g. Also, gathering the responses is a bad idea. Notifications were supposed to be "fire and forget" stuff. |
Yes, agree 🤦 stupid idea. |
I wouldn't say so. It depends on what we try to achieve... |
Make
Notifier
more generalThere are three points, that we can improve in the current Implementation of Notifier:
Notifier
doesn't supportasync/await
:But it seems wrong because we developing an Application that supports
async/await
.Notifier
prohibits us from introducing new topics without changingNTFY
:What makes the
NTFY
kinda global event registry.In the future, this will lead to permanent merge conflicts, because every developer, that uses the
Notifier
should changeNTFY
.It also makes it difficult to find the topics which belong to, say, a particular Community.
Notifier.notify
method uses*args
instead**kwargs
which is more vulnerable to makingTypeError
just by misprint:Example:
Resuming
It would be nice if
Notifier
will be closer to the following:The text was updated successfully, but these errors were encountered: