Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/io/kurrent/dbclient/CreateProjection.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CreateProjection {
private final String query;
private final boolean trackEmittedStreams;
private final boolean emitEnabled;
private final int engineVersion;
private final CreateProjectionOptions options;

public CreateProjection(final GrpcClient client, final String projectionName, final String query,
Expand All @@ -22,6 +23,7 @@ public CreateProjection(final GrpcClient client, final String projectionName, fi
this.query = query;
this.trackEmittedStreams = options.isTrackingEmittedStreams();
this.emitEnabled = options.isEmitEnabled();
this.engineVersion = options.getEngineVersion();
this.options = options;
}

Expand All @@ -36,6 +38,7 @@ public CompletableFuture execute() {
Projectionmanagement.CreateReq.Options.Builder optionsBuilder =
Projectionmanagement.CreateReq.Options.newBuilder()
.setQuery(query)
.setEngineVersion(engineVersion)
.setContinuous(continuousBuilder);

Projectionmanagement.CreateReq request = Projectionmanagement.CreateReq.newBuilder()
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/io/kurrent/dbclient/CreateProjectionOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class CreateProjectionOptions extends OptionsBase<CreateProjectionOptions> {
private boolean trackEmittedStreams;
private boolean emitEnabled;
private int engineVersion;

private CreateProjectionOptions() {
this.trackEmittedStreams = false;
Expand All @@ -26,6 +27,10 @@ boolean isEmitEnabled() {
return emitEnabled;
}

int getEngineVersion() {
return engineVersion;
}

/**
* If true, the projection tracks all streams it creates.
*/
Expand All @@ -41,4 +46,17 @@ public CreateProjectionOptions emitEnabled(boolean value) {
this.emitEnabled = value;
return this;
}

/**
* Selects the projection engine version. {@code 0} (default) or {@code 1} selects V1;
* {@code 2} selects the V2 engine, which provides partition-based parallel processing.
* <p>
* 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.
*/
public CreateProjectionOptions engineVersion(int value) {
this.engineVersion = value;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ message CreateReq {
Continuous continuous = 3;
}
string query = 4;
int32 engine_version = 5; // 0 or 1 = v1 (default), 2 = v2

message Transient {
string name = 1;
Expand Down
Loading