Skip to content

Commit fe38f89

Browse files
committed
feat: add engineVersion option to projection create
Exposes the V2 projection engine introduced in KurrentDB. Setting engineVersion(2) on CreateProjectionOptions selects V2; 0 (default) or 1 selects V1. The option is pinned at create time and cannot be changed via update.
1 parent 17ec29d commit fe38f89

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/main/java/io/kurrent/dbclient/CreateProjection.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class CreateProjection {
1212
private final String query;
1313
private final boolean trackEmittedStreams;
1414
private final boolean emitEnabled;
15+
private final int engineVersion;
1516
private final CreateProjectionOptions options;
1617

1718
public CreateProjection(final GrpcClient client, final String projectionName, final String query,
@@ -22,6 +23,7 @@ public CreateProjection(final GrpcClient client, final String projectionName, fi
2223
this.query = query;
2324
this.trackEmittedStreams = options.isTrackingEmittedStreams();
2425
this.emitEnabled = options.isEmitEnabled();
26+
this.engineVersion = options.getEngineVersion();
2527
this.options = options;
2628
}
2729

@@ -36,6 +38,7 @@ public CompletableFuture execute() {
3638
Projectionmanagement.CreateReq.Options.Builder optionsBuilder =
3739
Projectionmanagement.CreateReq.Options.newBuilder()
3840
.setQuery(query)
41+
.setEngineVersion(engineVersion)
3942
.setContinuous(continuousBuilder);
4043

4144
Projectionmanagement.CreateReq request = Projectionmanagement.CreateReq.newBuilder()

src/main/java/io/kurrent/dbclient/CreateProjectionOptions.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
public class CreateProjectionOptions extends OptionsBase<CreateProjectionOptions> {
77
private boolean trackEmittedStreams;
88
private boolean emitEnabled;
9+
private int engineVersion;
910

1011
private CreateProjectionOptions() {
1112
this.trackEmittedStreams = false;
@@ -26,6 +27,10 @@ boolean isEmitEnabled() {
2627
return emitEnabled;
2728
}
2829

30+
int getEngineVersion() {
31+
return engineVersion;
32+
}
33+
2934
/**
3035
* If true, the projection tracks all streams it creates.
3136
*/
@@ -41,4 +46,17 @@ public CreateProjectionOptions emitEnabled(boolean value) {
4146
this.emitEnabled = value;
4247
return this;
4348
}
49+
50+
/**
51+
* Selects the projection engine version. {@code 0} (default) or {@code 1} selects V1;
52+
* {@code 2} selects the V2 engine, which provides partition-based parallel processing.
53+
* <p>
54+
* The engine version is pinned at create time and cannot be changed via update.
55+
* V2 has limitations versus V1 — notably, {@code trackEmittedStreams} is rejected,
56+
* result streams are not emitted, and bi-state projections are not supported.
57+
*/
58+
public CreateProjectionOptions engineVersion(int value) {
59+
this.engineVersion = value;
60+
return this;
61+
}
4462
}

src/main/proto/kurrentdb/protocol/v1/projectionmanagement.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ message CreateReq {
2828
Continuous continuous = 3;
2929
}
3030
string query = 4;
31+
int32 engine_version = 5; // 0 or 1 = v1 (default), 2 = v2
3132

3233
message Transient {
3334
string name = 1;

0 commit comments

Comments
 (0)