use of com.google.api.gax.retrying.RetrySettings in project toolkit by googleapis.
the class RetryDefinitionsTransformer method generateRetryParamsDefinitions.
public List<RetryParamsDefinitionView> generateRetryParamsDefinitions(InterfaceContext context) {
List<RetryParamsDefinitionView> definitions = new ArrayList<>();
SurfaceNamer namer = context.getNamer();
for (Entry<String, RetrySettings> retryCodesDef : context.getInterfaceConfig().getRetrySettingsDefinition().entrySet()) {
RetrySettings settings = retryCodesDef.getValue();
RetryParamsDefinitionView.Builder params = RetryParamsDefinitionView.newBuilder();
params.key(retryCodesDef.getKey());
params.name(namer.publicMethodName(Name.from(retryCodesDef.getKey())));
params.retryBackoffMethodName(namer.retryBackoffMethodName(retryCodesDef.getKey()));
params.timeoutBackoffMethodName(namer.timeoutBackoffMethodName(retryCodesDef.getKey()));
params.initialRetryDelay(settings.getInitialRetryDelay());
params.retryDelayMultiplier(settings.getRetryDelayMultiplier());
params.maxRetryDelay(settings.getMaxRetryDelay());
params.initialRpcTimeout(settings.getInitialRpcTimeout());
params.rpcTimeoutMultiplier(settings.getRpcTimeoutMultiplier());
params.maxRpcTimeout(settings.getMaxRpcTimeout());
params.totalTimeout(settings.getTotalTimeout());
definitions.add(params.build());
}
return definitions;
}
use of com.google.api.gax.retrying.RetrySettings in project toolkit by googleapis.
the class GoGapicSurfaceTransformer method generateRetryConfigDefinitions.
@VisibleForTesting
List<RetryConfigDefinitionView> generateRetryConfigDefinitions(InterfaceContext context, List<MethodModel> methods) {
Set<RetryConfigDefinitionView.Name> retryNames = new HashSet<>();
for (MethodModel method : methods) {
MethodConfig conf = context.getMethodConfig(method);
retryNames.add(RetryConfigDefinitionView.Name.create(conf.getRetrySettingsConfigName(), conf.getRetryCodesConfigName()));
}
TreeMap<RetryConfigDefinitionView.Name, RetryConfigDefinitionView> retryDef = new TreeMap<>();
Map<String, ImmutableSet<String>> retryCodesDef = context.getInterfaceConfig().getRetryCodesDefinition();
Map<String, RetrySettings> retryParamsDef = context.getInterfaceConfig().getRetrySettingsDefinition();
for (RetryConfigDefinitionView.Name name : retryNames) {
ImmutableSet<String> codes = retryCodesDef.get(name.retryCodesConfigName());
if (codes.isEmpty()) {
continue;
}
List<String> retryCodeNames = new ArrayList<>();
for (String code : codes) {
retryCodeNames.add(context.getNamer().getStatusCodeName(code));
}
retryDef.put(name, RetryConfigDefinitionView.newBuilder().name(name).retryCodes(retryCodeNames).params(retryParamsDef.get(name.retrySettingsConfigName())).build());
}
if (!retryDef.isEmpty()) {
context.getImportTypeTable().saveNicknameFor("time;;;");
context.getImportTypeTable().saveNicknameFor("google.golang.org/grpc/codes;;;");
}
return new ArrayList<>(retryDef.values());
}
use of com.google.api.gax.retrying.RetrySettings in project divolte-collector by divolte.
the class GoogleCloudPubSubSinkConfigurationTest method testRetryMaxRpcTimeoutDefaultsToInitialRpcTimeout.
@Test
public void testRetryMaxRpcTimeoutDefaultsToInitialRpcTimeout() {
final RetrySettings retrySettings = new GooglePubSubRetryConfiguration(null, null, null, null, null, java.time.Duration.ofNanos(138263), null, null).createRetrySettings();
assertEquals(retrySettings.getInitialRpcTimeout(), retrySettings.getMaxRpcTimeout());
}
use of com.google.api.gax.retrying.RetrySettings in project divolte-collector by divolte.
the class GoogleCloudPubSubSinkConfigurationTest method testDefaultRetryConfigurationValid.
@Test
public void testDefaultRetryConfigurationValid() {
// Check that we can generate settings from our defaults.
final RetrySettings retrySettings = GoogleCloudPubSubSinkConfiguration.DEFAULT_RETRY_SETTINGS.createRetrySettings();
assertNotNull(retrySettings);
}
Aggregations