Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public class SettingsCommentComposer {
private static final String CLASS_HEADER_DEFAULT_ADDRESS_PORT_PATTERN =
"The default service address (%s) and default port (%d) are used.";
private static final String CLASS_HEADER_SAMPLE_CODE_PATTERN =
"For example, to set the total timeout of %s to 30 seconds:";
"For example, to set the [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) of %s:";

private static final String CLASS_HEADER_SAMPLE_CODE_SUFFIX =
"Please refer to the [Client Side Retry Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for additional support in setting retries.";

private static final String CLASS_HEADER_BUILDER_DESCRIPTION =
"The builder of this class is recursive, so contained classes are themselves builders. When"
Expand Down Expand Up @@ -170,7 +173,8 @@ public static List<CommentStatement> createClassHeaderComments(
String.format(
CLASS_HEADER_SAMPLE_CODE_PATTERN,
JavaStyle.toLowerCamelCase(methodNameOpt.get())))
.addSampleCode(sampleCodeOpt.get());
.addSampleCode(sampleCodeOpt.get())
.addComment(CLASS_HEADER_SAMPLE_CODE_SUFFIX);
}

if (isDeprecated) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,25 @@ public static Optional<Sample> composeSettingsSample(
.setExprReferenceExpr(retrySettingsArgExpr)
.setMethodName("toBuilder")
.build();
MethodInvocationExpr ofSecondMethodInvocationExpr =
MethodInvocationExpr ofOneSecondMethodInvocationExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(
TypeNode.withReference(ConcreteReference.withClazz(Duration.class)))
.setMethodName("ofSeconds")
.setArguments(
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.INT).setValue("1").build()))
.build();
MethodInvocationExpr ofFiveSecondsMethodInvocationExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(
TypeNode.withReference(ConcreteReference.withClazz(Duration.class)))
.setMethodName("ofSeconds")
.setArguments(
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.INT).setValue("5").build()))
.build();
MethodInvocationExpr ofThirtySecondsMethodInvocationExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(
TypeNode.withReference(ConcreteReference.withClazz(Duration.class)))
Expand All @@ -98,11 +116,85 @@ public static Optional<Sample> composeSettingsSample(
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.INT).setValue("30").build()))
.build();
MethodInvocationExpr ofSixtySecondsMethodInvocationExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(
TypeNode.withReference(ConcreteReference.withClazz(Duration.class)))
.setMethodName("ofSeconds")
.setArguments(
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.INT).setValue("60").build()))
.build();
MethodInvocationExpr ofThreeHundredSecondsMethodInvocationExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(
TypeNode.withReference(ConcreteReference.withClazz(Duration.class)))
.setMethodName("ofSeconds")
.setArguments(
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.INT).setValue("300").build()))
.build();
retrySettingsArgExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(retrySettingsArgExpr)
.setMethodName("setInitialRetryDelayDuration")
.setArguments(ofOneSecondMethodInvocationExpr)
.build();
retrySettingsArgExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(retrySettingsArgExpr)
.setMethodName("setInitialRpcTimeoutDuration")
.setArguments(ofFiveSecondsMethodInvocationExpr)
.build();
retrySettingsArgExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(retrySettingsArgExpr)
.setMethodName("setMaxAttempts")
.setArguments(
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.INT).setValue("5").build()))
.build();
retrySettingsArgExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(retrySettingsArgExpr)
.setMethodName("setMaxRetryDelayDuration")
.setArguments(ofThirtySecondsMethodInvocationExpr)
.build();
retrySettingsArgExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(retrySettingsArgExpr)
.setMethodName("setMaxRpcTimeoutDuration")
.setArguments(ofSixtySecondsMethodInvocationExpr)
.build();
double retryDelayMultiplier = 1.3;
retrySettingsArgExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(retrySettingsArgExpr)
.setMethodName("setRetryDelayMultiplier")
.setArguments(
ValueExpr.withValue(
PrimitiveValue.builder()
.setType(TypeNode.DOUBLE)
.setValue(String.format("%.1f", retryDelayMultiplier))
.build()))
.build();
double rpcTimeoutMultiplier = 1.5;
retrySettingsArgExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(retrySettingsArgExpr)
.setMethodName("setRpcTimeoutMultiplier")
.setArguments(
ValueExpr.withValue(
PrimitiveValue.builder()
.setType(TypeNode.DOUBLE)
.setValue(String.format("%.1f", rpcTimeoutMultiplier))
.build()))
.build();
retrySettingsArgExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(retrySettingsArgExpr)
.setMethodName("setTotalTimeout")
.setArguments(ofSecondMethodInvocationExpr)
.setMethodName("setTotalTimeoutDuration")
.setArguments(ofThreeHundredSecondsMethodInvocationExpr)
.build();
retrySettingsArgExpr =
MethodInvocationExpr.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ import javax.annotation.Generated;
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of echoWithVersionMethod to 30 seconds:
* <p>For example, to set the
* [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings)
* of echoWithVersionMethod:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
Expand All @@ -57,10 +59,21 @@ import javax.annotation.Generated;
* .echoWithVersionMethodSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .setInitialRetryDelayDuration(Duration.ofSeconds(1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to see that we are using the new java.time methods! cc: @diegomarquezp

* .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
* .setMaxAttempts(5)
* .setMaxRetryDelayDuration(Duration.ofSeconds(30))
* .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
* .setRetryDelayMultiplier(1.3)
* .setRpcTimeoutMultiplier(1.5)
* .setTotalTimeoutDuration(Duration.ofSeconds(300))
* .build());
* EchoWithVersionStubSettings echoWithVersionSettings = echoWithVersionSettingsBuilder.build();
* }</pre>
*
* Please refer to the [Client Side Retry
* Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for
* additional support in setting retries.
*/
@Generated("by gapic-generator-java")
public class EchoWithVersionStubSettings extends StubSettings<EchoWithVersionStubSettings> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import javax.annotation.Generated;
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of fastFibonacci to 30 seconds:
* <p>For example, to set the
* [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings)
* of fastFibonacci:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
Expand All @@ -48,11 +50,22 @@ import javax.annotation.Generated;
* .fastFibonacciSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .setInitialRetryDelayDuration(Duration.ofSeconds(1))
* .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
* .setMaxAttempts(5)
* .setMaxRetryDelayDuration(Duration.ofSeconds(30))
* .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
* .setRetryDelayMultiplier(1.3)
* .setRpcTimeoutMultiplier(1.5)
* .setTotalTimeoutDuration(Duration.ofSeconds(300))
* .build());
* DeprecatedServiceSettings deprecatedServiceSettings = deprecatedServiceSettingsBuilder.build();
* }</pre>
*
* Please refer to the [Client Side Retry
* Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for
* additional support in setting retries.
*
* @deprecated This class is deprecated and will be removed in the next major version update.
*/
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ import org.threeten.bp.Duration;
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of fastFibonacci to 30 seconds:
* <p>For example, to set the
* [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings)
* of fastFibonacci:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
Expand All @@ -58,12 +60,23 @@ import org.threeten.bp.Duration;
* .fastFibonacciSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .setInitialRetryDelayDuration(Duration.ofSeconds(1))
* .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
* .setMaxAttempts(5)
* .setMaxRetryDelayDuration(Duration.ofSeconds(30))
* .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
* .setRetryDelayMultiplier(1.3)
* .setRpcTimeoutMultiplier(1.5)
* .setTotalTimeoutDuration(Duration.ofSeconds(300))
* .build());
* DeprecatedServiceStubSettings deprecatedServiceSettings =
* deprecatedServiceSettingsBuilder.build();
* }</pre>
*
* Please refer to the [Client Side Retry
* Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for
* additional support in setting retries.
*
* @deprecated This class is deprecated and will be removed in the next major version update.
*/
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ import javax.annotation.Generated;
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of echo to 30 seconds:
* <p>For example, to set the
* [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings)
* of echo:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
Expand All @@ -55,10 +57,21 @@ import javax.annotation.Generated;
* .echoSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .setInitialRetryDelayDuration(Duration.ofSeconds(1))
* .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
* .setMaxAttempts(5)
* .setMaxRetryDelayDuration(Duration.ofSeconds(30))
* .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
* .setRetryDelayMultiplier(1.3)
* .setRpcTimeoutMultiplier(1.5)
* .setTotalTimeoutDuration(Duration.ofSeconds(300))
* .build());
* EchoSettings echoSettings = echoSettingsBuilder.build();
* }</pre>
*
* Please refer to the [Client Side Retry
* Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for
* additional support in setting retries.
*/
@BetaApi
@Generated("by gapic-generator-java")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ import org.threeten.bp.Duration;
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of echo to 30 seconds:
* <p>For example, to set the
* [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings)
* of echo:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
Expand All @@ -84,10 +86,21 @@ import org.threeten.bp.Duration;
* .echoSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .setInitialRetryDelayDuration(Duration.ofSeconds(1))
* .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
* .setMaxAttempts(5)
* .setMaxRetryDelayDuration(Duration.ofSeconds(30))
* .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
* .setRetryDelayMultiplier(1.3)
* .setRpcTimeoutMultiplier(1.5)
* .setTotalTimeoutDuration(Duration.ofSeconds(300))
* .build());
* EchoStubSettings echoSettings = echoSettingsBuilder.build();
* }</pre>
*
* Please refer to the [Client Side Retry
* Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for
* additional support in setting retries.
*/
@BetaApi
@Generated("by gapic-generator-java")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ import org.threeten.bp.Duration;
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of deleteLog to 30 seconds:
* <p>For example, to set the
* [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings)
* of deleteLog:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
Expand All @@ -91,10 +93,21 @@ import org.threeten.bp.Duration;
* .deleteLogSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .setInitialRetryDelayDuration(Duration.ofSeconds(1))
* .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
* .setMaxAttempts(5)
* .setMaxRetryDelayDuration(Duration.ofSeconds(30))
* .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
* .setRetryDelayMultiplier(1.3)
* .setRpcTimeoutMultiplier(1.5)
* .setTotalTimeoutDuration(Duration.ofSeconds(300))
* .build());
* LoggingServiceV2StubSettings loggingServiceV2Settings = loggingServiceV2SettingsBuilder.build();
* }</pre>
*
* Please refer to the [Client Side Retry
* Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for
* additional support in setting retries.
*/
@Generated("by gapic-generator-java")
public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2StubSettings> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ import org.threeten.bp.Duration;
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of createTopic to 30 seconds:
* <p>For example, to set the
* [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings)
* of createTopic:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
Expand All @@ -91,10 +93,21 @@ import org.threeten.bp.Duration;
* .createTopicSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .setInitialRetryDelayDuration(Duration.ofSeconds(1))
* .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
* .setMaxAttempts(5)
* .setMaxRetryDelayDuration(Duration.ofSeconds(30))
* .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
* .setRetryDelayMultiplier(1.3)
* .setRpcTimeoutMultiplier(1.5)
* .setTotalTimeoutDuration(Duration.ofSeconds(300))
* .build());
* PublisherStubSettings publisherSettings = publisherSettingsBuilder.build();
* }</pre>
*
* Please refer to the [Client Side Retry
* Guide](https://github.com/googleapis/google-cloud-java/blob/main/docs/client_retries.md) for
* additional support in setting retries.
*/
@Generated("by gapic-generator-java")
public class PublisherStubSettings extends StubSettings<PublisherStubSettings> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ public class SyncEcho {
.echoSettings()
.getRetrySettings()
.toBuilder()
.setTotalTimeout(Duration.ofSeconds(30))
.setInitialRetryDelayDuration(Duration.ofSeconds(1))
.setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
.setMaxAttempts(5)
.setMaxRetryDelayDuration(Duration.ofSeconds(30))
.setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
.setRetryDelayMultiplier(1.3)
.setRpcTimeoutMultiplier(1.5)
.setTotalTimeoutDuration(Duration.ofSeconds(300))
.build());
EchoSettings echoSettings = echoSettingsBuilder.build();
}
Expand Down
Loading