-
Notifications
You must be signed in to change notification settings - Fork 11
Di pipeline #10
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
Open
patriot1burke
wants to merge
2
commits into
Azure:kaibocai/dc-middleware
Choose a base branch
from
patriot1burke:di-pipeline
base: kaibocai/dc-middleware
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Di pipeline #10
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/microsoft/azure/functions/middleware/MiddlewareExecutionContext.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.microsoft.azure.functions.middleware; | ||
|
||
import com.microsoft.azure.functions.ExecutionContext; | ||
|
||
/** | ||
* Expands {@link ExecutionContext} so that {@link FunctionWorkerMiddleware} implementations | ||
* can modify target function instance or get more information about the target function. | ||
*/ | ||
public interface MiddlewareExecutionContext extends ExecutionContext { | ||
public ClassLoader getFunctionClassLoader(); | ||
public Class getFunctionClass(); | ||
|
||
public Object getFunctionInstance(); | ||
|
||
/** | ||
* Allows middleware to override target function instance for this invocation. | ||
* The default behavior is for the instance to be creatd by the Azure Functions runtime. | ||
* | ||
* @param obj | ||
*/ | ||
public void setFunctionInstance(Object obj); | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Quarkus, we don't need
getFunctionClassLoader
andgetFunctionInstance
right. Please correct me if I am wrong.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getFunctionClassLoader() is removable so long as getFunctionClass().getClassLoader() returns the correct loader.
getFunctionInstance() you'd want to have to see if another middleware has overriden the instance already and proxy that instance, output a warning, or abort. An alternative to that is for setFunctionInstance() to throw an exception if the instance has already been set. What do you think is the best approach?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense, I was just wondering if we would have such a use case. The only middleware that require access to FunctionInstance will be DI framework like Quarkus or Spring, etc. But cx will not use both Quarkus and Spring at the same time.
However, I can see this is valid point. I will explore this more from our side.
Personally, I prefer second direction has setFunctionInstance() do the check and throw the exception if this case happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
middleware would be pulled in via a maven dependency. So, if an app developer accidently pulled in both a Quarkus and Spring middleware dependency by accident (or on purpose) you could have conflict. These sort of dependency conflicts are more common than you think based on my experience.
Not that important though. Just something to think about.