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

Skip deferred binding for CosmosDB trigger #9027

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,15 @@ protected override async Task<Collection<ParameterDescriptor>> GetFunctionParame
{
var bindings = inputBindings.Union(outputBindings);

// If an input or output binding uses expressions, we do not want to use ParameterBindingData for the trigger bindings
if (triggerMetadata.SupportsDeferredBinding())
{
bool skipDeferredBinding = BindingAttributeContainsExpression(bindings);
if (skipDeferredBinding)
// If an input or output binding uses expressions, we do not want to use ParameterBindingData for the trigger bindings
bool containsExpression = BindingAttributeContainsExpression(bindings);

// If the trigger is a CosmosDBTrigger, we do not want to use ParameterBindingData as it is not supported
bool isCosmosTrigger = IsCosmosDBTrigger(triggerMetadata);
Copy link
Contributor

@jviau jviau Jan 11, 2023

Choose a reason for hiding this comment

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

It doesn't feel right to me to insert single extension specific logic into this core layer. Can this be pulled into a formal extensibility behavior? Can we delegate the supported decision to the BindingMetadata itself, and extenders can control it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup agree, was trying to have a quick patch in place for if we release Cosmos soon.

However, I did sync with Fabio about this today and since Cosmos is not in any rush to be released we can focus on refactoring the supportsDeferredBinding attribute for extensions and the function metadata generator on the worker to have more granular information about what bindings support deferred binding rather than the blanket "all or nothing" approach we have in place today.

As a result, I'll abandon this PR and create an issue for the refactor work that needs to happen in the worker


if (containsExpression || isCosmosTrigger)
{
triggerMetadata.Properties.Add(ScriptConstants.SkipDeferredBindingKey, true);
}
Expand Down Expand Up @@ -135,5 +139,10 @@ internal bool BindingAttributeContainsExpression(IEnumerable<FunctionBinding> bi

return false;
}

internal bool IsCosmosDBTrigger(BindingMetadata triggerMetadata)
{
return triggerMetadata.Type == "cosmosDBTrigger" ? true : false;
}
}
}