Add condiotnal task execution
Tenant can specify on which env task should be executed
MODIFY
src/async-task/TenantAsyncTask.ts
src/async-task/TenantAsyncTask.ts
@@ -12,6 +12,8 @@ const MODULE_NAME = 'TenantAsyncTask';
export default abstract class TenantAsyncTask extends AbstractAsyncTask {
protected async executeAsyncTask(): Promise<void> {
+ // Current task environement
+ const currentTaskEnv = process.env.TASK_ENV || 'FARGATE_SAP_PRD'; // Environement is not set in Fargate
// Get the Tenants
const tenants = await TenantStorage.getTenants({}, Constants.DB_PARAMS_MAX_LIMIT);
// Process them
@@ -21,6 +23,11 @@ export default abstract class TenantAsyncTask extends AbstractAsyncTask {
// Ignore this tenant
continue;
}
+ // Check if tenant task needs to run on a specific env
+ if (tenant.taskExecutionEnv && tenant.taskExecutionEnv !== currentTaskEnv) {
+ // Ignore execution on this environement
+ continue;
+ }
const tenantCorrelationID = Utils.generateShortNonUniqueID();
const startTimeInTenant = moment();
await Logging.logDebug({

MODIFY
src/scheduler/TenantSchedulerTask.ts
src/scheduler/TenantSchedulerTask.ts
@@ -12,6 +12,8 @@ const MODULE_NAME = 'TenantSchedulerTask';
export default abstract class TenantSchedulerTask extends SchedulerTask {
public async processTask(config: TaskConfig): Promise<void> {
+ // Current task environement
+ const currentTaskEnv = process.env.TASK_ENV || 'FARGATE_SAP_PRD'; // Environement is not set in Fargate
// Get the Tenants
const tenants = await TenantStorage.getTenants({}, Constants.DB_PARAMS_MAX_LIMIT);
// Process them
@@ -21,6 +23,11 @@ export default abstract class TenantSchedulerTask extends SchedulerTask {
// Ignore this tenant
continue;
}
+ // Check if tenant task needs to run on a specific environement
+ if (tenant.taskExecutionEnv && tenant.taskExecutionEnv !== currentTaskEnv) {
+ // Ignore execution on this environement
+ continue;
+ }
const tenantCorrelationID = Utils.generateShortNonUniqueID();
const startTimeInTenant = moment();
await Logging.logDebug({

MODIFY
src/types/Tenant.ts
src/types/Tenant.ts
@@ -11,6 +11,7 @@ export default interface Tenant extends CreatedUpdatedProps {
components: TenantComponent;
redirectDomain?: string;
idleMode?: boolean // Prevents batch and async tasks executions when moving the tenant to a different cloud infrastructure provider
+ taskExecutionEnv?: string; // Environement on which tasks should be executed
}
export interface TenantComponent {

Add condiotnal task execution

- Tenant can specify on which env task should be executed