riak-ripple / ripple Goto Github PK
View Code? Open in Web Editor NEWA rich Ruby modeling layer for Riak, Basho's distributed database
License: Other
A rich Ruby modeling layer for Riak, Basho's distributed database
License: Other
When a link header is sent to riak with a %20 in it, it will be rewritten to use a '+', thus the link will reference a document which does not exist. I would be safer therefore to store documents in Riak with the '+' in the key rather than substitute it to %20 as any links to the document will remain valid.
We should have support for cucumber, RSpec, Test::Unit, Shoulda, etc.
Currently different instances of the same Document do not compare to equivalent.
The following code yields an exception
item = client['items']['item']
catalog = client['catalogs']['test']
link = item.to_link
catalog.links << link
catalog.store
(...)
/Users/ftreacy/.rvm/gems/ruby-1.9.1-p378/gems/riak-client-0.7.0/lib/riak/client/curb_backend.rb:63:in
perform': Expected [200, 204, 300] from Riak but received 400. Invalid Link header. Links must be of the form (Riak::FailedRequest) </riak/BUCKET/KEY>; riaktag="TAG" from /Users/ftreacy/.rvm/gems/ruby-1.9.1-p378/gems/riak-client-0.7.0/lib/riak/client/http_backend.rb:92:in
put'
from /Users/ftreacy/.rvm/gems/ruby-1.9.1-p378/gems/riak-client-0.7.0/lib/riak/robject.rb:122:in
`store'
This is because a 'tag' is not set, but tags shouldn't be required.
e.g. key_on :name
class Foo
include Ripple::Document
property :foo, String
end
# foo has a carriage return control character
Foo.create(:foo => "bar\rbaz")
# problem parsing data
Riak::MapReduce.new(Ripple.client).
add("foos").
map("function(v){ return [JSON.parse(v.values[0].data)]; }", :keep => true).run
# clean up
Foo.all{|f| f.destroy}
# no more carriage return
Foo.create(:foo => "bar baz")
# no problemo
Riak::MapReduce.new(Ripple.client).
add("foos").
map("function(v){ return [JSON.parse(v.values[0].data)]; }", :keep => true).run
# clean up
Foo.all{|f| f.destroy}
Looks like Report.bucket.keys returns nil when the bucket is empty, I would guess it should return an empty array.
uninitialized constant User::Boolean
is raised when I define property :admin, Boolean
in class User include Ripple::Document
.
My current workaround is to copy/paste Ripple's module Boolean
just before the model class declaration.
Error during failsafe response:
ActionView::Template::Error (Session contains objects whose class definition isn't available.
Remember to require the classes for all objects kept in the session.
(Original exception: uninitialized constant User::Boolean [NameError])
) in /Users/ftreacy/.rvm/gems/ruby-1.9.1-p378/gems/actionpack-3.0.0.beta3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb:
127.0.0.1 - - [02/Jul/2010 11:50:48] "GET /users/[email protected] HTTP/1.0" 500 - 0.2028
Sorry if in case I've overlooked something (I've just started to look into this gem and riak itself)...
Is there a way to provide a list of known riak nodes? I know that you can fetch data from any given node, but I've you provide only one host and that host is down, you are screwed, right?
Seems like the interface for ActiveModel changed on you. Let me know if you need any more information.
I know there's the Ripple.config, but it don't seems to work:
>> Ripple.client.prefix
=> "/raw/"
>> Ripple.config = {:prefix => 'riak'}
=> {:prefix=>"riak"}
>> Ripple.client.prefix
=> "/raw/"
>> Ripple.client.port
=> 8098
>> Ripple.config = {:port => '9000'}
=> {:port=>"9000"}
>> Ripple.client.port
=> 8098
>
I think you have a bad spec. In ripple_spec.rb you have:
it "should reset the client when the configuration changes" do
c = Ripple.client
Ripple.config = {:port => 9000}
Ripple.client.should_not == c
end
In IRB, I tried it:
>> c = Ripple.client
=> #<Riak::Client http://127.0.0.1:8098>
>> Ripple.config = {:port => 9000}
=> {:port=>9000}
>> Ripple.client == c
=> false
>> Ripple.client
=> #<Riak::Client http://127.0.0.1:8098>
>> c
=> #<Riak::Client http://127.0.0.1:8098>
>>
With this spec the test break:
it "should reset the client when the configuration changes" do
c = Ripple.client
Ripple.config = {:port => 9000}
Ripple.client.port.should == 9000
end
include a middleware to clear the caches on each request
When you save a nil for a property set as Date, it tries to typecast the nil back to Date and raises an exception. Apparently this is fixed on the associations branch. Can we port it over here somehow?
To follow the rule of least surprise, I think the configuration file should be processed using ERB a la database.yml. ashley-woodard/ripple@d24f3f3
With ripple 0.6.1, I am getting an error creating an instance of a class that uses the Ripple::Document. The example taken from the wiki:
require 'ripple'
class Email
include Ripple::Document
property :from, String, :presence => true
property :to, String, :presence => true
property :sent, Time, :default => proc { Time.now }
property :body, String
end
Then I create an Email and get the following error:
reply = Email.new
NameError: undefined local variable or method `changed_attributes' for #<Email:0x102683be0>
from /Users/nparker/.gem/ruby/1.8/gems/activemodel-3.0.0.beta2/lib/active_model/attribute_methods.rb:358:in `method_missing'
from /Library/Ruby/Gems/1.8/gems/ripple-0.6.1/lib/ripple/document/attribute_methods.rb:87:in `method_missing'
from /Library/Ruby/Gems/1.8/gems/ripple-0.6.1/lib/ripple/document/attribute_methods/dirty.rb:41:in `initialize'
from (irb):9:in `new'
from (irb):9
Have you seen this before?
Net::HTTP supports streaming from an IO object, but setting data to a File when using Curb results in an inspect output in the object body.
The way the gemspec is written ensures that this only works for rails 3 beta, it fails to install with bundler and edge rails.
Example:
class Model
include Ripple::Document
property :array, Array, :default => []
end
m = Model.new
m.array << 1
m.array # => []
Hello, Sean.
It appears that the timeout setting on M/R jobs are being ignored. Although I set the timeout to various different settings, my jobs all timeout right @ 60 seconds.
When you save a nil for a property set as Date, it tries to typecast the nil back to Date and raises an exception. Apparently this is fixed on the associations branch. Can we port it over here somehow?
Could I recommend the use of msgpack for the serialisation of attributes to data? From what I have read of the source it would appear currently the attribute data is converted to json before it is stored however this process is potentially time consuming plus expensive from a transfer point of view. Therefore could it be discussed that a binary serialisation format be used? If so could I recommend the use of msgpack which is significantly quick
This is needed for a lot of Rails-style controller methods, as well as Padrino's admin UI.
Allow extracting siblings when an object is in conflict, and picking between those, with the new vclock automatically set so storing the sibling will resolve the conflict.
@_on_validate seems to have no effect.
I have a Riak 0.8 server now running at [email protected] but now I get:
users-Mac-Pro:~ root# irb
require 'riak'
=> true
client = Riak::Client.new
=> #<Riak::Client http://127.0.0.1:8098>
client.host = "192.168.1.6"
=> "192.168.1.6"
bucket = client.bucket("riak_client_test")
NameError: uninitialized constant Riak::Bucket::JSON
from /Library/Ruby/Gems/1.8/gems/ripple-0.5.0/lib/riak/bucket.rb:49:inload' from /Library/Ruby/Gems/1.8/gems/ripple-0.5.0/lib/riak/client.rb:120:in
bucket'
from (irb):4
undefined method t' for #<Riak::Client:0x000001027c1608> (NoMethodError) ./vendor/ripple/lib/riak/client.rb:106:in
rescue in http'
./vendor/ripple/lib/riak/client.rb:102:in http' ./vendor/ripple/lib/riak/client.rb:119:in
bucket'
./vendor/ripple/lib/ripple/document/bucket_access.rb:28:in `bucket'
This will create two gems - riak-client (the basic HTTP client) and ripple (the document library). riak-client will use ActiveSupport >= 2.3.5, ripple will require Rails 3.
Falls along the line of a feature, and not sure if this is possible or desired, but an option to cast data coming back from the Riak Client as a HashWithIndifferentAccess instead of just a Hash since the ActiveSupport library is already a dependency.
Thoughts? Tomatoes?
For some reason, in lib/riak/i18n.rb, when it attempts to load active_support/i18n, rubygems tries to activate it and fails along the lines of:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.map
/home/michael/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems.rb:220:in activate' /home/michael/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in
require'
/home/michael/Scripts/CrystalCommerce/frontend/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /home/michael/Scripts/CrystalCommerce/frontend/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in
new_constants_in'
/home/michael/Scripts/CrystalCommerce/frontend/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' /home/michael/.rvm/gems/ruby-1.8.7-p249/gems/riak-client-0.7.1/lib/riak/i18n.rb:15 /home/michael/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require'
/home/michael/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' /home/michael/Scripts/CrystalCommerce/frontend/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in
require'
/home/michael/Scripts/CrystalCommerce/frontend/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in' /home/michael/Scripts/CrystalCommerce/frontend/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in
require'
/home/michael/.rvm/gems/ruby-1.8.7-p249/gems/riak-client-0.7.1/lib/riak.rb:22
/home/michael/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' /home/michael/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require'
If I throw on a NoMethodError to the rescue LoadError, I am able to get around it, despite how ugly that is.
This will use JSON as the content-type by default, unless specified.
When instantiating, create a special Ripple::Conflict object, or raise an exception with the conflicted object attached.
Fetching a bucket in any manner:
b = client.bucket["bucket-1"]
or
b = client["bucket-1"]
defaults its behavior to fetching every key present in that bucket. This may be undesirable behavior in cases where a user simply wants to add store a new item and doesn't fit well with the notion of high-write-availability because this is a horribly long operation if there are lots of keys in that bucket.
Allow setting of R, W, DW for tunable consistency
Document::all with a passed block fails because it invalidates the curl handle. Use multi or Typhoeus if possible.
It would be cool if ripple could emulate transactions. Something like this:
transaction do
Foo.create(:answer => 42)
bar = Bar.find('Spam')
bar.content = 'Mayonnaise'
bar.save
# Here foo and bar have only run their before_* callbacks and validations
# but are not actually stored yet.
end
# If all validations for both Foo and Bar passed, both are stored now,
# otherwise the new Foo is discarded and bar was never updated.
I am trying to let riak create a key for my objects, but I keep getting a NoMethodError.
client = Riak::Client.new
bucket = client.bucket('howtos')
new_obj = Riak::RObject.new(bucket)
NoMethodError: private method `gsub' called for nil:NilClass
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/uri/common.rb:289:in `escape'
from /Users/matt/Projects/mpdb/vendor/gems/gems/ripple-0.6.1/lib/riak/util/escape.rb:8:in `escape'
from /Users/matt/Projects/mpdb/vendor/gems/gems/ripple-0.6.1/lib/riak/robject.rb:219:in `inspect'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:302:in `output_value'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:151:in `eval_input'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:263:in `signal_status'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:147:in `eval_input'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:70:in `start'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:69:in `catch'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:69:in `start'
from /usr/bin/irb:13
Docs:
http://seancribbs.github.com/ripple/Riak/RObject.html#initialize-instance_method
According to the docs, the 'key' param defaults to nil and if it is nil a key will be assigned.
What am I missing?
THanks,
Matt
Generate methods and map-reduce jobs for finding documents. Load documents and objects from the map-reduce form.
Both clients don't verify that they are returning the whole chunk but return an arbitrary length chunk of the input (based on their internal buffers probably). This only emerges when the individual key lists are large.
Types:
Let Document create indexes on simple properties in separate buckets, with links back to the original object. Generate finder methods for these eager indices that uses simple link walking.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.