All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.allegro.tech.hermes.consumers.consumer.offset.OffsetsToCommit Maven / Gradle / Ivy

There is a newer version: 2.10.0
Show newest version
package pl.allegro.tech.hermes.consumers.consumer.offset;

import pl.allegro.tech.hermes.api.SubscriptionName;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class OffsetsToCommit {

    private final Map> offsets = new HashMap<>();

    public OffsetsToCommit add(SubscriptionPartitionOffset offset) {
        Set subscriptionOffsets = offsets.get(offset.getSubscriptionName());
        if(subscriptionOffsets == null) {
            subscriptionOffsets = new HashSet<>();
            offsets.put(offset.getSubscriptionName(), subscriptionOffsets);
        }
        subscriptionOffsets.add(offset);
        return this;
    }

    public Set subscriptionNames() {
        return offsets.keySet();
    }

    public Set batchFor(SubscriptionName subscriptionName) {
        return offsets.get(subscriptionName);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy