Przeglądaj źródła

refactor(core): Move & rename TaskService

Co-located it together in the plugin that it relates to
Michael Bromley 4 miesięcy temu
rodzic
commit
ff939dbda6

+ 1 - 0
packages/core/src/plugin/default-scheduler-plugin/constants.ts

@@ -1,3 +1,4 @@
 export const DEFAULT_SCHEDULER_PLUGIN_OPTIONS = Symbol('DEFAULT_SCHEDULER_PLUGIN_OPTIONS');
 export const DEFAULT_TIMEOUT = 60000;
 export const DEFAULT_MANUAL_TRIGGER_CHECK_INTERVAL = 10000;
+export const loggerCtx = 'DefaultSchedulerPlugin';

+ 3 - 3
packages/core/src/plugin/default-scheduler-plugin/default-scheduler-strategy.ts

@@ -10,10 +10,10 @@ import { TransactionalConnection } from '../../connection';
 import { ProcessContext } from '../../process-context';
 import { ScheduledTask } from '../../scheduler/scheduled-task';
 import { SchedulerStrategy, TaskReport } from '../../scheduler/scheduler-strategy';
-import { TaskService } from '../../service';
 
 import { DEFAULT_SCHEDULER_PLUGIN_OPTIONS } from './constants';
 import { ScheduledTaskRecord } from './scheduled-task-record.entity';
+import { StaleTaskService } from './stale-task.service';
 import { DefaultSchedulerPluginOptions } from './types';
 
 /**
@@ -32,13 +32,13 @@ export class DefaultSchedulerStrategy implements SchedulerStrategy {
     private readonly tasks: Map<string, { task: ScheduledTask; isRegistered: boolean }> = new Map();
     private pluginOptions: DefaultSchedulerPluginOptions;
     private runningTasks: ScheduledTask[] = [];
-    private taskService: TaskService;
+    private taskService: StaleTaskService;
 
     init(injector: Injector) {
         this.connection = injector.get(TransactionalConnection);
         this.pluginOptions = injector.get(DEFAULT_SCHEDULER_PLUGIN_OPTIONS);
         this.injector = injector;
-        this.taskService = injector.get(TaskService);
+        this.taskService = injector.get(StaleTaskService);
 
         const runTriggerCheck =
             injector.get(ConfigService).schedulerOptions.runTasksInWorkerOnly === false ||

+ 2 - 0
packages/core/src/plugin/default-scheduler-plugin/default-scheduler.plugin.ts

@@ -8,6 +8,7 @@ import {
 } from './constants';
 import { DefaultSchedulerStrategy } from './default-scheduler-strategy';
 import { ScheduledTaskRecord } from './scheduled-task-record.entity';
+import { StaleTaskService } from './stale-task.service';
 import { DefaultSchedulerPluginOptions } from './types';
 
 /**
@@ -48,6 +49,7 @@ import { DefaultSchedulerPluginOptions } from './types';
             provide: DEFAULT_SCHEDULER_PLUGIN_OPTIONS,
             useFactory: () => DefaultSchedulerPlugin.options,
         },
+        StaleTaskService,
     ],
     compatibility: '>0.0.0',
 })

+ 3 - 3
packages/core/src/service/services/task.service.ts → packages/core/src/plugin/default-scheduler-plugin/stale-task.service.ts

@@ -5,14 +5,14 @@ import { Cron } from 'croner';
 import { Instrument } from '../../common/instrument-decorator';
 import { Logger } from '../../config';
 import { TransactionalConnection } from '../../connection/transactional-connection';
-import { ScheduledTaskRecord } from '../../plugin/default-scheduler-plugin/scheduled-task-record.entity';
 import { SchedulerService } from '../../scheduler/scheduler.service';
 
-const loggerCtx = 'CleanTaskLocks';
+import { loggerCtx } from './constants';
+import { ScheduledTaskRecord } from './scheduled-task-record.entity';
 
 @Injectable()
 @Instrument()
-export class TaskService {
+export class StaleTaskService {
     constructor(
         private connection: TransactionalConnection,
         private schedulerService: SchedulerService,

+ 0 - 1
packages/core/src/service/index.ts

@@ -59,7 +59,6 @@ export * from './services/stock-level.service';
 export * from './services/stock-location.service';
 export * from './services/stock-movement.service';
 export * from './services/tag.service';
-export * from './services/task.service';
 export * from './services/tax-category.service';
 export * from './services/tax-rate.service';
 export * from './services/user.service';

+ 0 - 2
packages/core/src/service/service.module.ts

@@ -65,7 +65,6 @@ import { StockLevelService } from './services/stock-level.service';
 import { StockLocationService } from './services/stock-location.service';
 import { StockMovementService } from './services/stock-movement.service';
 import { TagService } from './services/tag.service';
-import { TaskService } from './services/task.service';
 import { TaxCategoryService } from './services/tax-category.service';
 import { TaxRateService } from './services/tax-rate.service';
 import { UserService } from './services/user.service';
@@ -107,7 +106,6 @@ const services = [
     TaxRateService,
     UserService,
     ZoneService,
-    TaskService,
 ];
 
 const helpers = [