Skip to content

[FIXED] Processes config file during embeded server initialization.#7093

Closed
yixianOu wants to merge 1 commit intonats-io:mainfrom
yixianOu:main
Closed

[FIXED] Processes config file during embeded server initialization.#7093
yixianOu wants to merge 1 commit intonats-io:mainfrom
yixianOu:main

Conversation

@yixianOu
Copy link
Copy Markdown
Contributor

Resolves #7092
Edited the NewServer function in the server package , server.go file. Using the ProcessConfigFile method of the Options type, to enable the embeded nats-server to read the config file
Signed-off-by: orician lzjzxOYX201905@gmail.com

Signed-off-by: orician <lzjzxOYX201905@gmail.com>
@yixianOu yixianOu requested a review from a team as a code owner July 22, 2025 18:55
@yixianOu yixianOu changed the title [FUXED] Processes config file during embeded server initialization. [FIXED] Processes config file during embeded server initialization. Jul 23, 2025
func NewServer(opts *Options) (*Server, error) {
if opts.ConfigFile != _EMPTY_ {
opts.ProcessConfigFile(opts.ConfigFile)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it would be surprising if NewServer() changes my passed options like this without some opt-in.

It might be better to add a helper function like NewServerFromConfig(file string) or something like that? Else maybe gate this behaviour on having passed a nil options with clear docs callout about that - but that doesn't seem so nice.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The mentioned issue also uses some other options instead of just the config file.
Why not call opts.ProcessConfigFile(opts.ConfigFile) right before calling NewServer on the options when embedding? (that's the same thing the server already does when combining CLI flags, etc.)

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.

Go client sdk built-in nats-server unable to read configuration file by passing ConfigFile Options.

3 participants