Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fredericBregier opened this issue Jan 4, 2024 · 0 comments

Comments

@fredericBregier
Copy link

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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant