Permalink
Browse files

Merge branch 'expose-types'

  • Loading branch information...
2 parents b01c0fb + 15761e5 commit 18c466f4e2c744f5503bbc2088a47f09f641bf9f @calvinfo calvinfo committed Sep 27, 2012
Showing with 38 additions and 1 deletion.
  1. +10 −1 Readme.md
  2. +7 −0 lib/helenus.js
  3. +21 −0 test/thrift.js
View
11 Readme.md
@@ -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
//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){
throw(err);
}
@@ -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
* Russell Bradberry - @devdazed
View
7 lib/helenus.js
@@ -87,4 +87,11 @@ Helenus.UUID = require('./uuid').UUID;
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;
View
21 test/thrift.js
@@ -168,6 +168,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){
var values = [
new Helenus.Column([12345678912345, new Date(1326400762701)], 'some value')
@@ -236,6 +244,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){
cf_standard.get(config.standard_row_key, config.standard_get_names_options, function(err, row){
assert.ifError(err);

0 comments on commit 18c466f

Please sign in to comment.