Commit 61606aa2 authored by project's avatar project

--no commit message

--no commit message
parent 75c0b32e
......@@ -3,7 +3,7 @@ var DIPlugin = require('../di-plugin');
function DITask(context){
DIPlugin.call(this,context);
this.name = "http-request";
this.name = "example";
this.output_type = "text";
}
util.inherits(DITask,DIPlugin);
......
......@@ -4,6 +4,7 @@ var EventEmitter = require('events').EventEmitter;
function DIPlugin(context){
EventEmitter.call(this);
this.version = '0.1';
this.name = 'base';
this.jobcontext = context;
this.outputdata = null;
......@@ -33,7 +34,7 @@ function DIResponse(handle){
this.handle = handle;
this.status = null;
this.data = null;
this.output_type = '*';
this.output_type = '';
}
DIResponse.prototype.success = function(data,type){
......
var util = require('util');
var DTPlugin = require('../dt-plugin');
function DTTask(context,request){
DTPlugin.call(this,context,request);
this.name = "noop";
this.output_type = "";
}
util.inherits(DTTask,DTPlugin);
DTTask.prototype.perform = require('./perform');
module.exports = DTTask;
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 memstore = context.task.memstore
var output_type = request.input_type;
var data = request.data;
// memstore.setItem('lasttransaction',transaction_id,function(err){
// response.success(data);
// });
// memstore.getItem('lasttransaction',function(err,value){
// response.success(value);
// });
data = data + "--DT--"
response.success(data,output_type);
//response.reject();
//response.error("error message")
}
module.exports = perform_function;
var util = require('util');
var EventEmitter = require('events').EventEmitter;
function DTPlugin(context,request){
EventEmitter.call(this);
this.version = '0.1';
this.name = 'base';
this.jobcontext = context;
this.request = request;
this.outputdata = null;
}
util.inherits(DTPlugin, EventEmitter);
DTPlugin.prototype.getname = function(){
return this.name;
}
DTPlugin.prototype.perform = function(){}
DTPlugin.prototype.run = function(){
this.emit('start');
var resp = new DTResponse(this);
this.perform(this.jobcontext,this.request,resp);
}
module.exports = DTPlugin;
/*
DTResponse
*/
function DTResponse(handle){
this.handle = handle;
this.status = null;
this.data = null;
this.output_type = '';
}
DTResponse.prototype.success = function(data,type){
var handle = this.handle;
process.nextTick(function(){
handle.emit('done',response('success',data,type));
});
}
DTResponse.prototype.error = function(err){
var handle = this.handle;
process.nextTick(function(){
handle.emit('done',response('error',err));
});
}
DTResponse.prototype.reject = function(){
var handle = this.handle;
process.nextTick(function(){
handle.emit('done',response('reject',null));
});
}
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;
}
......@@ -6,10 +6,10 @@
"cmd": "*/10 * * * * *"
},
"data_in" : {
"type": "example",
"param": {
"url": "http://www.google.com"
}
"type": "example"
},
"data_transfrom" : {
"type": "noop"
},
"data_out" : {
"type": "bss-storage",
......
......@@ -44,11 +44,19 @@ function run_job(cfg)
"transaction" : transaction
}
console.log('JOB RUNNING \n[TRANSACTION ID]\t: ' + transaction.id + '\n');
console.log('***** JOB RUNNING *****\n[TRANSACTION ID]\t: ' + transaction.id + '\n');
//process di
perform_di(context,function(err,resp){
if(resp.status == 'success' && context.jobconfig.data_transfrom){
var dt_request = {'type':resp.type,'data':resp.data}
perform_dt(context,dt_request,function(err,dt_resp){
console.log('***** JOB DONE *****\n\n');
});
}else{
console.log('***** JOB DONE *****\n\n');
}
});
}
......@@ -79,6 +87,32 @@ function perform_di(context,cb)
});
}
function perform_dt(context,request,cb)
{
console.log('\n\n[RUNNING DT]');
var dt_context = context
var jobId = dt_context.jobconfig.job_id;
var dt_cfg = dt_context.jobconfig.data_transfrom;
console.log('[DT_PLUGIN]\t\t: ' + dt_cfg.type);
var DITask = getPlugins('dt',dt_cfg.type);
var mempref = "ms." + jobId + '.dt';
var dtMem = new memstore(mempref,storage);
dt_context.task = {
"memstore" : dtMem
}
var dt = new DITask(dt_context,request);
dt.run();
dt.on('done',function(resp){
console.log('[DT_OUTPUT_TYPE]\t: ' + resp.type);
console.log('[DT_STATUS]\t\t: ' + resp.status);
console.log('>>' + resp.data);
cb(null,resp);
});
}
function getPlugins(type,name)
{
var path = '../plugins/' + type + '/' + type + '-' +name;
......
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