Refactor func metadata to allow multiple sources #2834
Draft
+177
−107
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue describing the changes in this PR
resolves #1159
Pull request checklist
release_notes.md
-- TODOAdditional information
NOTE: Tests are not updated yet. Will invest the effort on that when/if we accept this approach.
This PR refactors function metadata flow to allow for multiple sources. The general idea is now
DefaultFunctionMetadataProvider
is now registered as a primary provider, even with source gen. Source gen sets an internal options value which will change the behavior ofDefaultFunctionMetadataProvider
to skip scanningfunction.metadata
, and only return results fromIFunctionMetadataSource
implementations. Source gen is now one of those sources.Concretely, the changes are:
IFunctionMetadataSource
- a new extensibility contract that is expected to be 0 to N implementations by extensions, customers, etc. This allows for providing custom function metadata which is not the typical[Function(name)]
flow. IE: durable can now give metadata to directly invoke class-based orchestrations and activities.IFunctionMetadataSource
along withIFunctionMetadataProvider
(provider contract no longer used for this type).DefaultFunctionMetadataProvider
is now updated to perform the following:functions.metadata
file.IFunctionMetadataSource
.Benefits
This approach offers a significant benefit of being compatible with newer versions of
DotnetWorker.Core
and old versions ofSdk.Generators
. As in this case, we will still outright replace the implementation ofIFunctionMetadataProvider
with the source-gen implementation. This is a very real scenario customers could get into, and avoiding a subtle behavior regression here is important.Concerns
Is changing the source gen emitted types contract a breaking change?-- addedIFunctionMetadataProvider
back to the emitted type, albeit it is no longer used.WorkerOptions
how we want to go?WorkerOptions.Internal
:InternalWorkerOptions
?)IFunctionsMetadataSource
is decorated withDefaultFunctionMetadataSource
, default provider will skip scanningfunction.metadata
)bool IsDefault
to theIFunctionsMetadataSource
(and switch to an abstract class instead of interface to default this tofalse
).