-
Notifications
You must be signed in to change notification settings - Fork 116
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
Allow using specific consitency on all methods #165
Conversation
@@ -6,8 +6,9 @@ class Datacenter < Diplomat::RestClient | |||
# Get an array of all avaliable datacenters accessible by the local consul agent | |||
# @param meta [Hash] output structure containing header information about the request (index) |
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.
Comment / Doc shall be updated to take into account the new param
lib/diplomat/datacenter.rb
Outdated
url = ['/v1/catalog/datacenters'] | ||
url << use_consistency(options) if use_consistency(options, nil) |
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.
why use 'if use_consistency' everywhere while it could be integrated into use_consistency (or a wrapper of both...) it's not very conservative if you forget one use_consistency call
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.
Did it in next patch
@@ -256,7 +256,7 @@ def decode_transaction(transaction) # rubocop:disable Metrics/MethodLength | |||
next unless resp['KV']['Value'] | |||
begin | |||
resp['KV']['Value'] = Base64.decode64(resp['KV']['Value']) | |||
rescue # rubocop:disable RescueWithoutErrorClass | |||
rescue StandardError | |||
nil |
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.
May need to add a logging message
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.
FAR if someone wants to do it, I don't change the behaviour here, just fix rubicop since JSON parsing and base64 are StandardError
lib/diplomat/rest_client.rb
Outdated
@@ -17,6 +17,19 @@ def use_named_parameter(name, value) | |||
value ? ["#{name}=#{value}"] : [] | |||
end | |||
|
|||
def use_consistency(options, default_value = []) |
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 don't get the point of having a default value if it's always set to nil, and checked if its value is not nil... Better just remove the if use_consistency(options, nil)
and use the default value
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 was to avoid modifying lib/diplomat/kv.rb, but I did the other way around finally in next patch
lgtm |
DONE by #179 |
This fixes #110