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

Remove adhoc natsconf config generation #39

Closed
wallyqs opened this issue Mar 23, 2018 · 0 comments
Closed

Remove adhoc natsconf config generation #39

wallyqs opened this issue Mar 23, 2018 · 0 comments

Comments

@wallyqs
Copy link
Member

wallyqs commented Mar 23, 2018

In latest release of the server v1.1.0, JSON would be supported for configuring the server: nats-io/nats-server#653
This would mean that can remove the current config generation and just convert to JSON:

func Marshal(conf *ServerConfig) ([]byte, error) {
js, err := json.MarshalIndent(conf, "", " ")
if err != nil {
return nil, err
}
if len(js) < 1 || len(js)-1 <= 1 {
return nil, ErrInvalidConfig
}
// Slice the initial and final brackets from the
// resulting JSON configuration so gnatsd config parsers
// almost treats it as valid config.
js = js[1:]
js = js[:len(js)-1]
// Replacing all commas with line breaks still keeps
// arrays valid and makes the top level configuration
// be able to be parsed as gnatsd config.
result := bytes.Replace(js, []byte(","), []byte("\n"), -1)
return result, nil
}

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

No branches or pull requests

1 participant