2017-04-11 22:05:43 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const toobusy = require('toobusy-js')
|
|
|
|
|
2020-01-04 22:30:23 +00:00
|
|
|
const config = require('../config')
|
|
|
|
const response = require('../response')
|
2017-04-11 22:05:43 +00:00
|
|
|
|
2019-07-28 11:56:55 +00:00
|
|
|
toobusy.maxLag(config.responseMaxLag)
|
2019-07-18 04:48:40 +00:00
|
|
|
|
2017-04-11 22:05:43 +00:00
|
|
|
module.exports = function (req, res, next) {
|
|
|
|
if (toobusy()) {
|
2020-02-26 03:26:56 +00:00
|
|
|
response.errorServiceUnavailable(req, res)
|
2017-04-11 22:05:43 +00:00
|
|
|
} else {
|
|
|
|
next()
|
|
|
|
}
|
|
|
|
}
|