de.otto.synapse.endpoint.receiver.aws.KinesisMessageLogIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of synapse-aws Show documentation
Show all versions of synapse-aws Show documentation
A library used at otto.de to implement Spring Boot based event-sourcing microserivces.
package de.otto.synapse.endpoint.receiver.aws;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import java.util.List;
import static com.google.common.collect.Maps.uniqueIndex;
import static java.util.Objects.requireNonNull;
public class KinesisMessageLogIterator {
private final ImmutableMap shardIterators;
public KinesisMessageLogIterator(final @Nonnull List shardIterators) {
this.shardIterators = uniqueIndex(shardIterators, (iter) -> iter.getShardPosition().shardName());
}
@Nonnull
public KinesisShardIterator getShardIterator(final String shardName) {
return requireNonNull(
shardIterators.get(shardName),
"Unknown shard " + shardName
);
}
}