Skip to content

Commit

Permalink
fix: enforce one partition for single partition mapper (#4427)
Browse files Browse the repository at this point in the history
fixes: #4209
  • Loading branch information
stuartwdouglas authored Feb 17, 2025
1 parent cf3ed06 commit fbffe36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import xyz.block.ftl.GeneratedRef;
import xyz.block.ftl.LeaseClient;
import xyz.block.ftl.Secret;
import xyz.block.ftl.SinglePartitionMapper;
import xyz.block.ftl.Subscription;
import xyz.block.ftl.Topic;
import xyz.block.ftl.TypeAlias;
Expand All @@ -35,4 +36,5 @@ private FTLDotNames() {
public static final DotName LEASE_CLIENT = DotName.createSimple(LeaseClient.class);
public static final DotName GENERATED_REF = DotName.createSimple(GeneratedRef.class);
public static final DotName TOPIC = DotName.createSimple(Topic.class);
public static final DotName SINGLE_PARTITION_MAPPER = DotName.createSimple(SinglePartitionMapper.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ TopicsBuildItem handleTopics(CombinedIndexBuildItem index, BuildProducer<Generat
if (topicDefinition.value("partitions") != null) {
partitions = topicDefinition.value("partitions").asInt();
}
if (partitionMapperClass.equals(FTLDotNames.SINGLE_PARTITION_MAPPER) && partitions != 1) {
throw new RuntimeException("SinglePartitionMapper can only be used with a single partition");
}

String name = topicDefinition.value("name").asString();
if (names.contains(name)) {
Expand Down

0 comments on commit fbffe36

Please sign in to comment.