-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: log every request to DSP-API #76
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BalduinLandolt
approved these changes
Mar 24, 2024
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.
Over all, certainly a big improvements.
Here are some detail remarks, though:
- I don't like the
connection.con.xyz()
. if you called the instanceconnection
too, you could import itfrom xyz.connection import connection
, then you'd end up with callingconnection.xyz()
which IMO reads a lot nicer. - I always hated the name "Connection" because that's not actually what it is. It knows how to handle a connection, but it is not a connection. It provides functionality to do calls to DSP, so what it actually is, is a client to talk to a DSP server, so a name along those lines (
DspClient
? and the instance could be calledclient
?) would make more sense. I didn't want tu stir that pot in DSP-TOOLS, but I dislike to see it copied over here. What do you think? - The singleton connection spares you some arguments to pass around, but it is conceptually the opposite of dependency injection, and introduces rock-solid coupling across the entire thing. I'm not sure how much testing needs to happen in these kinds of scripts; but if you do want to have good coverage, this will come to bite you eventually.
- if you decide to stick with the singleton connection, then it doesn't make much sense anymore to model it as a class which has a single instance into which you do (pseudo)-static calls. Then it could just as well be a module with top level functions and a number of private variables. The only reason to have classes is to be able to have multiple instances of them. And with this design, you also wouldn't need to do a first instantiation with
Connection("foo")
just to make typing happy [in all code paths, this instance gets overwritten with a different instance].
All these points are somewhat cosmetic, so feel free to ignore them or address them later.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Basically, this PR copy-pastes the
Connection
class of DSP-TOOLS, so that the permissions-related modules don't have to care any more how to make a request. As a plus, I don't pass around the connection object, but it lives in a single module, and all modules just access it there. This spares a lot of code!