Skip to content

Commit f85a851

Browse files
committed
Update
1 parent 580efb9 commit f85a851

3 files changed

Lines changed: 40 additions & 8 deletions

File tree

google-cloud-language/src/main/java/com/google/cloud/language/spi/v1/LanguageServiceSettings.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.google.cloud.language.spi.v1;
1717

1818
import com.google.api.gax.core.GoogleCredentialsProvider;
19+
import com.google.api.gax.core.PropertiesProvider;
1920
import com.google.api.gax.core.RetrySettings;
2021
import com.google.api.gax.grpc.ChannelProvider;
2122
import com.google.api.gax.grpc.ClientSettings;
@@ -86,6 +87,11 @@ public class LanguageServiceSettings extends ClientSettings {
8687
private static final String DEFAULT_GAPIC_NAME = "gapic";
8788
private static final String DEFAULT_GAPIC_VERSION = "";
8889

90+
private static final String PROPERTIES_FILE = "/project.properties";
91+
private static final String META_VERSION_KEY = "artifact.version";
92+
93+
private static String gapicVersion;
94+
8995
private final SimpleCallSettings<AnalyzeSentimentRequest, AnalyzeSentimentResponse>
9096
analyzeSentimentSettings;
9197
private final SimpleCallSettings<AnalyzeEntitiesRequest, AnalyzeEntitiesResponse>
@@ -151,8 +157,13 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
151157
}
152158

153159
private static String getGapicVersion() {
154-
String packageVersion = LanguageServiceSettings.class.getPackage().getImplementationVersion();
155-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
160+
if (gapicVersion == null) {
161+
gapicVersion =
162+
PropertiesProvider.loadProperty(
163+
LanguageServiceSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
164+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
165+
}
166+
return gapicVersion;
156167
}
157168

158169
/** Returns a builder for this class with recommended defaults. */

google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/SpeechSettings.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.google.cloud.speech.spi.v1beta1;
1717

1818
import com.google.api.gax.core.GoogleCredentialsProvider;
19+
import com.google.api.gax.core.PropertiesProvider;
1920
import com.google.api.gax.core.RetrySettings;
2021
import com.google.api.gax.grpc.ChannelProvider;
2122
import com.google.api.gax.grpc.ClientSettings;
@@ -86,6 +87,11 @@ public class SpeechSettings extends ClientSettings {
8687
private static final String DEFAULT_GAPIC_NAME = "gapic";
8788
private static final String DEFAULT_GAPIC_VERSION = "";
8889

90+
private static final String PROPERTIES_FILE = "/project.properties";
91+
private static final String META_VERSION_KEY = "artifact.version";
92+
93+
private static String gapicVersion;
94+
8995
private final SimpleCallSettings<SyncRecognizeRequest, SyncRecognizeResponse>
9096
syncRecognizeSettings;
9197
private final OperationCallSettings<AsyncRecognizeRequest, AsyncRecognizeResponse>
@@ -145,8 +151,12 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
145151
}
146152

147153
private static String getGapicVersion() {
148-
String packageVersion = SpeechSettings.class.getPackage().getImplementationVersion();
149-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
154+
if (gapicVersion == null) {
155+
gapicVersion =
156+
PropertiesProvider.loadProperty(SpeechSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
157+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
158+
}
159+
return gapicVersion;
150160
}
151161

152162
/** Returns a builder for this class with recommended defaults. */
@@ -209,9 +219,9 @@ public static class Builder extends ClientSettings.Builder {
209219
.setInitialRetryDelay(Duration.millis(100L))
210220
.setRetryDelayMultiplier(1.3)
211221
.setMaxRetryDelay(Duration.millis(60000L))
212-
.setInitialRpcTimeout(Duration.millis(60000L))
222+
.setInitialRpcTimeout(Duration.millis(190000L))
213223
.setRpcTimeoutMultiplier(1.0)
214-
.setMaxRpcTimeout(Duration.millis(60000L))
224+
.setMaxRpcTimeout(Duration.millis(190000L))
215225
.setTotalTimeout(Duration.millis(600000L));
216226
definitions.put("default", settingsBuilder);
217227
RETRY_PARAM_DEFINITIONS = definitions.build();

google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/TraceServiceSettings.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static com.google.cloud.trace.spi.v1.PagedResponseWrappers.ListTracesPagedResponse;
1919

2020
import com.google.api.gax.core.GoogleCredentialsProvider;
21+
import com.google.api.gax.core.PropertiesProvider;
2122
import com.google.api.gax.core.RetrySettings;
2223
import com.google.api.gax.grpc.CallContext;
2324
import com.google.api.gax.grpc.ChannelProvider;
@@ -95,6 +96,11 @@ public class TraceServiceSettings extends ClientSettings {
9596
private static final String DEFAULT_GAPIC_NAME = "gapic";
9697
private static final String DEFAULT_GAPIC_VERSION = "";
9798

99+
private static final String PROPERTIES_FILE = "/project.properties";
100+
private static final String META_VERSION_KEY = "artifact.version";
101+
102+
private static String gapicVersion;
103+
98104
private final SimpleCallSettings<PatchTracesRequest, Empty> patchTracesSettings;
99105
private final SimpleCallSettings<GetTraceRequest, Trace> getTraceSettings;
100106
private final PagedCallSettings<ListTracesRequest, ListTracesResponse, ListTracesPagedResponse>
@@ -151,8 +157,13 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
151157
}
152158

153159
private static String getGapicVersion() {
154-
String packageVersion = TraceServiceSettings.class.getPackage().getImplementationVersion();
155-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
160+
if (gapicVersion == null) {
161+
gapicVersion =
162+
PropertiesProvider.loadProperty(
163+
TraceServiceSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
164+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
165+
}
166+
return gapicVersion;
156167
}
157168

158169
/** Returns a builder for this class with recommended defaults. */

0 commit comments

Comments
 (0)