Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Expose CDC data API settings in EnhancedBigtableStubSettings #1376

Merged
merged 1 commit into from
Sep 1, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,20 @@ public UnaryCallSettings.Builder<ReadModifyWriteRow, Row> readModifyWriteRowSett
return readModifyWriteRowSettings;
}

/** Returns the builder for the settings used for calls to ReadChangeStream. */
public ServerStreamingCallSettings.Builder<ReadChangeStreamQuery, ChangeStreamRecord>
readChangeStreamSettings() {
return readChangeStreamSettings;
}

/**
* Returns the builder for the settings used for calls to GenerateInitialChangeStreamPartitions.
*/
public ServerStreamingCallSettings.Builder<String, ByteStringRange>
generateInitialChangeStreamPartitionsSettings() {
return generateInitialChangeStreamPartitionsSettings;
}

@SuppressWarnings("unchecked")
public EnhancedBigtableStubSettings build() {
Preconditions.checkState(projectId != null, "Project id must be set");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,81 @@ public void checkAndMutateRowSettingsAreNotLostTest() {
.isEqualTo(retrySettings);
}

@Test
public void generateInitialChangeStreamPartitionsSettingsAreNotLostTest() {
String dummyProjectId = "my-project";
String dummyInstanceId = "my-instance";

EnhancedBigtableStubSettings.Builder builder =
EnhancedBigtableStubSettings.newBuilder()
.setProjectId(dummyProjectId)
.setInstanceId(dummyInstanceId);

RetrySettings retrySettings = RetrySettings.newBuilder().build();
builder
.generateInitialChangeStreamPartitionsSettings()
.setRetryableCodes(Code.ABORTED, Code.DEADLINE_EXCEEDED)
.setRetrySettings(retrySettings)
.build();

assertThat(builder.generateInitialChangeStreamPartitionsSettings().getRetryableCodes())
.containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED);
assertThat(builder.generateInitialChangeStreamPartitionsSettings().getRetrySettings())
.isEqualTo(retrySettings);

assertThat(builder.build().generateInitialChangeStreamPartitionsSettings().getRetryableCodes())
.containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED);
assertThat(builder.build().generateInitialChangeStreamPartitionsSettings().getRetrySettings())
.isEqualTo(retrySettings);

assertThat(
builder
.build()
.toBuilder()
.generateInitialChangeStreamPartitionsSettings()
.getRetryableCodes())
.containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED);
assertThat(
builder
.build()
.toBuilder()
.generateInitialChangeStreamPartitionsSettings()
.getRetrySettings())
.isEqualTo(retrySettings);
}

@Test
public void readChangeStreamSettingsAreNotLostTest() {
String dummyProjectId = "my-project";
String dummyInstanceId = "my-instance";

EnhancedBigtableStubSettings.Builder builder =
EnhancedBigtableStubSettings.newBuilder()
.setProjectId(dummyProjectId)
.setInstanceId(dummyInstanceId);

RetrySettings retrySettings = RetrySettings.newBuilder().build();
builder
.readChangeStreamSettings()
.setRetryableCodes(Code.ABORTED, Code.DEADLINE_EXCEEDED)
.setRetrySettings(retrySettings)
.build();

assertThat(builder.readChangeStreamSettings().getRetryableCodes())
.containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED);
assertThat(builder.readChangeStreamSettings().getRetrySettings()).isEqualTo(retrySettings);

assertThat(builder.build().readChangeStreamSettings().getRetryableCodes())
.containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED);
assertThat(builder.build().readChangeStreamSettings().getRetrySettings())
.isEqualTo(retrySettings);

assertThat(builder.build().toBuilder().readChangeStreamSettings().getRetryableCodes())
.containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED);
assertThat(builder.build().toBuilder().readChangeStreamSettings().getRetrySettings())
.isEqualTo(retrySettings);
}

@Test
public void checkAndMutateRowSettingsAreSane() {
UnaryCallSettings.Builder<ConditionalRowMutation, Boolean> builder =
Expand Down