-
Notifications
You must be signed in to change notification settings - Fork 2
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
Support quorum options #23
base: master
Are you sure you want to change the base?
Conversation
quorum = options.fetch(:quorum, {}) | ||
|
||
unless quorum.empty? | ||
raise ArgumentError.new("invalid quorum option") unless quorum.keys.select { |key| !quorum_types.include?(key) }.empty? |
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.
Line is too long. [127/80]
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.
A good practice is to create a specific error like InvalidQuorumOption < ArgumentError
Also, if you have to map/select a collection, please use a different variable.
Did you consider to create a Quorum class to handle all the methods around quorum? |
I'll do a review to this PR by the end of the week |
This is an extract of what we are using in a internal project. I agree with you in your comments, but before that, do you agree with the public API?. Is this what you had in mind? (Issue #1) |
@damiancaruso I am sorry this PR is taking so long. About the public API, I had two completely different ideas, one is covered in this PR, the other one is something like this: Post.quorum(w: 4).save
Post.quorum(r: 2).reload I'm not sure right now, I would like to brainstorm about both implementations and API. BTW I don't like to change the |
This adds support for quorum options in
#save
,#delete
,#reload
,::[]
and::exists?
methods.It adds an options hash as a parameter to the methods mentioned above. The quorum should be set with the
:quorum
key.Usage: