-
Notifications
You must be signed in to change notification settings - Fork 895
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
pyln: Add command notifications support #4311
Conversation
59d3a5c
to
d12b5bf
Compare
@@ -141,6 +141,24 @@ def set_exception(self, exc: Union[Exception, RpcException]) -> None: | |||
def _write_result(self, result: dict) -> None: | |||
self.plugin._write_locked(result) | |||
|
|||
def notify(self, message: str, level='DEBUG') -> None: | |||
"""Send a notification to the caller. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have this? It's split into the two kinds of notifications we have currently defined though: notify_message and notify_progress.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't see that it's in the Plugin
not the Request
, that's a really weird place for it, if we require access to the request anyway. I'll change Plugin.notify_message
to become a wrapper of Request.notify
and move that code there instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good point. Pretty sure this API is unused, so just move it.
Changelog-Added: pyln-client: Plugin methods can now report progress or status via the `Request.notify` function
Changelog-Added: pyln-client: Added support for command notifications to LightningRpc via the `notify` context-manager.
d12b5bf
to
81a73b5
Compare
Ack 81a73b5 |
Adds command notification support to both the RPC client library as
well as the plugin library. This allows RPC clients to register a
notification callback that gets called for each notification, and
allows plugin methods to report status or progress using the
Request.notify
method.