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

Setting bucket properties is goofy #148

Merged
merged 25 commits into from Feb 5, 2015
Merged

Conversation

bkerley
Copy link
Contributor

@bkerley bkerley commented Jan 14, 2015

Developers want to do this:

bucket.props['precommit'].push({ 'mod' => 'validate_json', 'fun' => 'validate' })

What happens is this fetches the props hash from Riak, and then mutates that has in place. At no time is it saved to Riak.

Doing this should save it:

bucket.props['precommit'].push({ :mod => 'validate_json', :fun => 'validate' })
bucket.props = {}

But it's terribly unintuitive.

@bkerley bkerley added this to the 2.1.0 milestone Apr 16, 2014
@bkerley
Copy link
Contributor Author

bkerley commented Jan 6, 2015

    it 'works like a hash' do
      expect(props['r']).to eq 'quorum'
      expect{ props['r'] = 1 }.to_not raise_error
      expect{  props.store }.to_not raise_error
      props.reload
      expect(props['r']).to eq 1
    end

    it 'works like with accessor methods' do
      expect(props.r).to eq 'quorum'
      expect{ props.r = 1 }.to_not raise_error
      expect{ props.store }.to_not raise_error
      props.reload
      expect(props.r).to eq 1
    end

@bkerley
Copy link
Contributor Author

bkerley commented Jan 14, 2015

TODO: test it with composite/hash properties like the modfun above.

require 'riak/client/beefcake/crdt_operator'
require 'riak/client/beefcake/crdt_loader'
require 'riak/client/beefcake/protocol'
require 'riak/client/beefcake/socket'
true
rescue LoadError, NameError
rescue LoadError, NameError => e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruby-n00b question: why set e when it's unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I so the exception goes into a variable and I can find it in a debugger. I should probably roll that one back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

@lukebakken
Copy link
Contributor

@bkerley this all looks great and is very easy to follow.

@drewkerrigan
Copy link

+1 3257730

borshop added a commit that referenced this pull request Feb 5, 2015
Setting bucket properties is goofy

Reviewed-by: drewkerrigan
@bkerley
Copy link
Contributor Author

bkerley commented Feb 5, 2015

@borshop merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants