Skip to content
This repository has been archived by the owner on Feb 22, 2019. It is now read-only.

Commit

Permalink
Updating thrift options and exposing consistency level
Browse files Browse the repository at this point in the history
  • Loading branch information
Calvin French-Owen committed Sep 27, 2012
1 parent face5a9 commit 15761e5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Readme.md
Expand Up @@ -93,7 +93,7 @@ If you do not want to use CQL, you can make calls using the thrift driver


//get what we just put in //get what we just put in
//the driver will return a Helenus.Row object just like CQL //the driver will return a Helenus.Row object just like CQL
cf.get('foo', function(err, row){ cf.get('foo', {consistency:Helenus.ConsistencyLevel.ONE} function(err, row){
if(err){ if(err){
throw(err); throw(err);
} }
Expand Down Expand Up @@ -202,6 +202,15 @@ Columns are returned as objects with the following structure:
} }
``` ```


## ConsistencyLevel

Helenus supports using a custom consistency level. By default, when using the thrift client reads and writes will both use `QUORUM`. When using the thrift driver, you simply pass a custom level in the options:

```javascript
cf.insert(key, values, {consistency : Helenus.ConsistencyLevel.ANY}, callback);
```


## Contributors ## Contributors


* Russell Bradberry - @devdazed * Russell Bradberry - @devdazed
Expand Down
7 changes: 7 additions & 0 deletions lib/helenus.js
Expand Up @@ -87,4 +87,11 @@ Helenus.UUID = require('./uuid').UUID;
Helenus.TimeUUID = require('./uuid').TimeUUID; Helenus.TimeUUID = require('./uuid').TimeUUID;




/**
* An object exposed to allow for custom consistency levels.
* @see ttypes.ConsistencyLevel
*/
Helenus.ConsistencyLevel = require('./cassandra/cassandra_types').ConsistencyLevel;


module.exports = Helenus; module.exports = Helenus;
21 changes: 21 additions & 0 deletions test/thrift.js
Expand Up @@ -151,6 +151,14 @@ module.exports = {
}); });
}, },


'test standard cf.insert with custom CL':function(test, assert){
cf_standard.insert(config.standard_row_key, config.standard_insert_values,
{ consistency : Helenus.ConsistencyLevel.ANY }, function(err, results){
assert.ifError(err);
test.finish();
});
},

'test standard cf.insert into composite cf':function(test, assert){ 'test standard cf.insert into composite cf':function(test, assert){
var values = [ var values = [
new Helenus.Column([12345678912345, new Date(1326400762701)], 'some value') new Helenus.Column([12345678912345, new Date(1326400762701)], 'some value')
Expand Down Expand Up @@ -219,6 +227,19 @@ module.exports = {
}); });
}, },


'test standard cf.get with custom CL':function(test, assert){
cf_standard.get(config.standard_row_key,
{ consistency : Helenus.ConsistencyLevel.ONE }, function(err, row){

assert.ifError(err);
assert.ok(row instanceof Helenus.Row);
assert.ok(row.key === config.standard_row_key);
assert.ok(row.get('one').value === 'a');

test.finish();
});
},

'test standard cf.get with columns names':function(test, assert){ 'test standard cf.get with columns names':function(test, assert){
cf_standard.get(config.standard_row_key, config.standard_get_names_options, function(err, row){ cf_standard.get(config.standard_row_key, config.standard_get_names_options, function(err, row){
assert.ifError(err); assert.ifError(err);
Expand Down

0 comments on commit 15761e5

Please sign in to comment.