package org.github.tess1o.geopulse.streaming.config;

import io.smallrye.common.annotation.Identifier;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@ApplicationScoped
public class ExecutorServiceProducer {

    @Produces
    @ApplicationScoped
    @Identifier("timeline-processing")
    public ExecutorService timelineProcessingExecutor() {
        return Executors.newThreadPerTaskExecutor(
                Thread.ofVirtual().name("timeline-", 0).factory()
        );
    }

    @Produces
    @ApplicationScoped
    @Identifier("coverage-processing")
    public ExecutorService coverageProcessingExecutor() {
        return Executors.newThreadPerTaskExecutor(
                Thread.ofVirtual().name("coverage-", 0).factory()
        );
    }

    @Produces
    @ApplicationScoped
    @Identifier("weather-processing")
    public ExecutorService weatherProcessingExecutor() {
        return Executors.newThreadPerTaskExecutor(
                Thread.ofVirtual().name("weather-", 0).factory()
        );
    }

    @Produces
    @ApplicationScoped
    @Identifier("map-matching-processing")
    public ExecutorService mapMatchingProcessingExecutor() {
        return Executors.newThreadPerTaskExecutor(
                Thread.ofVirtual().name("map-matching-", 0).factory()
        );
    }
}
