package com.lingniu.ingest.api.consumer;

import java.util.ArrayList;
import java.util.List;

@FunctionalInterface
public interface EnvelopeIngestor {
    EnvelopeIngestResult tryIngest(byte[] kafkaValue);

    default List<EnvelopeIngestResult> tryIngestAll(List<byte[]> kafkaValues) {
        if (kafkaValues == null || kafkaValues.isEmpty()) {
            return List.of();
        }
        List<EnvelopeIngestResult> results = new ArrayList<>(kafkaValues.size());
        for (byte[] kafkaValue : kafkaValues) {
            results.add(tryIngest(kafkaValue));
        }
        return results;
    }
}
