Fixes #25092: Refactor CachedReportingService to make persistance simpler #5757
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.
https://issues.rudder.io/issues/25092
So, it seems that a lot of things are going on here, but that's not so much:
This commit splits the big
CachedReportingServiceImpl
into four parts:NodeStatusReportRepository
that only store/retrieve NodeStatusReports. Also add a simpleimplementation in memory. Latter, we will be able to persist in a psql backend storage
ReportingService
using previousNodeStatusReportRepository
. With that and the availability ofPolicyType
, it's now apparent that that service is just syntaxic sugor on top of filteringNodeStatusReports
.ComputeNodeStatusReportService
that get the logic with the queue but change nothing in it for now. It updatesNodeStatusReportRepository
with its updates. Latter on, we will be able to add a check on expiration based on node parameter about how long to keep expired compliance.FindNewNodeStatusReports
that only has the logic to retrieve information for new NodeStatusReportsin base from expected reports and run. The fact that it is now independant from
RepositoryService
method signature allows to show thatRuleId
,DirectiveId
andPolicyType
paramters are never used in it. We will be able to simplify it even further more latter on (his only job should be to retieveRunAndConfigInfo
, and letComputeNodeStatusReportService
do the computing).For now, we keep the same init logic than we had before the refactoring: there's a bootstrap action that expires all node compliance, so they are all computed back which now init the in-memory
NodeStatusReportRepository
. Of course once we have that in base, we will get it from there, only asking for the missing nodes if any.Then, the commit adapt signatures where
ReportingService
was used.It alos remove
ReportingServiceTest
which was only comments (very useful) ; and adaptCachedReportingServiceTest
to show that things still work when splitted in several pieces. One value change in that test because we don't exactly have the same call chain: now, the call to trigger a computation is explicit, and the chain is smarter on what should be updated (following https://issues.rudder.io/issues/24652 / #5737)All in all, the new code is much, much simpler and get ride of a lot of oranically-grown-not-refactored code ; and it will be rather easy to add the missing parts for persisting and not expiring compliance.