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

Allow for multiple IFunctionMetadataProvider implementations #1159

Open
jviau opened this issue Nov 8, 2022 · 2 comments · May be fixed by #2834
Open

Allow for multiple IFunctionMetadataProvider implementations #1159

jviau opened this issue Nov 8, 2022 · 2 comments · May be fixed by #2834

Comments

@jviau
Copy link
Contributor

jviau commented Nov 8, 2022

Overview

To enable extensions to register additional functions which are not captured by the existing methods (scanning for methods with a valid trigger attribute via source gen or msbuild task).

Use Cases

Functions from extensions

Some extensions may want to expose function metadata definitions in their own way. For example, to support class-based orchestrators and activities in Durable Functions, the extension could provide functions metadata which all point to the same implementation which shims to the target class to invoke.

Primary vs Auxiliary

Today we assume there is only 1 instance of IFunctionMetadataProvider. This is both in how we consume it (importing a single instance) and in our setup logic: DefaultFunctionMetadataProvider is only registered if no other instance exists. We will need a solve both of these issues. To accomplish this, we first need to define two types of providers: primary and auxiliary. There should be only ever 1 instance of a primary provider. This provider should be responsible for registering all traditional functions: methods which include the function attribute and a valid trigger. The primary provider should index all assemblies loaded by the application. Auxiliary providers are then everything else: providers which register functions that fall outside of the primary providers scope (see durable example in use cases).

In this design, the DefaultFunctionMetadataProvider is 'primary', and will only register if no other primary provider is present. The source generator provider will also be 'primary'.

Concerns

We need to be careful about breaking changes with this design, as we do not want to regress the fallback behavior of default vs source-gen provider, nor impact any cardinality dependency injection assumptions for this service.

@danielmarbach
Copy link
Contributor

danielmarbach commented Jan 5, 2024

We stumbled over this issue while looking into a problem we are facing. We are generating a function with a source generator that gets triggered with a service bus trigger. Unfortunately, the order of source generator invocations is not deterministic and we are running after the function metadata provider source generator, which causes our function to not be recognized and added to the DirectFunctionExecutor internal dictionary.

Is there are reason the whole metadata gathering is not more composable? For example, why not allow registering multiple providers that are then aggregated by the host automatically to populate the metadata dictionary?

@danielmarbach
Copy link
Contributor

@fabiocav @jviau I have added a spike draft PR for discussion #2183 (review).

@jviau jviau linked a pull request Nov 6, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants