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
492e6d41
Commit
492e6d41
authored
Feb 26, 2017
by
project
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
f0d98038
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
113 additions
and
25 deletions
+113
-25
amqp.json
conf/amqp.json
+1
-1
memstore.json
conf/memstore.json
+1
-1
http-context.js
http-listener/lib/http-context.js
+8
-0
main.js
http-listener/main.js
+20
-2
service-main.js
http-listener/ws/service-main.js
+5
-2
event-pub.js
lib/amqp/event-pub.js
+7
-0
message.js
lib/model/example/message.js
+50
-0
test.js
test/test.js
+20
-18
test_topic_sub.js
test/test_topic_sub.js
+1
-1
No files found.
conf/amqp.json
View file @
492e6d41
{
{
"type"
:
"rabbitmq"
,
"type"
:
"rabbitmq"
,
"url"
:
"amqp://
lab1
.igridproject.info"
"url"
:
"amqp://
bigmaster
.igridproject.info"
}
}
conf/memstore.json
View file @
492e6d41
{
{
"type"
:
"redis"
,
"type"
:
"redis"
,
"url"
:
"redis://:@
lab1
.igridproject.info:6379/1"
"url"
:
"redis://:@
bigmaster
.igridproject.info:6379/1"
}
}
http-listener/lib/http-context.js
0 → 100644
View file @
492e6d41
module
.
exports
.
middleware
=
function
(
ctx
){
var
funcCtx
=
function
(
req
,
res
,
next
)
{
req
.
context
=
ctx
;
next
();
}
return
funcCtx
;
}
http-listener/main.js
View file @
492e6d41
...
@@ -5,7 +5,10 @@ var app = express();
...
@@ -5,7 +5,10 @@ var app = express();
var
bodyParser
=
require
(
'body-parser'
);
var
bodyParser
=
require
(
'body-parser'
);
var
cfg
=
ctx
.
config
;
var
cfg
=
ctx
.
config
;
var
HttpACL
=
ctx
.
getLib
(
'lib/mems/http-acl'
);
var
EvenPub
=
ctx
.
getLib
(
'lib/amqp/event-pub'
);
const
JOBCHANEL
=
'job_trigger'
;
module
.
exports
.
create
=
function
(
cfg
)
module
.
exports
.
create
=
function
(
cfg
)
{
{
...
@@ -16,7 +19,8 @@ module.exports.create = function(cfg)
...
@@ -16,7 +19,8 @@ module.exports.create = function(cfg)
function
HTTPListener
(
cfg
)
function
HTTPListener
(
cfg
)
{
{
this
.
config
=
cfg
;
this
.
config
=
cfg
;
this
.
httpacl
=
HttpACL
.
create
({
'conn'
:
this
.
config
.
memstore
.
url
});
this
.
evp
=
new
EvenPub
({
'url'
:
this
.
config
.
amqp
.
url
,
'name'
:
JOBCHANEL
});
}
}
HTTPListener
.
prototype
.
start
=
function
()
HTTPListener
.
prototype
.
start
=
function
()
...
@@ -31,15 +35,29 @@ HTTPListener.prototype.http_start = function()
...
@@ -31,15 +35,29 @@ HTTPListener.prototype.http_start = function()
var
API_PORT
=
19180
;
var
API_PORT
=
19180
;
app
.
use
(
bodyParser
.
json
({
limit
:
'5mb'
}));
this
.
httpacl
.
update
(
function
(
err
){
if
(
!
err
){
console
.
log
(
'WWW:ACL Update
\
t
\
t[OK]'
);
}
else
{
console
.
log
(
'WWW:ACL Update
\
t
\
t[ERR]'
);
}
});
app
.
use
(
bodyParser
.
json
({
limit
:
'128mb'
}));
app
.
use
(
bodyParser
.
urlencoded
({
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
extended
:
true
}));
}));
var
context
=
require
(
'./lib/http-context'
);
app
.
use
(
context
.
middleware
({
'httpacl'
:
self
.
httpacl
,
'evp'
:
self
.
evp
}));
app
.
use
(
require
(
'./ws'
));
app
.
use
(
require
(
'./ws'
));
app
.
listen
(
API_PORT
,
function
()
{
app
.
listen
(
API_PORT
,
function
()
{
console
.
log
(
'WWW:HTTP START
\
t
\
t[OK]'
);
console
.
log
(
'WWW:HTTP START
\
t
\
t[OK]'
);
});
});
...
...
http-listener/ws/service-main.js
View file @
492e6d41
...
@@ -12,9 +12,12 @@ router.get('/:akey',function (req, res) {
...
@@ -12,9 +12,12 @@ router.get('/:akey',function (req, res) {
var
reqHelper
=
request
.
create
(
req
);
var
reqHelper
=
request
.
create
(
req
);
var
respHelper
=
response
.
create
(
res
);
var
respHelper
=
response
.
create
(
res
);
var
appkey
=
req
.
params
.
akey
;
var
appkey
=
req
.
params
.
akey
;
var
ctx
=
req
.
context
;
respHelper
.
responseOK
({
'status'
:
'OK'
,
'appkey'
:
appkey
});
var
httpacl
=
req
.
context
.
httpacl
;
var
evp
=
req
.
context
.
evp
;
var
j
=
httpacl
.
findJob
(
appkey
,
'get'
);
respHelper
.
responseOK
({
'status'
:
'OK'
,
'appkey'
:
appkey
,
'res'
:
j
});
});
});
module
.
exports
=
router
;
module
.
exports
=
router
;
lib/amqp/event-pub.js
View file @
492e6d41
...
@@ -44,4 +44,11 @@ EventPub.prototype.send = function(topic,msg,cb)
...
@@ -44,4 +44,11 @@ EventPub.prototype.send = function(topic,msg,cb)
});
});
}
}
EventPub
.
prototype
.
close
=
function
(
cb
)
{
var
self
=
this
;
self
.
conn
.
close
(
cb
);
}
module
.
exports
=
EventPub
;
module
.
exports
=
EventPub
;
lib/model/example/message.js
0 → 100644
View file @
492e6d41
//
//--- BSData ---
//
var
bsdata
=
{
'object_type'
:
'bsdata'
,
'data_type'
:
'text,binary,object'
,
'encoding'
:
'base64'
,
'data'
:
'data'
}
//
//--- Storage Service request ---
//
var
storage_write_request
=
{
'object_type'
:
'storage_request'
,
'command'
:
'write'
,
'param'
:
{
'storage_name'
:
'gcs.file.test'
,
'meta'
:
{
'name'
:
'gcs'
},
'data'
:
{
'type'
:
'bsdata'
,
'value'
:
{
'data_type'
:
'string'
,
'data'
:
'AA00FFCC'
}
}
}
}
var
httpdata
=
{
'object_type'
:
'httpdata'
,
'method'
:
'get,post'
,
'data'
:
{}
}
var
job_trigger
=
{
'object_type'
:
'job_trigger'
,
'source'
:
'http_listener'
,
'jobId'
:
'jobid'
,
'option'
:
{},
'input_data'
:
{
'type'
:
'bsdata'
,
'value'
:
{
'data_type'
:
'object'
,
'data'
:
httpdata
}
}
}
test/test.js
View file @
492e6d41
...
@@ -78,24 +78,26 @@ const crypto = require("crypto");
...
@@ -78,24 +78,26 @@ const crypto = require("crypto");
// atext = JSON.stringify(a);
// atext = JSON.stringify(a);
// redis.set('a',atext)
// redis.set('a',atext)
// var HttpACL = ctx.getLib('lib/mems/http-acl');
var
HttpACL
=
ctx
.
getLib
(
'lib/mems/http-acl'
);
//
// var httpacl = HttpACL.create({'conn':'redis://:@lab1.igridproject.info:6379/1'});
//
// httpacl.add({'appkey':'app1','method':'get','jobid':'job1'})
// httpacl.add({'appkey':'app2','method':'get','jobid':'job2'})
// httpacl.add({'appkey':'app1','method':'get','jobid':'job3'})
// httpacl.commit();
//
// httpacl.update(function(err){
// //console.log(httpacl.acl);
// var j = httpacl.findJob('app1','get');
// console.log(j);
// });
var
EvenPub
=
ctx
.
getLib
(
'lib/amqp/event-pub'
);
var
httpacl
=
HttpACL
.
create
({
'conn'
:
'redis://:@bigmaster.igridproject.info:6379/1'
}
);
var
evp
=
new
EvenPub
({
'url'
:
'amqp://lab1.igridproject.info'
,
'name'
:
'topic_logs'
});
httpacl
.
add
({
'appkey'
:
'app1'
,
'method'
:
'get'
,
'jobid'
:
'job1'
})
httpacl
.
add
({
'appkey'
:
'app2'
,
'method'
:
'get'
,
'jobid'
:
'job2'
})
httpacl
.
add
({
'appkey'
:
'app1'
,
'method'
:
'get'
,
'jobid'
:
'job3'
})
httpacl
.
commit
();
evp
.
send
(
'q.test.t1'
,
'kamron aroonrua'
);
httpacl
.
update
(
function
(
err
){
evp
.
send
(
'q.test.t1'
,
'kamron aroonrua aaa'
);
//console.log(httpacl.acl);
var
j
=
httpacl
.
findJob
(
'app1'
,
'get'
);
console
.
log
(
j
);
});
// var EvenPub = ctx.getLib('lib/amqp/event-pub');
//
// var evp = new EvenPub({'url':'amqp://bigmaster.igridproject.info','name':'topic_logs'});
//
// evp.send('q.test.t1','kamron aroonrua');
// evp.send('q.test.t1','kamron aroonrua aaa');
//
// setTimeout(function() { evp.close(function(err){console.log('close');}); }, 1500);
test/test_topic_sub.js
View file @
492e6d41
...
@@ -6,7 +6,7 @@ var amqp = require('amqplib/callback_api');
...
@@ -6,7 +6,7 @@ var amqp = require('amqplib/callback_api');
amqp
.
connect
(
'amqp://
lab1
.igridproject.info'
,
function
(
err
,
conn
)
{
amqp
.
connect
(
'amqp://
bigmaster
.igridproject.info'
,
function
(
err
,
conn
)
{
conn
.
createChannel
(
function
(
err
,
ch
)
{
conn
.
createChannel
(
function
(
err
,
ch
)
{
var
ex
=
'topic_logs'
;
var
ex
=
'topic_logs'
;
...
...
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