ExtensionMeta Class
The metaclass handles extension registration.
AppExtension is registered in init, it is applied to all triggers. FuncExtension is registered in call, as users need to instantiate it inside hook script.
After registration, the extension class will be flatten into the following structure to speed up worker lookup:
_func_exts[<trigger_name>].<hook_name>.(ext_name, ext_impl) (e.g. _func_exts['HttpTrigger'].pre_invocation.ext_impl)
_app_exts.<hook_name>.(ext_name, ext_impl) (e.g. _app_exts.pre_invocation_app_level.ext_impl)
The extension tree information is stored in _info for diagnostic purpose. The dictionary is serializable to json:
_info['FuncExtension']['<Trigger>'] = list(<Extension>) _info['AppExtension'] = list(<Extension>)
Executes on 'import extension', once the AppExtension class is loaded, call the setup() method and add the life-cycle hooks into _app_exts.
Constructor
ExtensionMeta(name, bases, namespace, /, **kwargs)
Methods
| get_application_hooks |
Return all application hooks |
| get_function_hooks |
Return all function extension hooks indexed by trigger name. |
| get_registered_extensions_json |
Return a json string of the registered |
| mro |
Return a type's method resolution order. |
| register |
Register a virtual subclass of an ABC. Returns the subclass, to allow usage as a class decorator. |
get_application_hooks
Return all application hooks
get_application_hooks() -> AppExtensionHooks | None
Returns
| Type | Description |
|---|---|
|
Example to look up a certain life-cycle name: get_application_hooks().pre_invocation_app_level.ext_name |
get_function_hooks
Return all function extension hooks indexed by trigger name.
get_function_hooks(name: str) -> FuncExtensionHooks | None
Parameters
| Name | Description |
|---|---|
|
name
Required
|
|
Returns
| Type | Description |
|---|---|
|
Example to look up a certain life-cycle name: get_function_hooks('HttpTrigger').pre_invocation.ext_name |
get_registered_extensions_json
Return a json string of the registered
get_registered_extensions_json() -> str
Returns
| Type | Description |
|---|---|
|
The json string will be constructed in a structure of { "FuncExtension": { "<TriggerA>": [ "ExtensionName"
}, "AppExtension": [
] } |
mro
Return a type's method resolution order.
mro()
register
Register a virtual subclass of an ABC.
Returns the subclass, to allow usage as a class decorator.
register(subclass)
Parameters
| Name | Description |
|---|---|
|
subclass
Required
|
|