Commit b9f8b95c authored by project's avatar project

--no commit message

--no commit message
parent 61606aa2
......@@ -38,38 +38,31 @@ function DIResponse(handle){
}
DIResponse.prototype.success = function(data,type){
var self=this;
var handle = this.handle;
this.data = data;
this.status = 'success';
if(type){this.output_type=type;}
process.nextTick(function(){
handle.emit('done',response('success',data,type));
handle.emit('done',{'status':'success','data':data,'type':self.output_type});
});
}
DIResponse.prototype.error = function(err){
var self=this;
var handle = this.handle;
this.data = err;
this.status = 'error';
process.nextTick(function(){
handle.emit('done',response('error',err));
handle.emit('done',{'status':'error','data':err});
});
}
DIResponse.prototype.reject = function(){
var handle = this.handle;
this.status = 'reject';
process.nextTick(function(){
handle.emit('done',response('reject',null));
handle.emit('done',{'status':'reject'});
});
}
function response(status,data,type){
var resp = {'status':status,'data':data};
if(type){
resp.type = type;
this.output_type = type;
}else{
resp.type = this.output_type;
}
this.data = data;
this.status = status;
return resp;
}
var util = require('util');
var DOPlugin = require('../do-plugin');
function DOTask(context,request){
DOPlugin.call(this,context,request);
this.name = "console";
}
util.inherits(DOTask,DOPlugin);
DOTask.prototype.perform = require('./perform');
module.exports = DOTask;
function perform_function(context,request,response){
var job_id = context.jobconfig.job_id;
var transaction_id = context.transaction.id;
var param = context.jobconfig.data_out.param;
var memstore = context.task.memstore
var output_type = request.input_type;
var data = request.data;
console.log(data);
response.success();
//response.reject();
//response.error("error message")
}
module.exports = perform_function;
var util = require('util');
var EventEmitter = require('events').EventEmitter;
function DOPlugin(context,request){
EventEmitter.call(this);
this.version = '0.1';
this.name = 'base';
this.jobcontext = context;
this.request = request;
}
util.inherits(DOPlugin, EventEmitter);
DOPlugin.prototype.getname = function(){
return this.name;
}
DOPlugin.prototype.perform = function(){}
DOPlugin.prototype.run = function(){
this.emit('start');
var resp = new DOResponse(this);
this.perform(this.jobcontext,this.request,resp);
}
module.exports = DOPlugin;
/*
DOResponse
*/
function DOResponse(handle){
this.handle = handle;
this.status = null;
this.data = null;
}
DOResponse.prototype.success = function(data){
var handle = this.handle;
this.status = 'success';
this.data = data;
process.nextTick(function(){
handle.emit('done',{'status':'success','data':data});
});
}
DOResponse.prototype.error = function(err){
var handle = this.handle;
this.status = 'error';
this.data = err;
process.nextTick(function(){
handle.emit('done',{'status':'error','data':err});
});
}
DOResponse.prototype.reject = function(){
var handle = this.handle;
this.status = 'reject';
process.nextTick(function(){
handle.emit('done',{'status':'reject','data':null});
});
}
function perform_function(context,request,response){
var job_id = context.jobconfig.job_id;
var transaction_id = context.transaction.id;
var param = context.jobconfig.data_in.param;
var param = context.jobconfig.data_transform.param;
var memstore = context.task.memstore
var output_type = request.input_type;
......@@ -15,7 +15,7 @@ function perform_function(context,request,response){
// memstore.getItem('lasttransaction',function(err,value){
// response.success(value);
// });
data = data + "--DT--"
//data = data + "--DT--"
response.success(data,output_type);
//response.reject();
......
......@@ -39,38 +39,31 @@ function DTResponse(handle){
}
DTResponse.prototype.success = function(data,type){
var self=this;
var handle = this.handle;
this.data = data;
this.status = 'success';
if(type){this.output_type=type;}
process.nextTick(function(){
handle.emit('done',response('success',data,type));
handle.emit('done',{'status':'success','data':data,'type':self.output_type});
});
}
DTResponse.prototype.error = function(err){
var self=this;
var handle = this.handle;
this.data = err;
this.status = 'error';
process.nextTick(function(){
handle.emit('done',response('error',err));
handle.emit('done',{'status':'error','data':err});
});
}
DTResponse.prototype.reject = function(){
var handle = this.handle;
this.status = 'reject';
process.nextTick(function(){
handle.emit('done',response('reject',null));
handle.emit('done',{'status':'reject'});
});
}
function response(status,data,type){
var resp = {'status':status,'data':data};
if(type){
resp.type = type;
this.output_type = type;
}else{
resp.type = this.output_type;
}
this.data = data;
this.status = status;
return resp;
}
......@@ -12,9 +12,6 @@
"type": "noop"
},
"data_out" : {
"type": "bss-storage",
"param" : {
"name": "sds.agritronics"
}
"type": "console"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment