Skip to content

Blueprint interfaces implementation #116

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

Merged
merged 23 commits into from
Jun 21, 2022
Merged

Blueprint interfaces implementation #116

merged 23 commits into from
Jun 21, 2022

Conversation

YunchuWang
Copy link
Member

@YunchuWang YunchuWang commented Apr 11, 2022

Introducing blueprint concepts to new programming model (referenced to flask blueprint)

The benefits of blueprint is:

  • separating functions to different python files
  • providing extensible, module python classes to enable external parties to implement their own function app types.

New public classes blueprint exposes:

  • DecoratorAPI: An abstract class which contains essential decorator function building blocks to extend for creating new function app or blueprint classes.
  • HttpFunctionsAuthLevelMixin: Python class which manages(getting/setting) http authorization level property to the extended classes.
  • TriggerApi: Interface to extend for using existing trigger decorator functions.
  • BindingApi: Interface to extend for using existing binding decorator functions.
  • FunctionRegister: Interface for declaring top level function app class which will be directly indexed by Python Function runtime. There can only be one FunctionRegister instance in a function app.
  • FunctionApp: FunctionApp instance containing all natively supported decorator functions to capture user defined function and corresponding metadata information.
  • Blueprint: Similar to FunctionApp with only difference is BluePrint does not extends FunctionRegister class.
  • ExternalHttpFunctionApp: Interface to extend for building third party http function apps.
  • AsgiFunctionApp: Top level function app class for constructing asgi http functions.
  • WsgiFunctionApp: Top level function app class for constructing wsgi http functions.

image

@codecov
Copy link

codecov bot commented Apr 11, 2022

Codecov Report

Merging #116 (06601f9) into dev (ce3e24f) will increase coverage by 0.11%.
The diff coverage is 98.92%.

@@            Coverage Diff             @@
##              dev     #116      +/-   ##
==========================================
+ Coverage   89.23%   89.35%   +0.11%     
==========================================
  Files          51       51              
  Lines        2946     2959      +13     
  Branches      393      396       +3     
==========================================
+ Hits         2629     2644      +15     
  Misses        241      241              
+ Partials       76       74       -2     
Flag Coverage Δ
unittests 89.32% <98.92%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
azure/functions/decorators/__init__.py 100.00% <ø> (ø)
azure/functions/decorators/function_app.py 99.40% <98.91%> (+0.65%) ⬆️
azure/functions/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce3e24f...06601f9. Read the comment docs.

peterstone2017 added 2 commits April 25, 2022 12:18
@YunchuWang YunchuWang marked this pull request as ready for review April 25, 2022 22:17
@YunchuWang YunchuWang requested a review from gavin-aguiar May 4, 2022 16:02
@YunchuWang YunchuWang changed the title blueprint initial implementation Blueprint interfaces implementation May 9, 2022
@YunchuWang YunchuWang requested a review from gavin-aguiar May 25, 2022 15:33

:return: Decorator function.
def register_functions(self, function_container: DecoratorApi) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

@YunchuWang - As this is only used for registering blueprints, should be call is register_blueprint? or you are using this to register for other other generic cases? We can use pointers to functions and use specific handlers for such cases.

Define a generic _register_functions

def _register_functions(...):
 ...

and then

register_blueprint=_register_functions
register_wsgiapp=_register_functions
...

such that it is easier to understand what the method would actually be used for.

Copy link
Member Author

Choose a reason for hiding this comment

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

it can be used to register custom defined classes extending triggerapi or bindingapi or both. i am thinking aliasing a register_blueprint and keeping register_functions public to register any other types of custom defined function container classes?

**kwargs
) -> Callable:

class FunctionRegister(DecoratorApi, HttpFunctionsAuthLevelMixin, ABC):
Copy link
Member

Choose a reason for hiding this comment

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

So - this would be used by the Worker now?

/cc @gavin-aguiar

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, need to make change on worker to index FunctionRegister instead of functionapp

respond to an event sent to an event grid topic.
All optional fields will be given default value by function host when
they are parsed by function host.
super().__init__(auth_level=http_auth_level)
Copy link
Member

Choose a reason for hiding this comment

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

we have to think for the future - if auth_level is set and no HTTP function is registered - we should give some sort of a warning - just in case. Not for this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

will add a task for this

Copy link
Member

@vrdmr vrdmr left a comment

Choose a reason for hiding this comment

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

LGTM

@YunchuWang YunchuWang merged commit 153a321 into dev Jun 21, 2022
@YunchuWang YunchuWang deleted the wangbill/blueprint branch June 21, 2022 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants