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] [WebJobs] Added support for BlobsOptions.MaxDequeueCount #37836

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 5.2.0-beta.1 (Unreleased)

### Features Added
- Added support for `BlobsOptions.MaxDequeueCount`

### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public partial class BlobsOptions : Microsoft.Azure.WebJobs.Hosting.IOptionsForm
{
public BlobsOptions() { }
public int MaxDegreeOfParallelism { get { throw null; } set { } }
public int MaxDequeueCount { get { throw null; } set { } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
string Microsoft.Azure.WebJobs.Hosting.IOptionsFormatter.Format() { throw null; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Http" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ namespace Microsoft.Azure.WebJobs.Host
/// </summary>
public class BlobsOptions : IOptionsFormatter
{
private const int DefaultMaxDequeueCount = 5;

private int _maxDegreeOfParallelism;
private int _maxDequeueCount = DefaultMaxDequeueCount;

/// <summary>
/// Constructs a new instance.
Expand Down Expand Up @@ -43,6 +46,30 @@ public int MaxDegreeOfParallelism
}
}

/// <summary>
/// Gets or sets the number of times to try processing a message before moving it to the poison queue (where
/// possible).
/// </summary>
/// <remarks>
/// Some queues do not have corresponding poison queues, and this property does not apply to them. Specifically,
/// there are no corresponding poison queues for any queue whose name already ends in "-poison" or any queue
/// whose name is already too long to add a "-poison" suffix.
/// </remarks>
public int MaxDequeueCount
{
get { return _maxDequeueCount; }

set
{
if (value < 1)
amnguye marked this conversation as resolved.
Show resolved Hide resolved
{
throw new ArgumentException("MaxDequeueCount must not be less than 1.", nameof(value));
}

_maxDequeueCount = value;
}
}

/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
string IOptionsFormatter.Format()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ internal static QueuesOptions BlobsOptionsToQueuesOptions(BlobsOptions blobsOpti
{
BatchSize = batchSize,
NewBatchThreshold = newBatchThreshold,
MaxDequeueCount = blobsOptions.MaxDequeueCount
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ namespace Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Listeners
{
public class SharedBlobQueueListenerFactoryTests
{
[TestCase(100, 32, 68)]
[TestCase(64, 32, 32)]
[TestCase(63, 32, 31)]
[TestCase(62, 32, 30)]
[TestCase(16, 9, 7)]
[TestCase(3, 2, 1)]
[TestCase(2, 2, 0)]
[TestCase(1, 1, 0)]
public void ConvertsBlobOptionsToQueueOptionsCorrectly(int maxDegreeOfParallelism, int expectedBatchSize, int expectedNewBatchThreshold)
[TestCase(100, 32, 68, 6)]
[TestCase(64, 32, 32, 5)]
[TestCase(63, 32, 31, 4)]
[TestCase(62, 32, 30, 4)]
[TestCase(16, 9, 7, 3)]
[TestCase(3, 2, 1, 1)]
[TestCase(2, 2, 0, 1)]
[TestCase(1, 1, 0, 1)]
public void ConvertsBlobOptionsToQueueOptionsCorrectly(int maxDegreeOfParallelism, int expectedBatchSize, int expectedNewBatchThreshold, int maxDequeueCount)
{
// Arrange
var blobOptions = new BlobsOptions()
{
MaxDegreeOfParallelism = maxDegreeOfParallelism,
MaxDequeueCount = maxDequeueCount,
};

// Act
Expand All @@ -30,6 +31,7 @@ public void ConvertsBlobOptionsToQueueOptionsCorrectly(int maxDegreeOfParallelis
// Assert
Assert.AreEqual(expectedBatchSize, queueOptions.BatchSize);
Assert.AreEqual(expectedNewBatchThreshold, queueOptions.NewBatchThreshold);
Assert.AreEqual(maxDequeueCount, queueOptions.MaxDequeueCount);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public void ConfigureOptions_AppliesValuesCorrectly_Blobs()
var values = new Dictionary<string, string>
{
{ $"{extensionPath}:MaxDegreeOfParallelism", "2" },
{ $"{extensionPath}:MaxDequeueCount", "3" },
};

BlobsOptions options = TestHelpers.GetConfiguredOptions<BlobsOptions>(b =>
Expand All @@ -26,6 +27,7 @@ public void ConfigureOptions_AppliesValuesCorrectly_Blobs()
}, values);

Assert.AreEqual(2, options.MaxDegreeOfParallelism);
Assert.AreEqual(3, options.MaxDequeueCount);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.Azure.WebJobs.Extensions.Storage.Queues.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Http" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" />
</ItemGroup>
<ItemGroup>
Expand Down