Skip to content

Commit

Permalink
Merge pull request #544 from catenax-ng/feat/cleaning_service/Request…
Browse files Browse the repository at this point in the history
…_Cleaning_for_BPN_Update

Feat(Cleaning): Add logic for bpn cleaning upon pool update
  • Loading branch information
nicoprow authored Oct 23, 2023
2 parents c8146c2 + a90d869 commit 00c58d9
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 00c58d9

Please sign in to comment.