-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Use variadic function to pass parameters instead of Config struct #454
Conversation
Using function to pass optional params makes the API more consistent with the rest of go-kit packages. For go-kit#427
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.
Yep, I'm basically into it. On review I think it's OK that the functional option operates on an unexported struct. Just a couple of tiny things to look at. Thanks so much for the effort!
// will be squelched, and ErrNotAllowed returned. | ||
Allowed []string | ||
// New wraps the logger and implements level checking. See the commentary on the | ||
// Option functions for a detailed description of how to configure levels. |
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.
Would you mind adding an extra sentence of commentary describing the default behavior with no options set?
level.Allowed(level.AllowWarnAndAbove()), | ||
level.ErrNotAllowed(myError), | ||
} | ||
logger := level.New(log.NewNopLogger(), opts...) |
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.
Any reason not to inline these? I'm not fussed, just curious.
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.
No specific reason. I usually prefer to create a slice when I have multiple options because it looks more organized, especially if there's a chance the list of options will grow in the future.
I'd be glad to change it if you have the opposite preference.
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.
Cool! No worries.
Brilliant, thanks for the contribution! |
Using function to pass optional params makes the API more consistent
with the rest of go-kit packages.
For #427
Following up on discussion in #427 (comment)
I thought it was important to get this change in before #449 and ultimately 1.0.0 to avoid making breaking changes in a stable API.