-
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
Naming logic requiring transaction context consistently #432
Comments
If I understand you correctly, the proposed change is that the `Db*' classes should manage the transactions themselves, and as such have the transaction span as short as possible? EDIT: Anyways, at least for write transactions we agreed upon this policy in #429 |
I fully agree. This is somehow a consequence of the principles outlined in #429 and I would add the following boundary conditions:
|
It's not that the Db* classes should handle the transactions themselves. If you are using a Db* class, you get a clear indication that you require a transaction context. Currently, we have logic that uses these Db* classes that may or may not already manage the relevant transactions and therefore the caller of that logic may or may not need an extra surrounding transaction. From a convention point of view, I would hence argue the following: If and only if any of the classes you are directly using have the Db* prefix, you need to take care of a transaction. I agree with all the points listed by @ppanopticon above. |
I would discourage the movement of the transaction management to the
However, I did not really take into account all the logic surrounding template, media collection and user management, which is currently not bound to some internal logic but pretty much directly exposed via the API. Here I would probably build dedicated data access objects. |
Agreed. I'd also not put any transaction logic inside any of the Db* classes. Rather, transactions should be limited to logic directly operating on such classes. |
For user management, we already have the |
I'd argue that there should be a |
If you wanted to enforce this programmatically, context receivers would probably be the way to go. I tried this a while ago and they don't play nice with some of the mechanisms used in dnq, so getting this to work is probably more trouble than it's worth. |
For the database abstraction classes, we have a consistent naming scheme: when a classes name starts with Db*, it requires a transaction context to work. There is, however, also other logic that can only be called inside of a transaction context, most notably parts of a run manager. This makes the whole thing tedious to deal with and probably has as a consequence that we have more and longer-lived transactions than actually necessary since one rather adds more, just to be sure. I would therefore suggest to consistently try and remove all these surrounding transactions and rather have them inside the relevant methods, spanning only exactly as much execution context as necessary. This would have the added benefit of being able to get rid of explicit transaction contexts in most API handlers. Thoughts?
The text was updated successfully, but these errors were encountered: