Beispiel #1
0
        public AzureAtomicWriter(CloudBlobClient storageClient, IDocumentStrategy strategy)
        {
            this._strategy = strategy;
            var folder = strategy.GetEntityBucket <TEntity>();

            this._containerDirectory = storageClient.GetBlobDirectory(folder);
        }
Beispiel #2
0
        public AzureAtomicReader(CloudBlobClient storageClient, IDocumentStrategy strategy)
        {
            this._strategy = strategy;
            var folder = strategy.GetEntityBucket <TEntity>();

            this._containerDirectory = storageClient.GetBlobDirectory(folder);
            this._logger             = NetcoLogger.GetLogger(this.GetType());
            this._ap = ActionPolicyAsync.From((exception =>
            {
                var storageException = exception as StorageException;
                if (storageException == null)
                {
                    return(false);
                }

                switch (storageException.RequestInformation.HttpStatusCode)
                {
                case ( int )HttpStatusCode.InternalServerError:
                case ( int )HttpStatusCode.ServiceUnavailable:
                    return(true);

                default:
                    return(false);
                }
            })).Retry(200, (ex, i) =>
            {
                this._logger.Log().Trace(ex, "Retrying Azure API GET call: {0}/200", i);
                var secondsDelay = 0.2 + 0.1 * _random.Next(-1, 1);                   // randomize wait time
                Task.Delay(TimeSpan.FromSeconds(secondsDelay)).Wait();
            });
        }