Jb/muxer ruby upgrade#7
Open
skunkworker wants to merge 15 commits into
Open
Conversation
The MRI client is working great for both jruby and mri
film42
reviewed
Jun 3, 2026
| # Create a subscription but reset the pending queue to use a central pending queue. | ||
| # NOTE: This is a potential race condition. Chances of the round-trip message to an | ||
| # existing queue before this queue swap happens seems extremely low, but possible. | ||
| sub.pending_queue = @pending_queue |
Contributor
There was a problem hiding this comment.
I still don't love this, but I think it's probably fine. We could drop msgs here if ruby performs a long and unhealthy GC between these lines. While not probable, it's possible this happens coming out of a maintenance mode when you're not warm (jruby JITs) and requests are thrashing. But, I don't think there's a clean way to plumb, and it's not worth a thread local context hack...
# Example:
def with_pending_queue(pending_queue:)
Thread.current[:pending_queue] = @pending_queue
yield
ensure
Thread.current[:pending_queue] = nil
end
module SomethingHorrible
def initialize
super
@pending_queue = Thread.current[:pending_queue] if Thread.current[:pending_queue].present?
end
end
class NATS::IO::Subscription
prepend SomethingHorrible
end
...
with_pending_queue(pending_queue: @pending_queue)
sub = @nats.subscribe(name, queue: name)
assert sub.pending_queue == @pending_queue
endBut... that's pretty nasty 😬
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Taking over work from #2