-
Notifications
You must be signed in to change notification settings - Fork 116
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
base: master
Are you sure you want to change the base?
Conversation
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.
LGTM 🎉
Great work! I like the oneof
approach in schema.
Left few suggestions.
e8ddc78
to
0bc48d0
Compare
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.
Few suggestions
0bc48d0
to
506e218
Compare
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.
LGTM 🌴
Final micro-nits
select { | ||
case <-sub.subCtx.Done(): | ||
close(recvChan) | ||
continue |
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.
Should it be break
here? Otherwise we can close recvChan multiple times (panic).
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.
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.
You are right! I confused sub.subCtx with ctx :)
|
||
select { | ||
case <-time.After(10 * time.Second): | ||
return fmt.Errorf("notification manager not ready") |
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.
Is 10 seconds sufficient? If L402 fails and retries, fetchL402
already waits for 10 seconds, so it will crash here by the time of the second attempt. Also in Tor 10 seconds is not enough.
notifications/manager.go
Outdated
|
||
cancel() | ||
// Wait for a bit before reconnecting. | ||
<-time.After(time.Second * 10) |
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.
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.
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.
Have a new timer version up in a bit, which waits 0 seconds on the first try!
return nil | ||
default: | ||
} | ||
|
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.
Nit: I propose to move this code into a new method. Then we can defer cancel()
in that method.
notifications/manager.go
Outdated
return notifChan | ||
} | ||
|
||
// Run starts the notification manager. |
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.
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).
a4152d1
to
d4a3f29
Compare
This commit refactors the proto definitions of the reservation notifications to use a more generic mechanism that can be used for other types of notifications as well.
This commit removes the notification stream from the reservation manager and replaces it with a subscriber interface.
666edcd
to
882c010
Compare
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.
882c010
to
1ce867f
Compare
This PR adds a generalized notif stream that replaces specific streams such as the reservations listener.