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

Read Repair #301

Open
mattsnyder opened this issue Oct 15, 2012 · 0 comments · Fixed by SaveLoveGive/ripple#1
Open

Read Repair #301

mattsnyder opened this issue Oct 15, 2012 · 0 comments · Fixed by SaveLoveGive/ripple#1

Comments

@mattsnyder
Copy link

Would be nice to perform read repair and remove dead links from the robject from within Ripple as objects are retrieved from Riak.

Currently operations like #count on a Ripple::Document use keys.count which includes dead links.
https://github.com/basho/ripple/blob/master/lib/ripple/associations/many_linked_proxy.rb#L11-14

Iterating over collections also requires rejecting nil values that result from dead links.

My thought is to perform link cleanup after calls to find_target.
https://github.com/basho/ripple/blob/master/lib/ripple/associations/many_linked_proxy.rb#L48-59

Here are tests to describe the desired behavior that could be added to https://github.com/basho/ripple/blob/master/spec/ripple/associations/many_linked_proxy_spec.rb:

 describe "#instantiate", :focus => true do
    context "all links are dead" do
      it "should remove links that could not be instantiated" do
        @person.robject.links << @task.to_link("tasks")
        @person.tasks.inspect # trigger load_object
        @person.robject.links.should be_empty
      end
    end
    context "only some links are dead" do
      it "should remove links that could not be instantiated" do
        @person.robject.links << @task.to_link("tasks")
        @person.tasks << @other_task
        @person.tasks.inspect
        @person.robject.links.should have(1).item
        @person.robject.links.should include(@other_task.to_link("tasks"))
      end
    end
    context "owner also links to objects of another type" do
      it "should only remove dead links of the accessed association" do
        @person.profile = @profile
        @person.robject.links << @task.to_link("tasks")
        @person.robject.links.should have(2).item
        @person.tasks.inspect
        @person.robject.links.should have(1).item
      end
    end
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant