GoogleCloudPlatform / spring-cloud-gcp

New home for Spring Cloud GCP development starting with version 2.0.
Apache License 2.0
423 stars 315 forks source link

Option to add Storage Options through the config instead of having to create a custom Storage Bean #3093

Open a1shadows opened 3 months ago

a1shadows commented 3 months ago

Is your feature request related to a problem? Please describe. Currently in order to customize the Storage Bean for things like retries and timeouts, the only way seems to be to initialize a custom bean like so

@Bean
    public Storage storage() {
        RetrySettings retrySettings = RetrySettings.newBuilder()
                .setInitialRetryDelay(Duration.parse(initialRetryDelay))
                .setRetryDelayMultiplier(retryDelayMultiplier)
                .setMaxRetryDelay(Duration.parse(maxRetryDelay))
                .setMaxAttempts(maxAttempts)
                .setTotalTimeout(Duration.parse(totalTimeout))
                .build();

        return StorageOptions.newBuilder()
                .setRetrySettings(retrySettings)
                .build()
                .getService();
    }

Describe the solution you'd like It would be super convenient to have the ability to provide these configurations in the application.properties file itself to be picked up during auto-configuration of the bean. For eg.

gcp:
  storage:
    retry:
      initial-retry-delay: 1s
      retry-delay-multiplier: 2.0
      max-retry-delay: 10s
      max-attempts: 5
      total-timeout: 1m
a1shadows commented 3 months ago

I would love to help implement something like this