Open mplsgrant opened 2 weeks ago
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Overview
This hooks system is intended to allow the user to extend Warnet with python code plugins which will have hooks into key points in the Warnet workflow.
For the user
This hooks API lets users write plugins that look like this:
The various decorators available to users can be found in the hooks_api.py file which is also found in the
plugins
directory.To get a
plugins
directory, simply runwarnet init
, and warnet will generate one for you.For the Warnet developers
This new hooks system lets us decorate our internal Warnet functions with
@api
like this:Doing so causes Warnet to produce the corresponding
hooks_api.py
file when the user runswarnet init
Feedback
I am looking for feedback on this approach. Earlier I had considered authoring an abstract class/interface. After implementing the hooks system using decorators, I noticed that it became much easier to get new API endpoints.