-
Notifications
You must be signed in to change notification settings - Fork 12
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
fix: empty stream state on broadcast #129
Conversation
Signed-off-by: Enrique Lacal <enrique.lacal@kaleido.io>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #129 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 79 79
Lines 6473 6476 +3
=========================================
+ Hits 6473 6476 +3 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Enrique Lacal <enrique.lacal@kaleido.io>
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'm not sure that this solution is consistent with the way we have viewed these types of connections throughout our architecture. The "Broadcast" function is expected to be non-blocking and any code should be able to call it regardless of whether any clients are current connected. The Broadcast function specifically is also not intended to be a durable message queue (as opposed to the RoundTrip function), which I think these changes have begun to alter. It is expected that if something is broadcasted (a TX receipt for example) while my client is not connected, if I am interested in that receipt, when I need to query for it when my client connects. I expect to be caught up on batches that I have missed (the durable part of the stream), but broadcasts are a different thing altogether.
pkg/wsserver/wsserver.go
Outdated
// Waiting for a least one connection to start the stream | ||
// before we start broadcasting | ||
// Err always nil per callback function | ||
_ = s.waitStreamConnections(ctx, stream, func(providedState *streamState) error { |
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.
Does waitStreamConnections
block here if nobody is connected?
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.
Yes it does block
Exactly what I thought that is why I left it for the reviewer to decide on which option is best - just ignore that message if no connection are available or wait until a connection is available. You are leaning towards the former but does that mean that "starting" a stream means start listening from now , not from the beginning of the events this stream cares about. If we are fine with that, I am happy to make my original change of just setting the state of stream without any connections on the first broadcast for the stream This will not be true |
Broadcasts are not durable, so if I (as a websocket client) start listening, I only expect to get broadcasts that happen while I'm connected |
Signed-off-by: Enrique Lacal <enrique.lacal@kaleido.io>
That's fine. Broadcasts and batches that go through the RoundTrip are different in this regard. |
Signed-off-by: Enrique Lacal <enrique.lacal@kaleido.io>
Just to clarify we are broadcasting batches as well so batching and delivery methods are completely different and configured independently. Have pushed the simpler change to just populate the stream state |
When a broadcast is attempted and the steam state hasn't been initialise it caused a nil pointer.
Two ways to solve this:
I've gone for the latter one. We perform best-effort delivery for broadcast, so it could be argued to do the former, any thoughts appreciated!