Skip to content
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

Merged
merged 3 commits into from
Jan 7, 2021

Conversation

cdecker
Copy link
Member

@cdecker cdecker commented Jan 5, 2021

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.

@@ -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.
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

@rustyrussell rustyrussell Jan 7, 2021

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.

@cdecker cdecker added this to the v0.9.3 milestone Jan 6, 2021
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.
@rustyrussell
Copy link
Contributor

Ack 81a73b5

@cdecker cdecker merged commit 70410b8 into ElementsProject:master Jan 7, 2021
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.

2 participants