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

Set IncludeEmptyEntriesInMessagePayload capability to true by default #2701

Merged
merged 3 commits into from
Sep 13, 2024
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,29 @@
- My change description (#PR/#issue)
-->

### Microsoft.Azure.Functions.Worker (metapackage) <version>
### Microsoft.Azure.Functions.Worker (metapackage) 2.0.0

- <entry>
- Updating `Microsoft.Azure.Functions.Worker.Core` to 2.0.0
- Updating `Microsoft.Azure.Functions.Worker.Grpc` to 2.0.0

### Microsoft.Azure.Functions.Worker.Core <version>
### Microsoft.Azure.Functions.Worker.Core 2.0.0

- <entry>
- Capability `IncludeEmptyEntriesInMessagePayload` is now enabled by default (#2701)
- This means that empty entries will be included in the function trigger message payload by default.
- To disable this capability and return to the old behaviour, set `IncludeEmptyEntriesInMessagePayload` to `false` in the worker options.

### Microsoft.Azure.Functions.Worker.Grpc <version>
```csharp
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults(builder =>
{
}, options =>
{
options.IncludeEmptyEntriesInMessagePayload = false;
})
.Build();
```

### Microsoft.Azure.Functions.Worker.Grpc 2.0.0

- Removed fallback command line argument reading code for grpc worker startup options. (#1908)

Expand Down
20 changes: 20 additions & 0 deletions src/DotNetWorker.Core/Hosting/WorkerCapabilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

namespace Microsoft.Azure.Functions.Worker
{
internal static class WorkerCapabilities
{
internal const string EnableUserCodeException = "EnableUserCodeException";
internal const string HandlesInvocationCancelMessage = "HandlesInvocationCancelMessage";
internal const string HandlesWorkerTerminateMessage = "HandlesWorkerTerminateMessage";
internal const string HandlesWorkerWarmupMessage = "HandlesWorkerWarmupMessage";
internal const string IncludeEmptyEntriesInMessagePayload = "IncludeEmptyEntriesInMessagePayload";
internal const string RawHttpBodyBytes = "RawHttpBodyBytes";
internal const string RpcHttpBodyOnly = "RpcHttpBodyOnly";
internal const string RpcHttpTriggerMetadataRemoved = "RpcHttpTriggerMetadataRemoved";
internal const string TypedDataCollection = "TypedDataCollection";
internal const string UseNullableValueDictionaryForHttp = "UseNullableValueDictionaryForHttp";
internal const string WorkerStatus = "WorkerStatus";
}
}
11 changes: 6 additions & 5 deletions src/DotNetWorker.Core/Hosting/WorkerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.Azure.Functions.Worker
{
/// <summary>
/// An options class for configuring the worker.
/// </summary>
/// </summary>
public class WorkerOptions
{
/// <summary>
Expand All @@ -30,13 +30,14 @@ public class WorkerOptions
public IDictionary<string, string> Capabilities { get; } = new Dictionary<string, string>()
{
// Enable these by default, although they are not strictly required and can be removed
{ "HandlesWorkerTerminateMessage", bool.TrueString },
{ "HandlesInvocationCancelMessage", bool.TrueString }
{ WorkerCapabilities.HandlesWorkerTerminateMessage, bool.TrueString },
{ WorkerCapabilities.HandlesInvocationCancelMessage, bool.TrueString },
{ WorkerCapabilities.IncludeEmptyEntriesInMessagePayload, bool.TrueString }
};

/// <summary>
/// Gets or sets the flag for opting in to unwrapping user-code-thrown
/// exceptions when they are surfaced to the Host.
/// exceptions when they are surfaced to the Host.
/// </summary>
public bool EnableUserCodeException
{
Expand All @@ -49,7 +50,7 @@ public bool EnableUserCodeException
/// For example, if a set of entries were sent to a messaging service such as Service Bus or Event Hub and your function
/// app has a Service bus trigger or Event hub trigger, only the non-empty entries from the payload will be sent to the
/// function code as trigger data when this setting value is <see langword="false"/>. When it is <see langword="true"/>,
/// All entries will be sent to the function code as it is. Default value for this setting is <see langword="false"/>.
/// all entries will be sent to the function code as it is. Default value for this setting is <see langword="true"/>.
/// </summary>
public bool IncludeEmptyEntriesInMessagePayload
{
Expand Down
12 changes: 6 additions & 6 deletions src/DotNetWorker.Grpc/GrpcWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,12 @@ private static IDictionary<string, string> GetWorkerCapabilities(WorkerOptions w
}

// Add required capabilities; these cannot be modified and will override anything from WorkerOptions
capabilities["RpcHttpBodyOnly"] = bool.TrueString;
capabilities["RawHttpBodyBytes"] = bool.TrueString;
capabilities["RpcHttpTriggerMetadataRemoved"] = bool.TrueString;
capabilities["UseNullableValueDictionaryForHttp"] = bool.TrueString;
capabilities["TypedDataCollection"] = bool.TrueString;
capabilities["WorkerStatus"] = bool.TrueString;
capabilities[WorkerCapabilities.RpcHttpBodyOnly] = bool.TrueString;
capabilities[WorkerCapabilities.RawHttpBodyBytes] = bool.TrueString;
capabilities[WorkerCapabilities.RpcHttpTriggerMetadataRemoved] = bool.TrueString;
capabilities[WorkerCapabilities.UseNullableValueDictionaryForHttp] = bool.TrueString;
capabilities[WorkerCapabilities.TypedDataCollection] = bool.TrueString;
capabilities[WorkerCapabilities.WorkerStatus] = bool.TrueString;

return capabilities;
}
Expand Down
3 changes: 2 additions & 1 deletion test/DotNetWorkerTests/GrpcWorkerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ void AssertKeyAndValue(KeyValuePair<string, string> kvp, string expectedKey, str

Assert.Collection(response.Capabilities.OrderBy(p => p.Key),
c => AssertKeyAndValue(c, "HandlesInvocationCancelMessage", bool.TrueString),
c => AssertKeyAndValue(c, "IncludeEmptyEntriesInMessagePayload", bool.TrueString),
c => AssertKeyAndValue(c, "RawHttpBodyBytes", bool.TrueString),
c => AssertKeyAndValue(c, "RpcHttpBodyOnly", bool.TrueString),
c => AssertKeyAndValue(c, "RpcHttpTriggerMetadataRemoved", bool.TrueString),
Expand Down Expand Up @@ -324,7 +325,7 @@ void ProcessMessage(IMessageProcessor processor, string functionId = null)
});

releaseFunctionEvent.Wait(5000);

Assert.True(releaseFunctionEvent.IsSet,
"Release function was never called. " +
"This indicates the blocking function prevented execution flow.");
Expand Down