Wrap cache clients in a Backstage-specific CacheClient to handle key normalization and error handling + allow us the freedom to move away from cache-manager in the future if necessary.

Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
Eric Peterson
2021-05-02 15:18:06 +02:00
parent 93ff8275dd
commit 6e0be00e1d
6 changed files with 137 additions and 10 deletions
+2 -1
View File
@@ -60,11 +60,12 @@ function makeCreateEnv(config: Config) {
root.info(`Created UrlReader ${reader}`);
const databaseManager = SingleConnectionDatabaseManager.fromConfig(config);
const cache = CacheManager.fromConfig(config);
const cacheManager = CacheManager.fromConfig(config);
return (plugin: string): PluginEnvironment => {
const logger = root.child({ type: 'plugin', plugin });
const database = databaseManager.forPlugin(plugin);
const cache = cacheManager.forPlugin(plugin);
return { logger, cache, database, config, reader, discovery };
};
}
+2 -2
View File
@@ -17,7 +17,7 @@
import { Logger } from 'winston';
import { Config } from '@backstage/config';
import {
CacheManager,
PluginCacheManager,
PluginDatabaseManager,
PluginEndpointDiscovery,
UrlReader,
@@ -25,7 +25,7 @@ import {
export type PluginEnvironment = {
logger: Logger;
cache: CacheManager;
cache: PluginCacheManager;
database: PluginDatabaseManager;
config: Config;
reader: UrlReader;