do not create duplicate db connection pools in the old backend
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
---
|
||||
'@backstage/create-app': patch
|
||||
---
|
||||
|
||||
Updated the backend template to no longer create duplicate connection pools to plugins that use the task scheduler.
|
||||
|
||||
To apply this change in your own repository, perform the following small update:
|
||||
|
||||
```diff
|
||||
// in packages/backend/src/index.ts
|
||||
- const taskScheduler = TaskScheduler.fromConfig(config);
|
||||
+ const taskScheduler = TaskScheduler.fromConfig(config, { databaseManager });
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-common': patch
|
||||
---
|
||||
|
||||
Minor internal refactor
|
||||
@@ -56,13 +56,14 @@ export type DatabaseManagerOptions = {
|
||||
/**
|
||||
* Manages database connections for Backstage backend plugins.
|
||||
*
|
||||
* @public
|
||||
* @remarks
|
||||
*
|
||||
* The database manager allows the user to set connection and client settings on
|
||||
* a per pluginId basis by defining a database config block under
|
||||
* `plugin.<pluginId>` in addition to top level defaults. Optionally, a user may
|
||||
* set `prefix` which is used to prefix generated database names if config is
|
||||
* not provided.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class DatabaseManager {
|
||||
/**
|
||||
@@ -105,17 +106,9 @@ export class DatabaseManager {
|
||||
pluginMetadata: PluginMetadataService;
|
||||
},
|
||||
): PluginDatabaseManager {
|
||||
const _this = this;
|
||||
|
||||
return {
|
||||
getClient(): Promise<Knex> {
|
||||
return _this.getDatabase(pluginId, deps);
|
||||
},
|
||||
migrations: {
|
||||
skip: false,
|
||||
..._this.options?.migrations,
|
||||
},
|
||||
};
|
||||
const getClient = () => this.getDatabase(pluginId, deps);
|
||||
const migrations = { skip: false, ...this.options?.migrations };
|
||||
return { getClient, migrations };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,7 +93,7 @@ function makeCreateEnv(config: Config) {
|
||||
});
|
||||
const databaseManager = DatabaseManager.fromConfig(config, { logger: root });
|
||||
const cacheManager = CacheManager.fromConfig(config);
|
||||
const taskScheduler = TaskScheduler.fromConfig(config);
|
||||
const taskScheduler = TaskScheduler.fromConfig(config, { databaseManager });
|
||||
const identity = DefaultIdentityClient.create({
|
||||
discovery,
|
||||
});
|
||||
|
||||
@@ -39,7 +39,7 @@ function makeCreateEnv(config: Config) {
|
||||
const cacheManager = CacheManager.fromConfig(config);
|
||||
const databaseManager = DatabaseManager.fromConfig(config, { logger: root });
|
||||
const tokenManager = ServerTokenManager.noop();
|
||||
const taskScheduler = TaskScheduler.fromConfig(config);
|
||||
const taskScheduler = TaskScheduler.fromConfig(config, { databaseManager });
|
||||
|
||||
const identity = DefaultIdentityClient.create({
|
||||
discovery,
|
||||
|
||||
Reference in New Issue
Block a user