Skip to content

Conversation

kshyju
Copy link
Member

@kshyju kshyju commented Sep 30, 2022

Fixes #1017

This change is part of a fix for 8499 which has details about what problem this is solving.

Adding a boolean property to WorkerOptions, using which customer can opt-in to get the behavior where empty entries in the message payload are not skipped. We made the host level changes in this PR to support this behavior.

Sample usage.

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults(builder =>
    {
    }, options =>
    {
        options.IncludeEmptyEntriesInPayload = true;
    })
    .Build();

Pull request checklist

  • My changes do not require documentation changes - Docs will be automatically published from type.
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)

Additional information

Additional PR information

response.Capabilities.Add("HandlesWorkerTerminateMessage", bool.TrueString);
response.Capabilities.Add("HandlesInvocationCancelMessage", bool.TrueString);

if (workerOptions.IncludeEmptyEntriesInMessagePayload)
Copy link
Member Author

@kshyju kshyju Sep 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the option is disabled, we just do not send the capability at all (instead of sending with False value. Host code is not checking the value of this entry. It just checks for the existence of this capability key).

https://github.com/Azure/azure-functions-host/blob/ec3c2d1049351870bbf611760520cf1e48075c8f/src/WebJobs.Script.Grpc/MessageExtensions/GrpcMessageConversionExtensions.cs#L328-L331

Copy link
Member

@fabiocav fabiocav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a documentation item tracking public docs updates?

public InputConverterCollection InputConverters { get; } = new InputConverterCollection();

/// <summary>
/// Gets or sets a value that determines if empty entries should be included in the function trigger message payload.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have more details here to make the behavior controlled by the option clearer, perhaps also outline the current behavior?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiocav I tried to elaborate the scenario a bit more in the latest iteration. Could you take a look? Feel free to suggest a better version if we can improve this further. Thank you!

release_notes.md Outdated
-->

- Add new analyzer rules for the source-generated function metadata preview (#1048)
- Bump gRPC dependencies to latest version (#1085)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you removing these because they're not public facing changes?

[Theory]
[InlineData("IncludeEmptyEntriesInMessagePayload", true, "IncludeEmptyEntriesInMessagePayload", true, "True")]
[InlineData("IncludeEmptyEntriesInMessagePayload", false, "IncludeEmptyEntriesInMessagePayload", false)]
public void InitRequest_ReturnsExpectedCapabilitiesBasedOnWorkerOptions(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - could space out the name to make easier to read "InitRequest_ReturnsExpectedCapabilities_BasedOnWorkerOptions"

bool shouldCapabilityPresent,
string expectedCapabilityValue = null)
{
var workerOption = new WorkerOptions();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - var name "workerOptions" ?

@kshyju kshyju force-pushed the shkr/gh-1097-empty-payload-worker-options branch from 80bf0e7 to 9339b23 Compare October 5, 2022 19:16
@kshyju
Copy link
Member Author

kshyju commented Oct 6, 2022

Do we have a documentation item tracking public docs updates?

This public docs page for this type will get updated from the code comments once we merge to main. Do you think we should have a separate docs page for this property ? Let's evaluate whether we need to add details to this page.

@kshyju kshyju force-pushed the shkr/gh-1097-empty-payload-worker-options branch from 9339b23 to 96b8e29 Compare October 10, 2022 22:56
@kshyju
Copy link
Member Author

kshyju commented Oct 10, 2022

/check-enforcer evaluate

@kshyju
Copy link
Member Author

kshyju commented Oct 10, 2022

/check-enforcer reset

brettsam pushed a commit that referenced this pull request Feb 16, 2023
…ty entries in trigger payload (#1091)

* Adding a new worker option property to opt-in the behavior to get empty entries in function trigger payload

* Addressing PR feedback.

* renaming variable name based on PR feedback.

* Rebasing on top of main. Resolved release notes conflict.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worker options to opt-in the behavior to get empty entries in payload

6 participants