riak-client is a rich Ruby client/toolkit for Riak, Basho's distributed database that contains a basic wrapper around typical operations, including bucket manipulation, object CRUD, link-walking, and map-reduce.
Exhaustive documentation is available at http://basho.github.io/riak-ruby-client/ , and API documentation can be read at http://www.rubydoc.info/gems/riak-client/frames .
Ruby 1.9.3, 2.0, 2.1, and 2.2 are supported. JRuby in 1.9 and 2.0 modes are also supported. riak-client is not compatible with Ruby 1.8.
In JRuby 1.7.13, OCSP validation is absent, and CRL validation always fails. This issue is being tracked and this document will be updated when it is fixed. Additionally, client certificate authentication doesn't work in JRuby. This issue is also being tracked, and this document will be updated when it works.
riak-client requires beefcake, cert_validator, i18n, innertube, and multi_json.
Riak 2 uses bucket types to enable groups of similar buckets to share properties, configuration, and to namespace values within those buckets. Bucket type support is integral to how CRDTs work.
In versions 2.2.0 and newer of this client, bucket types have a first-class representation, and can be used to create BucketTyped::Bucket objects that are namespaced differently from regular Riak::Bucket objects.
# This example assumes you have a "beverages" bucket type.
chapadao.data = "Chapadao de Ferro"
This client supports the new Riak Search 2 (codenamed "Yokozuna"). For more information about Riak Search, see the Riak documentation.
This documentation assumes there's a yokozuna bucket type created and activated.
# Create a client and bucket.
# may fail until the index creation has propagated.
Riak supports secondary indexes. Secondary indexing, or "2i," gives you the ability to tag objects with multiple queryable values at write time, and then query them later.
Objects are tagged with a hash kept behind the indexes method. Secondary index storage logic is in lib/riak/rcontent.rb.
# indexes. They can have multiple values.
# have multiple values too.
# You must re-save the object to store indexes.
Secondary index queries return a list of keys exactly matching a scalar or within a range.
# Binary indexes also support both ranges and scalars.
# but can also fetch values for you in parallel.
Riak 2 features new distributed data structures: counters, sets, and maps (containing counters, flags, maps, registers, and sets). These are implemented by the Riak database as Convergent Replicated Data Types.
Riak data type support requires bucket types to be configured to support each top-level data type. If you're just playing around, use the Riak Ruby Vagrant setup to get started with the appropriate configuration and bucket types quickly.
The top-level CRDT types have both immediate and batch mode. If you're doing multiple writes to a single top-level counter or set, or updating multiple map entries, batch mode will make fewer round-trips to Riak.
Top-level CRDT types accept nil as a key. This allows Riak to assign a random key for them.
Deleting CRDTs requires you to use the key-value API for the time being.
Riak 2 integer counters have one operation: increment by an integer.
Riak 2 maps can contain counters, flags (booleans), registers (strings), sets, and other maps.
Maps are similar but distinct from the standard Ruby Hash. Entries are segregated by both name and type, so you can have counters, registers, and sets inside a map that all have the same name.
Sets are an unordered collection of entries.
PROTIP: Ruby and Riak Ruby Client both have classes called Set. Be careful to refer to the Ruby version as ::Set and the Riak client version as Riak::Crdt::Set.
The client code for these types is in the Riak::Crdt namespace, and mostly in the lib/riak/crdt directory.
For more information about 1.4-style counters in Riak, see the Basho documentation.
Counter records are automatically persisted on increment or decrement. The initial default value is 0.
ArgumentError: Counters can only be incremented or decremented by integers.
That's about it. PN Counters in Riak are distributed, so each node will receive the proper increment/decrement operation. Enjoy using them.
Events are propogated using ActiveSupport::Notifications, provided by the Instrumentable gem.
We aim to have a comprehensive and fast set of tests, implemented using a modern, well-supported version of RSpec. These tests include both unit specs for individual classes, and integration specs that ensure the client works properly with an actual Riak instance.
The Riak Ruby Vagrant virtual machine's Riak configuration is normally used to test this client in development. Once it's up and running, configure the Ruby test_client.yml on the host machine to connect to pb_port: 17017 and test away.
Configuring the Riak node the tests connect to is done via the spec/support/test_client.yml file, which is loaded into a Ruby hash with symbolized keys, and passed to Riak::Client.new.
The LevelDB backend is necessary for testing secondary indexes.
allow_mult is required for many features: conflict resolution, and legacy counters among them.
Riak Search 2.0 ("Yokozuna") must be configured for testing full-text search.
Copy spec/support/test_server.yml.example to spec/support/test_server.yml and change that file according to your local installation of riak.
Write an RSpec example or set of examples that demonstrate the necessity and validity of your changes. Patches without specs will most often be ignored. Just do it, you'll thank me later. Documentation patches need no specs, of course.
Make your feature addition or bug fix. Make your specs and stories pass (green).
Run the suite using multiruby or rvm to ensure cross-version compatibility.
Cleanup any trailing whitespace in your code (try @whitespace-mode@ in Emacs, or "Remove Trailing Spaces in Document" in the "Text" bundle in Textmate). You can use the clean_whitespace Rake task if you like.
Commit, do not mess with Rakefile. If related to an existing issue in the tracker, include "Closes #X" in the commit message (where X is the issue number).
Send a pull request to the Basho repository.
Copyright ©2010-2016 Sean Cribbs and Basho Technologies, Inc.
The included photo (spec/fixtures/cat.jpg) is Copyright ©2009 Sean Cribbs, and is licensed under the Creative Commons Attribution Non-Commercial 3.0 license.
Generated on Thu Apr 4 02:27:43 2019 by yard 0.9.19 (ruby-2.5.1).