-
Notifications
You must be signed in to change notification settings - Fork 120
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
chore: skip publishing the last empty struct when generator stops #2327
Conversation
…ation Signed-off-by: Keran Yang <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2327 +/- ##
==========================================
- Coverage 67.09% 67.08% -0.02%
==========================================
Files 351 351
Lines 45269 45272 +3
==========================================
- Hits 30375 30372 -3
- Misses 13825 13829 +4
- Partials 1069 1071 +2 ☔ View full report in Codecov by Sentry. |
pkg/sources/generator/tickgen.go
Outdated
// when the channel is closed and empty, go will still read from the channel once and return the zero value. | ||
// exclude the zero value from being passed to the next vertex, | ||
// ensuring all messages produced by generator follow the same data schema. | ||
if util.IsZeroStruct(r) { |
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.
Why is it zerostruct
?
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.
Thanks! I updated the PR description and addressed the comment. Don't need the isZero check, just use the second parameter should work.
Signed-off-by: Keran Yang <[email protected]>
pkg/sources/generator/tickgen.go
Outdated
// ensuring all messages produced by generator follow the same data schema. | ||
if !ok { | ||
mg.logger.Info("Zero value read from the generator channel, skipping...") | ||
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.
In this case, shall we return instead of continue?
Signed-off-by: Keran Yang <[email protected]>
closes #2285
There is race condition when we terminate the generator vertex. The message channel can be closed followed by a read from the channel. Reading from a closed channel will return the zero value of the struct, resulting in an empty message being sent to the next vertex. This change prevent it from being sent so that we have a consistent data structure for downstream vertices.