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

Generalized notif stream #826

Merged
merged 3 commits into from
Oct 8, 2024

Conversation

sputn1ck
Copy link
Member

This PR adds a generalized notif stream that replaces specific streams such as the reservations listener.

Copy link
Collaborator

@starius starius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Great work! I like the oneof approach in schema.
Left few suggestions.

notifications/log.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Show resolved Hide resolved
loopd/daemon.go Outdated Show resolved Hide resolved
@sputn1ck sputn1ck force-pushed the generalized_notif_stream branch 3 times, most recently from e8ddc78 to 0bc48d0 Compare September 19, 2024 18:55
Copy link
Collaborator

@starius starius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few suggestions

notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@starius starius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🌴
Final micro-nits

notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
loopd/daemon.go Outdated Show resolved Hide resolved

cancel()
// Wait for a bit before reconnecting.
<-time.After(time.Second * 10)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose this:

select {
case <-time.After(time.Second * 10):
case <-ctx.Done():
}

not to keep this goroutine running for 10 seconds after main context is cancelled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a new timer version up in a bit, which waits 0 seconds on the first try!

notifications/manager.go Show resolved Hide resolved
return notifChan
}

// Run starts the notification manager.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to add to godoc, that it closes readyChan as soon as it makes first successful connection to the stream. Also worth noting, that the function is long-running (not launching a goroutine and returning soon).

@sputn1ck sputn1ck force-pushed the generalized_notif_stream branch 4 times, most recently from 666edcd to 882c010 Compare September 22, 2024 09:23
@sputn1ck sputn1ck marked this pull request as ready for review September 22, 2024 09:23
Copy link
Collaborator

@hieblmi hieblmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @sputn1ck, indeed the oneof approach is nicely extensible. I have only one suggestion to make the Subscribe method more generic for other users of the notification manager.

instantout/reservation/interfaces.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Show resolved Hide resolved
notifications/manager.go Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager.go Outdated Show resolved Hide resolved
@lightninglabs-deploy
Copy link

@sputn1ck, remember to re-request review from reviewers when ready

@sputn1ck sputn1ck force-pushed the generalized_notif_stream branch 7 times, most recently from 562ad20 to 6485de0 Compare October 8, 2024 10:09
@sputn1ck sputn1ck requested a review from bhandras October 8, 2024 10:13
@sputn1ck sputn1ck force-pushed the generalized_notif_stream branch 3 times, most recently from 1f3c9af to ea9f5ab Compare October 8, 2024 11:42
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🥇

notifications/manager.go Outdated Show resolved Hide resolved
notifications/manager_test.go Outdated Show resolved Hide resolved
This commit removes the notification stream from
the reservation manager and replaces it with a
subscriber interface.
This commit adds a generic notification manager
that can be used to subscribe to different types
of notifications.
This commit adds the notification manager to the
loopd daemon.
@sputn1ck sputn1ck merged commit 8bc6b61 into lightninglabs:master Oct 8, 2024
4 checks passed
@sputn1ck sputn1ck deleted the generalized_notif_stream branch October 8, 2024 13:16
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.

5 participants