-
Notifications
You must be signed in to change notification settings - Fork 911
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
Notification support #4046
Notification support #4046
Conversation
e99fe31
to
af22c25
Compare
I really like the idea of using notifications in order to update the caller on what's going on. From what I can see this is notifying using the My only concern is that it might break clients that do not expect notifications to be interleaved with the response they are waiting for, and there is no way to opt into receiving the notifications as it stands right now. There is absolutely no requirement for the notified party to have subscribed before receiving notificactions in the JSON-RPC 2.0 spec, but it'd be better I think. The problem is how to do that, and all mechanisms I can come up with either
The only way I can think of making this easy is by adding fields to the JSON-RPC object itself, along with Long story short: I like the idea, and implementation, would want a better opt-in mechanism, but can't come up with one myself... 😉 |
Agreed. We could have a This may combine well with using logging levels: I think this makes sense in general as we get more sophisticated. For example, I can see myself wanting Will rework along these lines? |
af22c25
to
8c31c38
Compare
OK, this is the Final Form (rebased on top of #4086 ). The only remaining question is nomenclature: should we refer to these as "updates" instead of "notifications"? |
8c31c38
to
7e1b089
Compare
concept ack especially now that it is opt-in, I have the same concern as @cdecker regarding existing clients not expecting notifications they have not subscribed to on the RPC interface. |
Trivial rebase. |
19989f0
to
a067173
Compare
a067173
to
8b14f81
Compare
Rebased on top of Still has a
I'd love to see this merged soon @rustyrussell :-) |
Yeah, those tests just delivered a canned reponse; in this case, it filled the buffer. Fixed them to disable notifications. |
Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
And make caller of json_stream_forward_change_id use it, since we're going to reuse that. Also call json_out_finished here, so next object doesn't have a "," prepended. Signed-off-by: Rusty Russell <[email protected]>
This lets callers enable notifications; we won't send any if they don't. Signed-off-by: Rusty Russell <[email protected]> Changelog-Added: JSON-RPC: `notifications` command to enable notifications.
Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]> Changelog-Added: libplugin: routines to send notification updates and progress.
Signed-off-by: Rusty Russell <[email protected]>
We also sanity check that response id matches our request. Signed-off-by: Rusty Russell <[email protected]> Changelog-Added: pyln: pyln.client handles and can send progress notifications.
This can be suppressed with -N. Note that we wull get an error with older lightningd, but we ignore it anyway. Signed-off-by: Rusty Russell <[email protected]> Changelog-Added: cli: print notifications and progress bars if commands provide them.
Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
For compatibility, we only do this if `allow-deprecated-apis` is false for now. Otherwise scripts parsing should use `grep -v '^# '` or start using `-N none`. Changelog-Added: JSON-RPC: `close` now sends notifications for slow closes (if `allow-deprecated-apis`=false) Changelog-Deprecated: cli: scripts should filter out '^# ' or use `-N none`, as commands will start returning notifications soon Fixes: ElementsProject#3925 Signed-off-by: Rusty Russell <[email protected]>
8b14f81
to
127b1a1
Compare
Trivial rebase to fix conflict, valgrind fixes, and folded cdecker fix. |
This is my attempt to answer #3925. Commands should be able to feed notifications back concerning command progress; to do so, we use notifications (JSON requests without an
id
). Plugins can feed them back to the correct sender by puttingid
in the params.Obviously, this needs discussion and documentation, but this shows what an implementation might look like.
@shesek might have particular opinions on this kind of API!