lib/commands/commandbase.js
function CommandBase(pbRequestName, pbResponseName, callback) {
    var requestCode = ProtoBufFactory.getCodeFor(pbRequestName);
    this.expectedCode = ProtoBufFactory.getCodeFor(pbResponseName);
    this.pbBuilder = ProtoBufFactory.getProtoFor(pbRequestName);

    var schema = Joi.func().required();
    var self = this;
    Joi.validate(callback, schema, function(err, option) {
       if (err) {
           throw new Error('callback is required and must be a function');
       }
       self.callback = callback;
    });
   
    this.header = new Buffer(5);
    this.header.writeUInt8(requestCode, 4);
    
    this.remainingTries = 1;
    
    // This is to facilitate debugging what pb messages this Command represents
    this.name = util.format('%s-%d', pbRequestName, cid);
    cid++;

    this.validateOptions = function (arg_options, arg_schema, arg_joi_opts) {
        var self = this;
        Joi.validate(arg_options, arg_schema, arg_joi_opts, function(err, opts) {
            if (err) {
                throw err;
            }
            self.options = opts;
        });
    };
}
function CommandBase(pbRequestName, pbResponseName, callback) {
    var requestCode = ProtoBufFactory.getCodeFor(pbRequestName);
    this.expectedCode = ProtoBufFactory.getCodeFor(pbResponseName);
    this.pbBuilder = ProtoBufFactory.getProtoFor(pbRequestName);

    var schema = Joi.func().required();
    var self = this;
    Joi.validate(callback, schema, function(err, option) {
       if (err) {
           throw new Error('callback is required and must be a function');
       }
       self.callback = callback;
    });
   
    this.header = new Buffer(5);
    this.header.writeUInt8(requestCode, 4);
    
    this.remainingTries = 1;
    
    // This is to facilitate debugging what pb messages this Command represents
    this.name = util.format('%s-%d', pbRequestName, cid);
    cid++;

    this.validateOptions = function (arg_options, arg_schema, arg_joi_opts) {
        var self = this;
        Joi.validate(arg_options, arg_schema, arg_joi_opts, function(err, opts) {
            if (err) {
                throw err;
            }
            self.options = opts;
        });
    };
}
function CommandBase ( pbRequestName , pbResponseName , callback ) { var requestCode = ProtoBufFactory . getCodeFor ( pbRequestName ) ; this . expectedCode = ProtoBufFactory . getCodeFor ( pbResponseName ) ; this . pbBuilder = ProtoBufFactory . getProtoFor ( pbRequestName ) ; var schema = Joi . func ( ) . required ( ) ; var self = this ; Joi . validate ( callback , schema , function ( err , option ) { if ( err ) { throw new Error ( 'callback is required and must be a function' ) ; } self . callback = callback ; } ) ; this . header = new Buffer ( 5 ) ; this . header . writeUInt8 ( requestCode , 4 ) ; this . remainingTries = 1 ; // This is to facilitate debugging what pb messages this Command represents this . name = util . format ( '%s-%d' , pbRequestName , cid ) ; cid ++ ; this . validateOptions = function ( arg_options , arg_schema , arg_joi_opts ) { var self = this ; Joi . validate ( arg_options , arg_schema , arg_joi_opts , function ( err , opts ) { if ( err ) { throw err ; } self . options = opts ; } ) ; } ; }
Provides a base class for all commands.

@module Core
 
Base class for all commands.

Classes extending this need to override:

constructPbRequest
onSuccess
onRiakError
onError

@class CommandBase
@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 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.
Provides a base class for all commands .