package at.procon.dip.clustering.service;

import java.util.UUID;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
@Slf4j
public class EmbeddingClusterAsyncExecutionService {

    private final EmbeddingClusterRunService runService;

    @Async("clusteringRunExecutor")
    public void executeRunAsync(UUID runId) {
        try {
            runService.executeQueuedRun(runId);
        } catch (Exception ex) {
            log.error("Cluster run {} failed during async execution: {}", runId, ex.getMessage(), ex);
        }
    }
}
