-
Notifications
You must be signed in to change notification settings - Fork 533
RUBY-932 Update Server Discovery and Monitoring code and tests #637
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
RUBY-932 Update Server Discovery and Monitoring code and tests #637
Conversation
28b3a14
to
24e87cb
Compare
# @return [ true, false ] If the description is from the server. | ||
# | ||
# @since 2.0.6 | ||
def self?(server) |
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 might change this name to something else, given that self
is reserved in Ruby and this might be a bit confusing.
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.
Changed it to Description#me?(server)
24e87cb
to
58def90
Compare
👍 |
@servers = [] | ||
@servers_update = Mutex.new |
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'd just put one big lock around Cluster and do all non-I/O operations (both reads and updates to all data structures) while holding the lock. If you do I/O, drop the lock, do your operation without touching any Cluster data structures, then reacquire the lock in order to update your data structures according to what you discovered from doing the I/O. So, no need to distinguish between these two mutexes, just lock the whole Cluster whenever you touch it.
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.
Thanks for your review.
I'm not going to take this approach because there is IO in a bunch of places that might not be obvious (like in the instantiation of an Address, for example) and the code would get messy if I was frequently grabbing and releasing the lock in between lines of code in Cluster.
I have taken your suggestion to only use one lock for both the servers and addresses list.
You're also right about having to copy the list. I've added that in as well.
Thanks again!
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.
Glad I could help!
On Thu, Jun 18, 2015 at 9:43 AM, Emily [email protected] wrote:
In lib/mongo/cluster.rb
#637 (comment)
:@servers = []
@servers_update = Mutex.new
Thanks for your review.
I'm not going to take this approach because there is IO in a bunch of
places that might not be obvious (like in the instantiation of an Address,
for example) and the code would get messy if I was frequently grabbing and
releasing the lock in between lines of code in Cluster.I have taken your suggestion to only use one lock for both the servers and
addresses list.You're also right about having to copy the list. I've added that in as
well.Thanks again!
—
Reply to this email directly or view it on GitHub
https://github.com/mongodb/mongo-ruby-driver/pull/637/files#r32730474.
d633fae
to
3f72d31
Compare
RUBY-932 Update Server Discovery and Monitoring code and tests
No description provided.