-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add the hook api #665
Draft
mplsgrant
wants to merge
63
commits into
bitcoin-dev-project:main
Choose a base branch
from
mplsgrant:2024-11-hook-api
base: main
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.
Draft
Add the hook api #665
Conversation
This file contains 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 text disrupts other commands whenever a `plugins` directory is not available.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
3 tasks
Draft
This is an attempt to prevent the namespace test from failing.
And then show the user how to automate their discovery
Sleep a bit to allow simln to process
mplsgrant
force-pushed
the
2024-11-hook-api
branch
from
November 23, 2024 02:36
e4db78a
to
97cad87
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.