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

server.Start() documentation indicates method blocks, however, it does not #4110

Closed
lheiskan opened this issue Apr 27, 2023 · 1 comment · Fixed by #4111
Closed

server.Start() documentation indicates method blocks, however, it does not #4110

lheiskan opened this issue Apr 27, 2023 · 1 comment · Fixed by #4111

Comments

@lheiskan
Copy link

Hey,

server.Start() method documentation seems a bit misleading. Documentation indicates that calling the method would block, and thus should be called in a go proc. However, it seems that the current implementation does not block, and the common pattern is to call server.WaitForShutdown() to block|wait for the server to exit.

This is something that one runs into when trying to embed NATS server. Pretty trivial to figure out how to call the method, however, would be even faster if docs were better.

Current docs in server/server.go

// Start up the server, this will block.
// Start via a Go routine if needed.
func (s *Server) Start() {
  s.Noticef("Starting nats-server")
...

Something like this might be better

// Start up the server, this will not block.
//
// WaitForShutdown can be used to block and wait for the server to shutdown if needed.
func (s *Server) Start() {
 s.Noticef("Starting nats-server")

  ...
@derekcollison
Copy link
Member

This was historically true but agree has changed.

Will update.

derekcollison added a commit that referenced this issue Apr 27, 2023
…ests and function comment.

Fix for #4110

Signed-off-by: Derek Collison <derek@nats.io>
derekcollison added a commit that referenced this issue Apr 27, 2023
This updates tests and the function comment.

Signed-off-by: Derek Collison <derek@nats.io>

Resolves #4110
ReubenMathew pushed a commit to ReubenMathew/nats-server that referenced this issue May 30, 2023
…ests and function comment.

Fix for nats-io#4110

Signed-off-by: Derek Collison <derek@nats.io>
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 a pull request may close this issue.

2 participants