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

Storage API Changes (Part 2 - Simplify the Storage user experience) #6749

Merged
merged 9 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/tests/ClientTestBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void ThrowsForSyncCallsInAsyncContext()
{
var client = InstrumentClient(new TestClient());
var exception = Assert.Throws<InvalidOperationException>(() => client.Method(123));
Assert.AreEqual("Async method call expected", exception.Message);
Assert.AreEqual("Async method call expected for Method", exception.Message);
}
}

Expand Down
3 changes: 3 additions & 0 deletions sdk/core/Azure.Core/tests/TestFramework/ClientTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Diagnostics;
using System.Reflection;
using Castle.DynamicProxy;
using NUnit.Framework;
Expand Down Expand Up @@ -32,6 +33,8 @@ public virtual TClient CreateClient<TClient>(params object[] args) where TClient

public virtual TClient InstrumentClient<TClient>(TClient client) where TClient: class
{
Debug.Assert(!client.GetType().Name.EndsWith("Proxy"), $"{nameof(client)} was already instrumented");

if (ClientValidation<TClient>.Validated == false)
{
foreach (var methodInfo in typeof(TClient).GetMethods(BindingFlags.Instance | BindingFlags.Public))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Intercept(IInvocation invocation)
// Check if there is an async alternative to sync call
if (asyncAlternative != null)
{
throw new InvalidOperationException("Async method call expected");
throw new InvalidOperationException($"Async method call expected for {methodName}");
}
else
{
Expand Down
14 changes: 7 additions & 7 deletions sdk/storage/Azure.Storage.Blobs/src/AppendBlobClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Azure.Storage.Blobs.Specialized
/// maximum size of an append blob is therefore slightly more than 195 GB
/// (4 MB X 50,000 blocks).
/// </summary>
public class AppendBlobClient : BlobClient
public class AppendBlobClient : BlobBaseClient
{
/// <summary>
/// <see cref="AppendBlobMaxAppendBlockBytes"/> indicates the maximum
Expand Down Expand Up @@ -546,15 +546,16 @@ private async Task<Response<BlobAppendInfo>> AppendBlockAsync(
{
content = content.WithNoDispose().WithProgress(progressHandler);
var appendAttempt = 0;
return await ReliableOperation.DoAsync(
return await ReliableOperation.DoSyncOrAsync(
async,
reset: () => content.Seek(0, SeekOrigin.Begin),
predicate: e => true,
maximumRetries: Constants.MaxReliabilityRetries,
operation:
async () =>
() =>
{
this.Pipeline.LogTrace($"Append attempt {++appendAttempt}");
return await BlobRestClient.AppendBlob.AppendBlockAsync(
return BlobRestClient.AppendBlob.AppendBlockAsync(
this.Pipeline,
this.Uri,
body: content,
Expand All @@ -568,8 +569,7 @@ private async Task<Response<BlobAppendInfo>> AppendBlockAsync(
ifMatch: accessConditions?.HttpAccessConditions?.IfMatch,
ifNoneMatch: accessConditions?.HttpAccessConditions?.IfNoneMatch,
async: async,
cancellationToken: cancellationToken)
.ConfigureAwait(false);
cancellationToken: cancellationToken);
},
cleanup: () => { })
.ConfigureAwait(false);
Expand Down Expand Up @@ -854,6 +854,6 @@ public static partial class SpecializedBlobExtensions
public static AppendBlobClient GetAppendBlobClient(
this BlobContainerClient client,
string blobName)
=> new AppendBlobClient(client.Uri.AppendToPath(blobName), client._pipeline);
=> new AppendBlobClient(client.Uri.AppendToPath(blobName), client.Pipeline);
}
}
Loading