Search in sources :

Example 6 with RetrySettings

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;
}
Also used : RetrySettings(com.google.api.gax.retrying.RetrySettings) RetryParamsDefinitionView(com.google.api.codegen.viewmodel.RetryParamsDefinitionView) ArrayList(java.util.ArrayList)

Example 7 with RetrySettings

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());
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) RetryConfigDefinitionView(com.google.api.codegen.viewmodel.RetryConfigDefinitionView) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) MethodConfig(com.google.api.codegen.config.MethodConfig) RetrySettings(com.google.api.gax.retrying.RetrySettings) ImmutableSet(com.google.common.collect.ImmutableSet) HashSet(java.util.HashSet) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 8 with RetrySettings

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());
}
Also used : RetrySettings(com.google.api.gax.retrying.RetrySettings) Test(org.junit.Test)

Example 9 with RetrySettings

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);
}
Also used : RetrySettings(com.google.api.gax.retrying.RetrySettings) Test(org.junit.Test)

Aggregations

RetrySettings (com.google.api.gax.retrying.RetrySettings)9 ImmutableSet (com.google.common.collect.ImmutableSet)3 CollectionConfigProto (com.google.api.codegen.CollectionConfigProto)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 JsonCreator (com.fasterxml.jackson.annotation.JsonCreator)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 RetryParamsDefinitionProto (com.google.api.codegen.RetryParamsDefinitionProto)1 MethodConfig (com.google.api.codegen.config.MethodConfig)1 MethodModel (com.google.api.codegen.config.MethodModel)1 Method (com.google.api.codegen.discovery.Method)1 RetryConfigDefinitionView (com.google.api.codegen.viewmodel.RetryConfigDefinitionView)1 RetryParamsDefinitionView (com.google.api.codegen.viewmodel.RetryParamsDefinitionView)1 BatchingSettings (com.google.api.gax.batching.BatchingSettings)1 NoCredentialsProvider (com.google.api.gax.core.NoCredentialsProvider)1 GrpcTransportChannel (com.google.api.gax.grpc.GrpcTransportChannel)1 FixedTransportChannelProvider (com.google.api.gax.rpc.FixedTransportChannelProvider)1 TransportChannelProvider (com.google.api.gax.rpc.TransportChannelProvider)1