public SymbolGcsWriter(IOptions <GoogleCloudStorageOptions> options, IStorageClientFactory storageClientFactory, ILogger <SymbolGcsWriter> logger) { _options = options.Value; _storageClientFactory = storageClientFactory ?? throw new ArgumentNullException(nameof(storageClientFactory)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// Create a retry policy with Polly with a exponential back off strategy for retries, with jitter and retrying immediately on the first failure /// </summary> /// <param name="options">Options to configure the data storage component</param> /// <returns>Async retry policy to use</returns> internal static AsyncRetryPolicy CreateRetryPolicy(GoogleCloudStorageOptions options) { var delay = Polly.Contrib.WaitAndRetry.Backoff.DecorrelatedJitterBackoffV2(options.MedianFirstRetryDelay, options.MaxRetries, fastFirst: true); return(Policy .Handle <GoogleApiException>() .WaitAndRetryAsync(delay, OnRetryAsync)); }
public FakeGoogleProvider( FakeGoogleClient fakeClient, ILogger <StorageProvider> logger, IFeatureCollection <IStorageProvider> features = null, IContentAnalyzer contentAnalyzer = null, GoogleCloudStorageOptions <FakeGoogleProvider> options = null) : base(logger, features, contentAnalyzer, options) { _fakeClient = fakeClient; }
public StorageProvider( ILogger <StorageProvider> logger, IFeatureCollection <IStorageProvider> features = null, IContentAnalyzer contentAnalyzer = null, GoogleCloudStorageOptions options = null) { if (features == null) { features = new FeatureCollectionBuilder().Build <IStorageProvider>(); } var googleFeatures = new FeatureCollectionBuilder(); googleFeatures.AddFeature <ICacheControlFeature>(new CacheControlFeature()); googleFeatures.AddFeature <ICreateByPathFeature>(new CreateByPathFeature()); googleFeatures.AddFeature <IRecordCopyFeature>(new RecordCopyFeature()); googleFeatures.AddFeature <ILoggerFeature>(new LoggerFeature()); Features = new CompositeFeatureCollection(features, googleFeatures.Build()); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); ContentAnalyzer = contentAnalyzer; Options = options ?? GoogleCloudStorageOptions.Default; }
/// <summary> /// Creates the bucket in Google if it does not exist /// </summary> /// <param name="client">Google storage client</param> /// <param name="loggerFactory">Reference to the logger factory to create the logger</param> /// <param name="options">Options to configure the storage bus</param> internal static void CreateBucketIfNotExists(StorageClient client, IRebusLoggerFactory loggerFactory, GoogleCloudStorageOptions options) { if (options.AutoCreateBucket) { var log = loggerFactory?.GetLogger <GoogleCloudStorageDataBusStorage>() ?? throw new ArgumentNullException(nameof(loggerFactory)); if (!BucketExists(client, options.BucketName)) { log.Info("Bucket {0} does not exist - will create it now", options.BucketName); CreateBucket(client, options.ProjectId, options.BucketName); } } }