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

*: fix invalid key in example cfg file and support log_level from cfg file #1330

Merged
merged 2 commits into from
Mar 29, 2021
Merged

*: fix invalid key in example cfg file and support log_level from cfg file #1330

merged 2 commits into from
Mar 29, 2021

Conversation

edoger
Copy link
Contributor

@edoger edoger commented Mar 18, 2021

No description provided.

@edoger
Copy link
Contributor Author

edoger commented Mar 18, 2021

After verification, the configuration of the log level "log-level" in the configuration file does not take effect. This is because the third-party library (github.com/mreiferson/go-options) can only recognize the "log_level". This patch fixes the configuration file Use "log_level" to set the log level. For "log-level", the old application behavior is still maintained.

@edoger edoger changed the title Fix invalid key in example cfg file. Fix invalid key in example cfg file and support to set the log level from the cfg file. Mar 18, 2021
@mreiferson mreiferson changed the title Fix invalid key in example cfg file and support to set the log level from the cfg file. *: fix invalid key in example cfg file and support log_level from cfg file Mar 22, 2021
@mreiferson mreiferson added the bug label Mar 22, 2021
Copy link
Member

@mreiferson mreiferson left a comment

Choose a reason for hiding this comment

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

Thanks for this comprehensive PR @edoger, a few changes if you don't mind!

@@ -59,3 +62,23 @@ func NewOptions() *Options {
AdminUsers: []string{},
}
}

func (opts *Options) Resolve(flagSet *flag.FlagSet, cfg map[string]interface{}) error {
Copy link
Member

Choose a reason for hiding this comment

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

We already have a way to coerce config data into appropriate option types, see:

https://github.com/nsqio/nsq/blob/master/apps/nsqd/options.go#L69

So we don't actually need this new method for any of the binaries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mreiferson Do we need to migrate the Validate method to Resolve? Because nsqadmin and nsqlookupd have no corresponding validate methods.

Copy link
Member

Choose a reason for hiding this comment

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

No, I think each binary should have a config file validation method rather than moving that responsibility into the package / options.

@@ -64,7 +63,9 @@ func (p *program) Start() error {
}
cfg.Validate()

options.Resolve(opts, flagSet, cfg)
if err := opts.Resolve(flagSet, cfg); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This can be reverted as well after addressing my previous comment. For better or worse, options.Resolve fatally exits on errors.

@edoger
Copy link
Contributor Author

edoger commented Mar 23, 2021

@mreiferson Done! The test failure doesn't seem to be caused by the code?

@mreiferson
Copy link
Member

Changes look great, tests are failing due to go fmt issues. Would you mind fixing those and squashing this down to logical commits?

@edoger
Copy link
Contributor Author

edoger commented Mar 29, 2021

@mreiferson Done! The code style has been fixed and everything looks good. Since the logFatal function cannot be unit tested, the decrease in test coverage is an inevitable result.

@mreiferson mreiferson merged commit 74f0dca into nsqio:master Mar 29, 2021
@edoger edoger deleted the fix-example-cfg-files branch April 2, 2021 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants