Commit f2ba49cd authored by project's avatar project

--no commit message

--no commit message
parent a9ab72aa
......@@ -56,12 +56,6 @@ CronList.prototype.clean = function()
CronList.prototype.update = function(cb)
{
var self=this;
// this.mem.get(PREFIX, function (err, result) {
// if(!err && result){
// self.list = JSON.parse(result);
// }
// cb(err);
// });
self.list = [];
self.mem.hgetall(KEYS,function (err,res){
if(!err && res){
......@@ -81,6 +75,13 @@ CronList.prototype.update = function(cb)
cb(err);
});
// this.mem.get(PREFIX, function (err, result) {
// if(!err && result){
// self.list = JSON.parse(result);
// }
// cb(err);
// });
}
CronList.prototype.commit = function(cb)
......
var Redis = require('redis');
const PREFIX = 'bs:http:acl';
const KEYS = 'bs:regis:triggers';
module.exports.create = function(cfg)
{
return new HttpACL(cfg);
}
module.exports.mkACL = function(appkey,method,jobid,opt)
module.exports.mkACL = mkACL;
function mkACL(appkey,method,jobid,opt)
{
var a = {
'appkey' : appkey,
......@@ -54,25 +56,46 @@ HttpACL.prototype.clean = function()
HttpACL.prototype.update = function(cb)
{
var self=this;
this.mem.get(PREFIX, function (err, result) {
if(!err && result){
self.clean()
self.mem.hgetall(KEYS,function (err,res){
if(!err && res){
self.acl = JSON.parse(result);
var ks = Object.keys(res);
for(var i=0;i<ks.length;i++)
{
var k = ks[i];
var trigger = JSON.parse(res[k]);
if(trigger.type == 'http')
{
var acl = mkACL(trigger.appkey,trigger.method,trigger.job_id);
self.add(acl);
}
}
}
cb(err);
});
}
HttpACL.prototype.commit = function(cb)
{
var stracl = JSON.stringify(this.acl);
this.mem.set(PREFIX,stracl);
if(typeof cb == 'function'){
cb();
}
// this.mem.get(PREFIX, function (err, result) {
// if(!err && result){
//
// self.acl = JSON.parse(result);
// }
// cb(err);
// });
}
// HttpACL.prototype.commit = function(cb)
// {
// var stracl = JSON.stringify(this.acl);
// this.mem.set(PREFIX,stracl);
//
// if(typeof cb == 'function'){
// cb();
// }
// }
HttpACL.prototype.findJob= function(appkey,method)
{
var jobs = [];
......
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