-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[jaeger-v2] Streamline storage initialization #5171
Conversation
Signed-off-by: Yuri Shkuro <github@ysh.us>
ext: s, | ||
storageKind: "memory", | ||
cfg: s.config.Memory, | ||
// memory factory does not return an error, so need to wrap it |
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 not change memory.NewFactoryWithConfig
to return the error? It doesn't look like it's used anywhere else, so it shouldn't be a large breaking change.
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.
Because I hate functions that are declared with errors but always return nil. The caller either has to ignore the error, or it has no easy way of unit testing the error handing path (which will never be used). Lose-lose. I think if the function can never return an error it should never declare it as a possibility (unless you're dealing with an interface where there's no choice).
for name, b := range s.config.Badger { | ||
if _, ok := s.factories[name]; ok { | ||
return fmt.Errorf("duplicate badger storage name %s", name) | ||
func (s *starter[Config, Factory]) build(ctx context.Context, host component.Host) 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.
Internal state isn't persisted between method calls so all methods are effectively read-only; we could assert this by using value receivers instead of pointer receivers.
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.
true, but makes no difference in this context since the code runs exactly once. Don't want to reset the approval just for this fix :-)
Which problem is this PR solving?
Description of the changes
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:yarn lint
andyarn test