-
Notifications
You must be signed in to change notification settings - Fork 809
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
Move time source from db layer to PersistenceManager for better separation of concerns #6610
Comments
Hello! I’d like to work on this task. I have a couple of questions so far. Regarding the logic for generating timestamps: Based on this discussion, the Thank you for your guidance! 💪 |
New Development: Another approach I considered is introducing a new parameter to these methods for handling the current A third option is to pass the current time directly into the Sorry for asking so many questions upfront, I want to ensure I have a solid plan of how to proceed. If you have a better approach, please share with me. |
^ @bowenxia, @taylanisikdemir, @3vilhamster, if you have a moment, could you please share your insights or advice that might help me with this dilemma? |
We are looking at this, and will respond with some pointers shortly. |
@demirkayaender, I decided to take the initiative and move forward with the implementation I felt was suitable, which is - introducing a new parameter into the interface. I believe a visual example would make it clearer to determine the best approach, so I've submitted PR #6638 . I hope this helps draw attention and gather feedback on the current implementation—how it looks, what could be improved, and the next steps. |
Hi @ribaraka, I am working on a thorough refactor doc. It will still need some time (1 day-ish) to finish and some time (1 day-ish) for our team to review. I'll get back to you once it is done hopefully by either tmr or early next week. |
Hi @ribaraka , I've attached the refactor plan. |
Hi @ribaraka I've left a comment. Overall looks great :) |
Is your feature request related to a problem? Please describe.
Currently, the timeSrc field is being handled at the DB layer, but this implementation has raised some concerns about its correctness and responsibility allocation. Specifically, the timestamp should ideally be determined at the PersistenceManager level rather than the DB layer, which should solely focus on translating entity records into database queries without adding additional logic.
Problem Statement
The timeSrc field is currently being used within the DB layer to determine timestamps, including during query generation.
While this approach enables unit test validation by replacing time.Now() with a mockable db.timeSrc.Now(), it introduces a mixing of responsibilities.
The proper handling of timestamps should occur at the PersistenceManager level, ensuring better separation of concerns and adherence to the single responsibility principle.
Proposed Solution
Refactor the system so that the PersistenceManager level handles the timeSrc field.
The DB layer should only translate entity records into database queries without modifying or adding any additional information like timestamps.
This would involve removing the timestamp logic from the DB layer and ensuring it is fully managed by the upper layers.
Additional context
See discussion in this PR: #6593
The text was updated successfully, but these errors were encountered: