coretraffic/ts/coretraffic.classes.taskmanager.ts

36 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2024-05-15 08:10:41 +00:00
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() {}
}