Move flip cache debug service into [debug] (#3057)

Close #2636
This commit is contained in:
Paul Melnikow
2019-02-20 18:43:27 -05:00
committed by GitHub
parent a4bd3f5fd6
commit c770a43dd8
4 changed files with 26 additions and 45 deletions

View File

@@ -3,6 +3,7 @@
const { NonMemoryCachingBaseService } = require('..')
const serverStartTime = new Date(new Date().toGMTString())
let bitFlip = false
module.exports = class Debug extends NonMemoryCachingBaseService {
static get category() {
@@ -19,7 +20,7 @@ module.exports = class Debug extends NonMemoryCachingBaseService {
static get route() {
return {
base: 'debug',
pattern: ':which(time|starttime)',
pattern: ':which(time|starttime|flip)',
}
}
@@ -35,6 +36,22 @@ module.exports = class Debug extends NonMemoryCachingBaseService {
label: 'start time',
message: new Date(serverStartTime).toUTCString(),
}
// For production cache debugging.
case 'flip':
bitFlip = !bitFlip
if (bitFlip) {
return {
label: 'flip',
message: 'on',
color: 'brightgreen',
}
} else {
return {
label: 'flip',
message: 'off',
color: 'red',
}
}
}
}
}

View File

@@ -7,3 +7,11 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('start time')
.get('/starttime.json')
.expectJSONTypes({ name: 'start time', value: Joi.date().required() })
t.create('Flip: first request')
.get('/flip.json')
.expectJSON({ name: 'flip', value: 'on' })
t.create('Flip: second request')
.get('/flip.json')
.expectJSON({ name: 'flip', value: 'off' })