mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
plugin: Add a list of notification topics registered by plugin
We will eventually start emitting and dispatching custom notifications from plugins just like we dispatch internal notifications. In order to get reasonable error messages we need to make sure that the topics plugins are asking for were correctly registered. When doing this we don't really care about whether the plugin that registered the notification is still alive or not (it might have died, but subscribers should stay up and running), so we keep a list of all topics attached to the `struct plugins` which gathers global plugin information.
This commit is contained in:
committed by
Rusty Russell
parent
29155c2fe8
commit
083b41f090
21
tests/plugins/custom_notifications.py
Executable file
21
tests/plugins/custom_notifications.py
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
from pyln.client import Plugin
|
||||
|
||||
|
||||
plugin = Plugin()
|
||||
|
||||
|
||||
@plugin.subscribe("custom")
|
||||
def on_custom_notification(val, plugin, **kwargs):
|
||||
plugin.log("Got a custom notification {}".format(val))
|
||||
|
||||
|
||||
@plugin.method("emit")
|
||||
def emit(plugin):
|
||||
"""Emit a simple string notification to topic "custom"
|
||||
"""
|
||||
plugin.notify("custom", "Hello world")
|
||||
|
||||
|
||||
plugin.add_notification_topic("custom")
|
||||
plugin.run()
|
||||
Reference in New Issue
Block a user