-
Notifications
You must be signed in to change notification settings - Fork 150
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
Use read_lock #129
Use read_lock #129
Conversation
1 similar comment
It's no use to use write lock here since these methods only read the value. Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Technically, yes. From my point of view, this makes the code a bit more complicated, and the locking a bit harder to reason about. And the only advantage, if I understand correctly, would be if there were two threads reading values simultaneously, which would be a quite unusual use case. |
I don't think so. For example puma. it supports multi-threads server. and this repository supports rack interface, right? it means prometheus/client_ruby runs on puma. But if you think this code makes the code complicated, feel free to close this PR 👍 |
Hi @ganmacs! Just a little update to say I haven't forgotten about this, and i'm planning to look into it today or tomorrow. |
@@ -16,4 +16,16 @@ | |||
metric_settings: { some_setting: true }) | |||
end.to raise_error(Prometheus::Client::DataStores::Synchronized::InvalidStoreSettingsError) | |||
end | |||
|
|||
it '#set an #get' do |
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.
it '#set an #get' do | |
it '#set and #get' do |
Ok, having looked into this a bit more... This is an awesome bit of information, as I had added the What do you think?
To clarify this comment, which was not very well worded... While we do explicitly support multi-threaded scenarios, my expectation when using the client is that values are very frequently incremented, but very rarely read. So, what I should've said is "The only advantage is when reading single values from multiple threads, and I expect reading single values would be a quite unusual case." |
Looks good to me. I'll close this PR. Thank you! |
It's no use to use write lock here since these methods only read the value.