Skip to content

Commit

Permalink
feat: Expose CDC data API settings in EnhancedBigtableStubSettings (g…
Browse files Browse the repository at this point in the history
…oogleapis#1376)

Co-authored-by: Teng Zhong <[email protected]>
  • Loading branch information
tengzhonger and Teng Zhong committed Sep 2, 2022
1 parent 7d58536 commit 31c1c8d
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,20 @@ public UnaryCallSettings.Builder<PingAndWarmRequest, Void> pingAndWarmSettings()
return pingAndWarmSettings;
}

/** 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 @@ -635,6 +635,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

0 comments on commit 31c1c8d

Please sign in to comment.