-
Notifications
You must be signed in to change notification settings - Fork 1
fix: Allow non blocking all the way down to the instance level #27
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes blocking behavior in the NATS API server to allow non-blocking operation at the instance level. The changes enable running specs and other tasks without being blocked by worker threads sleeping.
- Adds a
blockingparameter throughout the worker spawn chain to control blocking behavior - Splits worker setup into blocking (
setup_worker!) and non-blocking (setup_worker) variants - Refactors parameter passing to use keyword arguments for better clarity
| return worker.setup_worker!(nats_url: url, service_opts: opts) if blocking | ||
|
|
||
| worker.setup_worker(nats_url: url, service_opts: opts) |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional logic is inverted. When blocking is true, the method calls setup_worker! which blocks with sleep, but then immediately returns, preventing the sleep from executing. This should be unless blocking or the logic should be restructured.
| return worker.setup_worker!(nats_url: url, service_opts: opts) if blocking | |
| worker.setup_worker(nats_url: url, service_opts: opts) | |
| if blocking | |
| worker.setup_worker!(nats_url: url, service_opts: opts) | |
| else | |
| worker.setup_worker(nats_url: url, service_opts: opts) | |
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it got this wrong. Not sure why it thinks the sleep is prevented from executing
| @client = NATS.connect url | ||
| @service = @client.services.add(**opts) | ||
| @client = NATS.connect nats_url | ||
| @service = @client.services.add(build_service_opts(service_opts:)) |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build_service_opts method call uses named parameter syntax but the method definition shows service_opts: parameter. This should be build_service_opts(service_opts: service_opts) for clarity.
| @service = @client.services.add(build_service_opts(service_opts:)) | |
| @service = @client.services.add(build_service_opts(service_opts: service_opts)) |
This allows running specs and any other tasks
that you want to accomplish without being blocked
by worker threads sleeping