rule.js 642 Bytes
const {rule} = require('./model');

const whiteList = [];
const blackList = [];

rule('user.ip.router', {}, async({user, resource, metrics}, next) => {
    const qps = await metrics.qps(user.ip({
        excludes: whiteList
    }), resource.all({
        includes: blackList,
        excludes: whiteList
    }));

    if (qps > 200) {
    } else {
    }

    return next();
});

rule('user.ip.', {}, async({user, resource, metrics}, next) => {
    const qps = await metrics.qps(user.ip({
        excludes: whiteList
    }), resource.all({
        excludes: whiteList
    }));

    if (qps > 2000) {
    } else {
    }

    return next();
});