quarkus-google-cloud-services icon indicating copy to clipboard operation
quarkus-google-cloud-services copied to clipboard

Adding options to configure the service Storage such as ConnectTimeout and some other configurations

Open fredericBregier opened this issue 2 years ago • 0 comments

In my project, I like to be able to test what is going on if the connection is down with the remote service, such as here the Storage service. However, when I try such a test (with a remote down service, using fake implementation service not started), I figured out that I can wait forever (or very long) before the connection is definitively in error and then getting the error from my code.

I did not find any way to configure for instance the ConnectTimeout.

By creating manually the service, inspired from StorageProducer, I am able to adjust this case. I don't think all are needed, but at least the more important.

TransportOptions transportOptions =
    HttpTransportOptions.newBuilder().setConnectTimeout(100).setReadTimeout(500).build();
GcpBootstrapConfiguration gcpConfiguration = gcpConfigHolder.getBootstrapConfig();
StorageOptions.Builder builder = StorageOptions.newBuilder().setCredentials(googleCredentials)
    .setProjectId(gcpConfiguration.projectId().orElse(null));
storageConfiguration.hostOverride.ifPresent(builder::setHost);
RetrySettings retrySettings = RetrySettings.newBuilder().setInitialRetryDelay(Duration.ofMillis(100))
    .setInitialRpcTimeout(Duration.ofMillis(100)).setLogicalTimeout(Duration.ofMillis(100)).setMaxAttempts(1)
    .setMaxRpcTimeout(Duration.ofMillis(200)).setMaxRetryDelay(Duration.ofMillis(200))
    .setTotalTimeout(Duration.ofMillis(500)).build();
Storage storage =
    builder.setTransportOptions(transportOptions).setRetrySettings(retrySettings).build().getService();

fredericBregier avatar Jan 04 '24 23:01 fredericBregier