fix(core): update
This commit is contained in:
parent
e9e4a60fe6
commit
439da1f342
@ -18,8 +18,10 @@ tap.test('should run the task as expected', async () => {
|
||||
myTaskManager.addTask(
|
||||
new taskbuffer.Task({
|
||||
name: 'myTask',
|
||||
bufferMax: 1,
|
||||
buffered: true,
|
||||
taskFunction: async () => {
|
||||
console.log('Task executed!');
|
||||
console.log('Task "myTask" executed!');
|
||||
referenceBoolean = true;
|
||||
taskRunCounter++;
|
||||
if (taskRunCounter === 10) {
|
||||
@ -35,7 +37,7 @@ tap.test('should run the task as expected', async () => {
|
||||
});
|
||||
|
||||
tap.test('should schedule task', async () => {
|
||||
myTaskManager.scheduleTaskByName('myTask', '* * * * * *');
|
||||
myTaskManager.scheduleTaskByName('myTask', '*/10 * * * * *');
|
||||
await taskDone.promise;
|
||||
myTaskManager.descheduleTaskByName('myTask');
|
||||
});
|
||||
|
@ -58,6 +58,7 @@ export class Task {
|
||||
taskArg: Task | TPreOrAfterTaskFunction,
|
||||
optionsArg: { x?: any; touchedTasksArray?: Task[] }
|
||||
) => {
|
||||
// extracts the task in case it is specified as a return value of a function
|
||||
const taskToRun = Task.extractTask(taskArg);
|
||||
const done = plugins.smartpromise.defer();
|
||||
|
||||
|
@ -70,7 +70,15 @@ export class TaskManager {
|
||||
public scheduleTaskByName(taskNameArg: string, cronStringArg: string) {
|
||||
const taskToSchedule = this.getTaskByName(taskNameArg);
|
||||
const cronJob = this.cronJobManager.addCronjob(cronStringArg, async () => {
|
||||
await taskToSchedule.triggerBuffered();
|
||||
console.log(`taskbuffer schedule triggered task >>${taskToSchedule.name}<<`);
|
||||
console.log(
|
||||
`task >>${taskToSchedule.name}<< is ${
|
||||
taskToSchedule.buffered
|
||||
? `buffered with max ${taskToSchedule.bufferMax} buffered calls`
|
||||
: `unbuffered`
|
||||
}`
|
||||
);
|
||||
await taskToSchedule.trigger();
|
||||
});
|
||||
taskToSchedule.cronJob = cronJob;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user