diff --git a/src/main/java/io/kurrent/dbclient/CreateProjection.java b/src/main/java/io/kurrent/dbclient/CreateProjection.java index dd1b2b89..d233fad9 100644 --- a/src/main/java/io/kurrent/dbclient/CreateProjection.java +++ b/src/main/java/io/kurrent/dbclient/CreateProjection.java @@ -29,6 +29,13 @@ public CreateProjection(final GrpcClient client, final String projectionName, fi @SuppressWarnings("unchecked") public CompletableFuture execute() { + if (engineVersion == 2 && trackEmittedStreams) { + CompletableFuture result = new CompletableFuture<>(); + result.completeExceptionally(new IllegalArgumentException( + "trackEmittedStreams is not supported when engineVersion is 2 (V2)")); + return result; + } + return this.client.run(channel -> { Projectionmanagement.CreateReq.Options.Continuous.Builder continuousBuilder = Projectionmanagement.CreateReq.Options.Continuous.newBuilder() diff --git a/src/main/java/io/kurrent/dbclient/CreateProjectionOptions.java b/src/main/java/io/kurrent/dbclient/CreateProjectionOptions.java index 5d5a9247..1d3b2f0e 100644 --- a/src/main/java/io/kurrent/dbclient/CreateProjectionOptions.java +++ b/src/main/java/io/kurrent/dbclient/CreateProjectionOptions.java @@ -54,8 +54,14 @@ public CreateProjectionOptions emitEnabled(boolean value) { * The engine version is pinned at create time and cannot be changed via update. * V2 has limitations versus V1: {@code trackEmittedStreams} is rejected, * result streams are not emitted, and bi-state projections are not supported. + * + * @throws IllegalArgumentException if {@code value} is not {@code 0}, {@code 1}, or {@code 2}. */ public CreateProjectionOptions engineVersion(int value) { + if (value < 0 || value > 2) { + throw new IllegalArgumentException( + "engineVersion must be 0, 1, or 2 (got " + value + ")"); + } this.engineVersion = value; return this; }