package at.procon.eventhub.processing.eventprocessing.module;

import at.procon.eventhub.dto.EventHubEventDto;
import at.procon.eventhub.processing.eventprocessing.plan.RuntimeProcessingExecutionApiRequest;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public record RuntimeProcessingModuleContext(
        RuntimeProcessingExecutionApiRequest request,
        List<EventHubEventDto> events,
        Map<String, Object> attributes,
        Map<String, RuntimeProcessingModuleResult> previousResults
) {
    public RuntimeProcessingModuleContext {
        events = events == null ? List.of() : List.copyOf(events);
        attributes = attributes == null ? Map.of() : Collections.unmodifiableMap(new LinkedHashMap<>(attributes));
        previousResults = previousResults == null ? Map.of() : Collections.unmodifiableMap(new LinkedHashMap<>(previousResults));
    }
}
