Skip to content
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

Closed

Conversation

pierresouchay
Copy link
Member

This fixes #110

@@ -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)

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

url = ['/v1/catalog/datacenters']
url << use_consistency(options) if use_consistency(options, nil)

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

Copy link
Member Author

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
Copy link

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

Copy link
Member Author

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

@@ -17,6 +17,19 @@ def use_named_parameter(name, value)
value ? ["#{name}=#{value}"] : []
end

def use_consistency(options, default_value = [])
Copy link

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

Copy link
Member Author

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

@kamaradclimber
Copy link
Contributor

lgtm

@pierresouchay
Copy link
Member Author

DONE by #179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Needs rebase the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support stale / consistent queries
4 participants