-
Notifications
You must be signed in to change notification settings - Fork 7
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
Refactor the add model method. #903
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 just curious about the reasoning for the changes. Also some comments that should be fixed.
internal/jimm/model.go
Outdated
} | ||
|
||
// WithConfig returns a builder with the specified model config. | ||
func (b *modelBuilder) WithConfig(cfg map[string]interface{}) *modelBuilder { | ||
func (b *model) WithConfig(ctx context.Context, cfg map[string]interface{}) 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.
We're not using the ctx in here?
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.
wanted to keep all methods the same by passing in the context in case we want to log anything in them
internal/jimm/model.go
Outdated
return b.modelInfo | ||
} | ||
|
||
func (b *model) withConfigFrom(ctx context.Context, getConfigFunction func(ctx context.Context) (map[string]interface{}, error)) 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.
What is the benefit of this function rather than the approach before? I.e. getting the config in the calling code and then calling withConfig
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.
moving more of the logic into the model struct
17ee58c
to
b38e3f3
Compare
b7ac8aa
to
b545d24
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.
Much better
Description
The what and why - include a summary of the change, describe what it does, and include relevant motivation and context.
Fixes JIRA/GitHub issue number
Engineering checklist
Check only items that apply
Test instructions
Notes for code reviewers