feat: add memory cache to boost performance (#2620)

* feat: add memory cache to boost performance

* fix: tests

* fix: logging

* fix: missing commented stuff
This commit is contained in:
Jérémy M
2023-11-21 18:29:31 +01:00
committed by GitHub
parent 74e0122294
commit dd125ddfcc
27 changed files with 458 additions and 17 deletions

View File

@ -0,0 +1,11 @@
export class WorkspaceMigrationAppliedEvent {
private readonly _workspaceId: string;
constructor(worskapceId: string) {
this._workspaceId = worskapceId;
}
get workspaceId(): string {
return this._workspaceId;
}
}

View File

@ -0,0 +1,3 @@
export enum WorkspaceMigrationEvents {
MigrationApplied = '@workspace/migration-applied',
}

View File

@ -1,4 +1,5 @@
import { Injectable } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import {
QueryRunner,
@ -17,6 +18,8 @@ import {
WorkspaceMigrationColumnCreate,
WorkspaceMigrationColumnRelation,
} from 'src/metadata/workspace-migration/workspace-migration.entity';
import { WorkspaceMigrationEvents } from 'src/workspace/workspace-migration-runner/events/workspace-migration-events';
import { WorkspaceMigrationAppliedEvent } from 'src/workspace/workspace-migration-runner/events/workspace-migration-applied.event';
import { customTableDefaultColumns } from './utils/custom-table-default-column.util';
@ -25,6 +28,7 @@ export class WorkspaceMigrationRunnerService {
constructor(
private readonly workspaceDataSourceService: WorkspaceDataSourceService,
private readonly workspaceMigrationService: WorkspaceMigrationService,
private readonly eventEmitter: EventEmitter2,
) {}
/**
@ -78,6 +82,12 @@ export class WorkspaceMigrationRunnerService {
await queryRunner.release();
// Emit event when migration is applied
this.eventEmitter.emit(
WorkspaceMigrationEvents.MigrationApplied,
new WorkspaceMigrationAppliedEvent(workspaceId),
);
return flattenedPendingMigrations;
}