Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
N
node-bigstream
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bs
node-bigstream
Commits
61606aa2
Commit
61606aa2
authored
Dec 19, 2016
by
project
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
75c0b32e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
158 additions
and
8 deletions
+158
-8
index.js
plugins/di/di-example/index.js
+1
-1
di-plugin.js
plugins/di/di-plugin.js
+2
-1
index.js
plugins/dt/dt-noop/index.js
+13
-0
perform.js
plugins/dt/dt-noop/perform.js
+26
-0
dt-plugin.js
plugins/dt/dt-plugin.js
+76
-0
example.json
test/jobs/example.json
+4
-4
playjob.js
test/playjob.js
+36
-2
No files found.
plugins/di/di-example/index.js
View file @
61606aa2
...
...
@@ -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
);
...
...
plugins/di/di-plugin.js
View file @
61606aa2
...
...
@@ -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
){
...
...
plugins/dt/dt-noop/index.js
0 → 100644
View file @
61606aa2
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
;
plugins/dt/dt-noop/perform.js
0 → 100644
View file @
61606aa2
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
;
plugins/dt/dt-plugin.js
0 → 100644
View file @
61606aa2
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
;
}
test/jobs/example.json
View file @
61606aa2
...
...
@@ -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"
,
...
...
test/playjob.js
View file @
61606aa2
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment