fix: add config reload flags to the state middleware

This commit is contained in:
Sérgio Salgado 2022-01-19 02:13:02 +00:00
parent cfb360ab4e
commit 5945f9d31b
3 changed files with 20 additions and 14 deletions

View file

@ -18,6 +18,7 @@ const util = require('util')
const db = require('./db')
const state = require('./middlewares/state')
const processBatches = require('./tx-batching-processing')
const { getOperatorId } = require('./operator')
const INCOMING_TX_INTERVAL = 30 * T.seconds
const LIVE_INCOMING_TX_INTERVAL = 5 * T.seconds
@ -98,12 +99,14 @@ function reload (schema) {
store.set('schema', schema)
// set asyncLocalStorage so settingsLoader loads settings for the right schema
return asyncLocalStorage.run(store, () => {
return settingsLoader.loadLatest().then(settings => {
const pi = plugins(settings)
cachedVariables.set(schema, { settings, pi, isReloading: false })
logger.debug(`Settings for schema '${schema}' reloaded in poller`)
return updateAndLoadSanctions()
})
return Promise.all([settingsLoader.loadLatest(), getOperatorId('middleware')])
.then(([settings, operatorId]) => {
const pi = plugins(settings)
cachedVariables.set(schema, { settings, pi, isReloading: false })
state.needsSettingsReload[operatorId.operatorId] = true
logger.debug(`Settings for schema '${schema}' reloaded in poller`)
return updateAndLoadSanctions()
})
})
}