Skip to content

add APIs to execution context for middleware support #9

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
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 @@ -6,6 +6,8 @@

package com.microsoft.azure.functions;

import java.lang.reflect.Parameter;
import java.util.Map;
import java.util.logging.Logger;

/**
Expand Down Expand Up @@ -50,5 +52,19 @@ default TraceContext getTraceContext() {
default RetryContext getRetryContext() {
return null;
}

Map<String, Parameter> getParameterMap();

Map<String, String> getParameterPayloadMap();

void setMiddlewareInput(String key, Object value);

Object getReturnValue();

void setMiddlewareOutput(Object value);

void setFunctionInstance(Object functionInstance);

Choose a reason for hiding this comment

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

Might consider moving these middleware specific methods like setFunctionInstance to a separate interface that extends extends ExecutionContext. ExecutionContext is available to the application developer and these methods might not be something you want exposed to them. See my PR here which shows this:

#10

Copy link
Member Author

@kaibocai kaibocai Sep 13, 2022

Choose a reason for hiding this comment

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

Thank you for your valuable suggestion! We will discuss it with the team.


Class<?> getContainingClass();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
package com.microsoft.azure.functions.middleware;

import com.microsoft.azure.functions.ExecutionContext;

public interface FunctionWorkerChain {
void doNext(ExecutionContext context) throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
package com.microsoft.azure.functions.middleware;

import com.microsoft.azure.functions.ExecutionContext;

public interface FunctionWorkerMiddleware {
void invoke(ExecutionContext context, FunctionWorkerChain next) throws Exception;
}