coretraffic/ts/coretraffic.classes.taskmanager.ts
2024-05-15 10:10:41 +02:00

36 lines
1.2 KiB
TypeScript

import * as plugins from './coretraffic.plugins.js';
import { CoreTraffic } from './coretraffic.classes.coretraffic.js';
import { logger } from './coretraffic.logging.js';
export class CoretrafficTaskManager {
public coretrafficRef: CoreTraffic;
public taskmanager: plugins.taskbuffer.TaskManager;
/**
* a task to run setup routing, runs buffered
*/
public setupRoutingTask: plugins.taskbuffer.Task;
constructor(coretrafficRefArg: CoreTraffic) {
this.coretrafficRef = coretrafficRefArg;
this.taskmanager = new plugins.taskbuffer.TaskManager();
this.setupRoutingTask = new plugins.taskbuffer.Task({
buffered: true,
bufferMax: 2,
taskFunction: async (reverseConfigs: plugins.lointCloudly.traffic.IReverseProxyConfig[]) => {
console.log('this is what got to the task:');
console.log(reverseConfigs);
logger.log('info', `routing setup task triggered`);
logger.log('info', `Found ${reverseConfigs.length} host reverse configs!`);
logger.log('info', `trying to deploy host candidates now`);
await this.coretrafficRef.networkProxy.updateProxyConfigs(reverseConfigs);
},
});
}
public async start() {}
public async stop() {}
}