fix(core): Change VariablesService to DI and use caching (#6827)
* support redis cluster * cleanup, fix config schema * set default prefix to bull * initial commit * improve logging * improve types and refactor * list support and refactor * fix redis service and tests * add comment * add redis and cache prefix * use injection * lint fix * clean schema comments * improve naming, tests, cluster client * merge master * cache returns unknown instead of T * update cache service, tests and doc * remove console.log * VariablesService as DI, add caching, fix tests * do not cache null or undefined values * import fix * more DI and remove collections * fix merge * lint fix * rename to ~Cached * fix test for CI * fix ActiveWorkflowRunner test
This commit is contained in:
committed by
GitHub
parent
41d8a18d47
commit
659ca26fe7
@@ -6,6 +6,7 @@ import * as ResponseHelper from '@/ResponseHelper';
|
||||
import type { VariablesRequest } from '@/requests';
|
||||
import { VariablesService } from './variables.service';
|
||||
import { EEVariablesController } from './variables.controller.ee';
|
||||
import Container from 'typedi';
|
||||
|
||||
export const variablesController = express.Router();
|
||||
|
||||
@@ -28,7 +29,7 @@ variablesController.use(EEVariablesController);
|
||||
variablesController.get(
|
||||
'/',
|
||||
ResponseHelper.send(async () => {
|
||||
return VariablesService.getAll();
|
||||
return Container.get(VariablesService).getAllCached();
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -43,7 +44,7 @@ variablesController.get(
|
||||
'/:id(\\w+)',
|
||||
ResponseHelper.send(async (req: VariablesRequest.Get) => {
|
||||
const id = req.params.id;
|
||||
const variable = await VariablesService.get(id);
|
||||
const variable = await Container.get(VariablesService).getCached(id);
|
||||
if (variable === null) {
|
||||
throw new ResponseHelper.NotFoundError(`Variable with id ${req.params.id} not found`);
|
||||
}
|
||||
@@ -69,7 +70,7 @@ variablesController.delete(
|
||||
});
|
||||
throw new ResponseHelper.AuthError('Unauthorized');
|
||||
}
|
||||
await VariablesService.delete(id);
|
||||
await Container.get(VariablesService).delete(id);
|
||||
|
||||
return true;
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user