Skip to content

Commit 08ac9bb

Browse files
committed
Updated storageOptions and HttpStorageOptions
1 parent 8784dfa commit 08ac9bb

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
import com.google.api.gax.rpc.HeaderProvider;
2727
import com.google.api.gax.tracing.ApiTracerFactory;
2828
import com.google.auth.Credentials;
29+
import com.google.cloud.storage.Retrying.DefaultRetrier;
30+
import com.google.cloud.storage.Retrying.HttpRetrier;
31+
import com.google.cloud.storage.Retrying.RetryingDependencies;
2932
import com.google.cloud.ServiceFactory;
3033
import com.google.cloud.ServiceRpc;
3134
import com.google.cloud.TransportOptions;
3235
import com.google.cloud.http.HttpTransportOptions;
3336
import com.google.cloud.spi.ServiceRpcFactory;
3437
import com.google.cloud.storage.BlobWriteSessionConfig.WriterFactory;
35-
import com.google.cloud.storage.Retrying.DefaultRetrier;
36-
import com.google.cloud.storage.Retrying.HttpRetrier;
37-
import com.google.cloud.storage.Retrying.RetryingDependencies;
3838
import com.google.cloud.storage.Storage.BlobWriteOption;
3939
import com.google.cloud.storage.TransportCompatibility.Transport;
4040
import com.google.cloud.storage.spi.StorageRpcFactory;
@@ -407,15 +407,7 @@ public Storage create(StorageOptions options) {
407407
blobWriteSessionConfig = HttpStorageOptions.defaults().getDefaultStorageWriterConfig();
408408
}
409409
WriterFactory factory = blobWriteSessionConfig.createFactory(clock);
410-
StorageImpl storage =
411-
new StorageImpl(
412-
httpStorageOptions,
413-
factory,
414-
new HttpRetrier(
415-
new DefaultRetrier(
416-
OtelStorageDecorator.retryContextDecorator(otel),
417-
RetryingDependencies.simple(
418-
options.getClock(), options.getRetrySettings()))));
410+
StorageImpl storage = new StorageImpl(httpStorageOptions, factory, options.createRetrier());
419411
return OtelStorageDecorator.decorate(storage, otel, Transport.HTTP);
420412
} catch (IOException e) {
421413
throw new IllegalStateException(

google-cloud-storage/src/main/java/com/google/cloud/storage/StorageOptions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
import java.util.Locale;
3636
import java.util.Properties;
3737
import org.checkerframework.checker.nullness.qual.NonNull;
38+
import com.google.cloud.storage.Retrying.DefaultRetrier;
39+
import com.google.cloud.storage.Retrying.HttpRetrier;
40+
import com.google.cloud.storage.Retrying.Retrier;
41+
import com.google.cloud.storage.Retrying.RetryingDependencies;
3842

3943
public abstract class StorageOptions extends ServiceOptions<Storage, StorageOptions> {
4044

@@ -68,6 +72,13 @@ public abstract class StorageOptions extends ServiceOptions<Storage, StorageOpti
6872
VERSION = tmp;
6973
}
7074

75+
Retrier createRetrier() {
76+
return new HttpRetrier(
77+
new DefaultRetrier(
78+
OtelStorageDecorator.retryContextDecorator(getOpenTelemetry()),
79+
RetryingDependencies.simple(getClock(), getRetrySettings())));
80+
}
81+
7182
/**
7283
* @deprecated Use {@link HttpStorageFactory}
7384
*/

0 commit comments

Comments
 (0)