Skip to content
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

[dbnode] [coordinator] Refactor config to use defaults wherever possible #2839

Merged
merged 27 commits into from
Nov 7, 2020

Conversation

robskillington
Copy link
Collaborator

@robskillington robskillington commented Nov 5, 2020

Making all the possible breaking changes for cleanup as possible.

@@ -76,25 +100,25 @@ type DBConfiguration struct {
Transforms TransformConfiguration `yaml:"transforms"`

// Logging configuration.
Logging xlog.Configuration `yaml:"logging"`
Logging *xlog.Configuration `yaml:"logging"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on avoiding pointers in config where it makes sense? e.g., len(str) and *string == nil are effectively equivalent checks, same with struct equivalence (against a zero value), with the benefit of not introducing another zero-like state that needs to be validated as well.

What do you think?

Copy link
Collaborator Author

@robskillington robskillington Nov 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it's much harder to check if zero struct or not, since sometimes defaults means it should be created into a new default, but other times it's semi valid to have a zero struct. This has burnt us a few times.

Opting to go with the canonical way we do this elsewhere, make it pointer type and adding an accessor "FooOrDefault" was the way we wanted to standardize on unless we have other suggestions that works in pretty much every case we want to cover?

Also need to sometimes return an error, so probably should also standardize on it if needing error return an error as second arg.

// We use this method to validate fields where the validator package falls short.
func (c *DBConfiguration) InitDefaultsAndValidate() error {
// LoggingOrDefault returns the logging configuration or defaults.
func (c *DBConfiguration) LoggingOrDefault() xlog.Configuration {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just go with Logging() and have it default if not set as you have it written? Not sure XOrDefault() provides a ton of informational value.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since DBConfiguration already has the field of the same name Logging we have to have some different name (can't have both field and method name the same), and so XOrDefault seems to be the best option for these cases (as opposed to something like GetLogging())

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's mainly because of the name collision we can't make it the same.

@@ -58,6 +58,9 @@ type LimitsConfiguration struct {
// load on the CPU, which can prevent other DB operations.
// A setting of 0 means there is no maximum.
MaxEncodersPerBlock int `yaml:"maxEncodersPerBlock" validate:"min=0"`

// Write new series limit per second to limit overwhelming during new ID bursts.
WriteNewSeriesPerSecond int `yaml:"writeNewSeriesPerSecond" validate:"min=0"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This isn't referenced anywhere in this diff, is this relevant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This got moved since we had a comment // TODO move v1.

@codecov
Copy link

codecov bot commented Nov 6, 2020

Codecov Report

Merging #2839 into master will increase coverage by 1.4%.
The diff coverage is 54.8%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #2839     +/-   ##
========================================
+ Coverage    70.6%   72.0%   +1.4%     
========================================
  Files        1099    1100      +1     
  Lines      100193   99828    -365     
========================================
+ Hits        70789   71965   +1176     
+ Misses      24446   22918   -1528     
+ Partials     4958    4945     -13     
Flag Coverage Δ
aggregator 75.8% <ø> (-0.1%) ⬇️
cluster 84.9% <ø> (ø)
collector 84.3% <ø> (ø)
dbnode 79.2% <62.5%> (+3.5%) ⬆️
m3em 74.4% <ø> (ø)
m3ninx 73.1% <ø> (ø)
metrics 17.2% <ø> (ø)
msg 74.0% <ø> (ø)
query 68.9% <20.0%> (-0.1%) ⬇️
x 80.1% <ø> (-0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a3dff43...4df8a78. Read the comment docs.

@robskillington
Copy link
Collaborator Author

LGTM, TY @rallen090 !

@robskillington robskillington merged commit c7392e1 into master Nov 7, 2020
@robskillington robskillington deleted the refactor-config-use-defaults-wherever-possible branch November 7, 2020 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants