Skip to content

Commit

Permalink
feat(Cleaning): Add logic for bpn cleaning upon pool update
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiodmota committed Oct 19, 2023
1 parent 7acbcaa commit a90d869
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ class CleaningServiceDummy(

private val logger = KotlinLogging.logger { }


@Scheduled(cron = "\${cleaningService.pollingCron:-}", zone = "UTC")
fun pollForCleaningTasks() {
processPollingTasks(TaskStep.CleanAndSync)
processPollingTasks(TaskStep.Clean)
}


private fun processPollingTasks(step: TaskStep) {
try {
logger.info { "Starting polling for cleaning tasks from Orchestrator..." }
val step = TaskStep.CleanAndSync
logger.info { "Starting polling for cleaning tasks from Orchestrator... TaskStep ${step.name}" }

// Step 1: Fetch and reserve the next cleaning request
val cleaningRequest = orchestrationApiClient.goldenRecordTasks
.reserveTasksForStep(TaskStepReservationRequest(amount = 10, step))

Expand All @@ -53,11 +56,9 @@ class CleaningServiceDummy(

if (cleaningTasks.isNotEmpty()) {
val cleaningResults = cleaningTasks.map { reservedTask ->
// Step 2: Generate dummy cleaning results
processCleaningTask(reservedTask)
}

// Step 3: Send the cleaning result back to the Orchestrator
orchestrationApiClient.goldenRecordTasks.resolveStepResults(TaskStepResultRequest(step, cleaningResults))
logger.info { "Cleaning tasks processing completed for this iteration." }
}
Expand Down

0 comments on commit a90d869

Please sign in to comment.