Skip to content

Commit

Permalink
Merge remote-tracking branch 'basho/features/lrb/rts-311' into featur…
Browse files Browse the repository at this point in the history
…es/lrb/rts-311
  • Loading branch information
Luke Bakken committed Nov 18, 2015
2 parents 76de3f2 + a7d8d0c commit 0221b27
Show file tree
Hide file tree
Showing 111 changed files with 1,216 additions and 2,020 deletions.
8 changes: 6 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = function(grunt) {

grunt.initConfig({
Expand All @@ -16,14 +18,16 @@ module.exports = function(grunt) {
url: '<%= pkg.homepage %>',
options: {
paths: './lib/',
outdir: './docs/'
outdir: './docs/',
tabtospace: 4
}
}
},
jshint: {
files: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js'],
options: {
node: true
node: true,
mocha: true
}
},
mochaTest: {
Expand Down
16 changes: 1 addition & 15 deletions benchmarks/kv.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright 2015 Basho Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

var Riak = require('../lib/client');

Expand Down
19 changes: 3 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
/*
* Copyright 2015 Basho Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

module.exports = require('./lib/client');
'use strict';

module.exports = require('./lib/client');
48 changes: 29 additions & 19 deletions lib/client.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright 2015 Basho Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

// Core modules
var Core = require('./core/core');
Expand Down Expand Up @@ -422,14 +408,14 @@ Client.prototype.mapReduce = function(query, callback, stream) {
*/

/**
* See {{#crossLink "StoreValue"}}{{/crossLink}}
* @method tsStoreValue
* See {{#crossLink "Store"}}{{/crossLink}}
* @method tsStore
* @param {Object} options The options for this operation.
* @param {Function} callback The callback to be executed when the operation completes.
*
*/
Client.prototype.tsStoreValue = function(options, callback) {
var cmd = new TS.StoreValue(options, callback);
Client.prototype.tsStore = function(options, callback) {
var cmd = new TS.Store(options, callback);
this.cluster.execute(cmd);
};

Expand All @@ -445,6 +431,30 @@ Client.prototype.tsQuery = function(options, callback) {
this.cluster.execute(cmd);
};

/**
* See {{#crossLink "Get"}}{{/crossLink}}
* @method tsGet
* @param {Object} options The options for this operation.
* @param {Function} callback The callback to be executed when the operation completes.
*
*/
Client.prototype.tsGet = function(options, callback) {
var cmd = new TS.Get(options, callback);
this.cluster.execute(cmd);
};

/**
* See {{#crossLink "Delete"}}{{/crossLink}}
* @method tsDelete
* @param {Object} options The options for this operation.
* @param {Function} callback The callback to be executed when the operation completes.
*
*/
Client.prototype.tsDelete = function(options, callback) {
var cmd = new TS.Delete(options, callback);
this.cluster.execute(cmd);
};

// Namespaces
function Riak() { }
function Commands() { }
Expand Down
22 changes: 14 additions & 8 deletions lib/commands/commandbase.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var ProtoBufFactory = require('../protobuf/riakprotobuf');
var Joi = require('joi');

Expand All @@ -21,10 +23,12 @@ var Joi = require('joi');
* @constructor
* @param {String} pbRequestName name of the Riak protocol buffer this command will send
* @param {String} pbResponseName name of the Riak protocol buffer this command will receive
* @param {Function} callback The user callback.
* @param {Function} callback The callback to be executed when the operation completes.
* @param {String} callback.err An error message. Will be null if no error.
* @param {Object} callback.response the response from Riak.
* @param {Object} callback.data additional error data. Will be null if no error.
*/
function CommandBase(pbRequestName, pbResponseName, callback) {

var requestCode = ProtoBufFactory.getCodeFor(pbRequestName);
this.expectedCode = ProtoBufFactory.getCodeFor(pbResponseName);
this.pbBuilder = ProtoBufFactory.getProtoFor(pbRequestName);
Expand Down Expand Up @@ -133,28 +137,30 @@ CommandBase.prototype.onSuccess = function(pbResponseMessage) {

/**
* Called by RiakNode when a RpbErrorResp is received and all retries are exhausted.
* Commands must override this method.
* Commands may override this method.
* @protected
* @method onRiakError
* @param {Object} rpbErrorResp the RpbErrorResp protocol buffer
*/
CommandBase.prototype.onRiakError = function(rpbErrorResp) {
this.onError(rpbErrorResp.getErrmsg().toString('utf8'));
var errmsg = rpbErrorResp.getErrmsg().toString('utf8');
var errcode = rpbErrorResp.getErrcode();
this.onError(errmsg, { msg: errmsg, code: errcode });
};

/**
* Called by Riaknode if an error occurs executing the command and all retries are exhausted.
* Called by RiakNode if an error occurs executing the command and all retries are exhausted.
* @protected
* @method onError
* @param {String} msg an error message
* @param {Object} data additional error data
*/
CommandBase.prototype.onError = function(msg) {
this._callback(msg, null);
CommandBase.prototype.onError = function(msg, data) {
this._callback(msg, null, data);
};

var schema = Joi.object().keys({
callback: Joi.func().required()
});

module.exports = CommandBase;

16 changes: 1 addition & 15 deletions lib/commands/crdt.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright 2015 Basho Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

/**
* Provides all the commands for Riak CRDTs (Conflict-Free Replicated Data Type)
Expand Down
25 changes: 2 additions & 23 deletions lib/commands/crdt/fetchcounter.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
/*
* Copyright 2015 Basho Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var CommandBase = require('../commandbase');
var inherits = require('util').inherits;
Expand All @@ -24,7 +9,6 @@ var Joi = require('joi');
* @module CRDT
*/


/**
* Command used to fetch a counter value from Riak.
*
Expand Down Expand Up @@ -55,22 +39,18 @@ var Joi = require('joi');
* @param {Object} callback.response The response from Riak.
* @param {Number} callback.response.counterValue The counter value in Riak.
* @param {Boolean} callback.response.isNotFound True if there was no counter in Riak.
* @param {Object} callback.data additional error data. Will be null if no error.
* @extends CommandBase
*/
function FetchCounter(options, callback) {
CommandBase.call(this, 'DtFetchReq', 'DtFetchResp', callback);

var self = this;
Joi.validate(options, schema, function(err, options) {

if (err) {
throw err;
}

self.options = options;
});

this.remainingTries = 1;
}

inherits(FetchCounter, CommandBase);
Expand Down Expand Up @@ -121,7 +101,6 @@ var schema = Joi.object().keys({
timeout: Joi.number().default(null).optional()
});


/**
* A builder for constructing FetchCounter instances.
*
Expand Down
24 changes: 2 additions & 22 deletions lib/commands/crdt/fetchmap.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright 2015 Basho Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

var CommandBase = require('../commandbase');
var inherits = require('util').inherits;
Expand All @@ -25,7 +11,6 @@ var MapField = require('../../protobuf/riakprotobuf').getProtoFor('MapField');
* @module CRDT
*/


/**
* Command for fetching a map from Riak.
*
Expand Down Expand Up @@ -58,23 +43,19 @@ var MapField = require('../../protobuf/riakprotobuf').getProtoFor('MapField');
* @param {Buffer} callback.response.context An opaque context to be used in any subsequent modification of the map.
* @param {Object} callback.response.map The map in Riak, converted to a JS object.
* @param {Boolean} callback.response.isNotFound True if there was no map in Riak.
* @param {Object} callback.data additional error data. Will be null if no error.
* @extends CommandBase
* @constructor
*/
function FetchMap(options, callback) {
CommandBase.call(this, 'DtFetchReq', 'DtFetchResp', callback);
var self = this;
Joi.validate(options, schema, function(err, options) {

if (err) {
throw err;
}

self.options = options;

});

this.remainingTries = 1;
}

inherits(FetchMap, CommandBase);
Expand Down Expand Up @@ -134,7 +115,6 @@ var dtType = {
3: 'map'
};


/**
* A builder for constructing FetchMap instances.
*
Expand Down
19 changes: 2 additions & 17 deletions lib/commands/crdt/fetchset.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright 2015 Basho Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

var CommandBase = require('../commandbase');
var inherits = require('util').inherits;
Expand All @@ -23,7 +9,6 @@ var Joi = require('joi');
* @module CRDT
*/


/**
* Command used to fetch a set from Riak.
*
Expand Down Expand Up @@ -56,6 +41,7 @@ var Joi = require('joi');
* @param {Buffer} callback.response.context An opaque context to be used in any subsequent modification of the set.
* @param {String[]|Buffer[]} callback.response.values An array holding the values in the set. String by default, Buffers if setsAsBuffers was used.
* @param {Boolean} callback.response.isNotFound True if there was no set in Riak.
* @param {Object} callback.data additional error data. Will be null if no error.
* @extends CommandBase
*/

Expand Down Expand Up @@ -278,6 +264,5 @@ bb('useBasicQuorum');
*/
bb('timeout');


module.exports = FetchSet;
module.exports.Builder = Builder;
Loading

0 comments on commit 0221b27

Please sign in to comment.