Move time source from db layer to PersistenceManager for better separation of concerns #6610
Labels
up-for-grabs
Issues that are good entry points for those new to Cadence that want to contribute
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: