Commit 688c99ee authored by project's avatar project

--no commit message

--no commit message
parent a82ed16d
function execute_function(ctx,out){
// var job_id = ctx.profile.jobid;
// var transaction_id = ctx.profile.transaction_id;
function execute_function(context,response){
// var job_id = context.profile.job_id;
// var transaction_id = context.profile.transaction_id;
// var param = ctx.parameter;
var data = '';
var data = 'hello world';
setTimeout(function () {
response.success(context.jobid + ' ' + data);
}, 1000);
console.log(this.getname() + 'plug-ins');
//response.cancel();
//response.error("error message")
//response.success(data);
}
module.exports = execute_function;
var util = require('util');
var DIPlugin = require('../di-plugin');
function DITask(){
function DITask(context){
DIPlugin.call(this,context);
this.name = "http"
}
util.inherits(DITask,DIPlugin);
......
var util = require('util');
var EventEmitter = require('events');
var EventEmitter = require('events').EventEmitter;
function DIPlugin(context){
EventEmitter.call(this);
function DIPlugin(){
this.name = 'base';
this.jobcontext = context;
this.outputdata = null;
}
util.inherits(DIPlugin, EventEmitter);
......@@ -10,6 +14,37 @@ DIPlugin.prototype.getname = function(){
return this.name;
}
DIPlugin.prototype.execute = function(){}
DIPlugin.prototype.run = function(){
this.emit('start');
var resp = new DIResponse(this);
this.execute(this.jobcontext,resp);
}
module.exports = DIPlugin;
/*
DIResponse
*/
function DIResponse(handle){
this.handle = handle;
}
DIResponse.prototype.success = function(data){
this.handle.emit('done',response('success',data));
}
DIResponse.prototype.error = function(err){
this.handle.emit('done',response('error',data));
}
DIResponse.prototype.cancel = function(){
this.handle.emit('done',response('cancel',null));
}
function response(status,data){
return {'status':status,'data':data}
}
var DITask = require('../plugins/di/di-http-request');
var di = new DITask();
var di = new DITask({jobid:'j01'});
di.execute();
di.run();
di.on('done',function(response){
console.log('>> ' + response.data);
})
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