fix(core): update

This commit is contained in:
Philipp Kunz 2019-09-05 11:35:26 +02:00
parent 4c7a373d98
commit eff9c6e6c9
7 changed files with 507 additions and 424 deletions

View File

@ -1,4 +1,4 @@
# gitzone standard
# gitzone ci_default
image: hosttoday/ht-docker-node:npmci
cache:

843
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,20 +27,20 @@
},
"homepage": "https://gitlab.com/pushrocks/taskbuffer#readme",
"dependencies": {
"@pushrocks/lik": "^3.0.4",
"@pushrocks/smartdelay": "^2.0.2",
"@pushrocks/smartlog": "^2.0.9",
"@pushrocks/smartpromise": "^2.0.5",
"@types/cron": "^1.3.0",
"cron": "^1.6.0",
"rxjs": "^6.3.3"
"@pushrocks/lik": "^3.0.11",
"@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartpromise": "^3.0.2",
"@types/cron": "^1.7.1",
"cron": "^1.7.1",
"rxjs": "^6.5.3"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.4",
"@gitzone/tstest": "^1.0.18",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.12.18",
"tslint": "^5.12.1",
"tslint-config-prettier": "^1.17.0"
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^12.7.4",
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0"
}
}

View File

@ -1,11 +1,9 @@
import { expect, tap } from '@pushrocks/tapbundle';
import taskbuffer = require('../ts/index');
import * as smartq from 'smartq';
import * as smartdelay from '@pushrocks/smartdelay';
let task1Executed = false;
let task1 = new taskbuffer.Task({
const task1 = new taskbuffer.Task({
taskFunction: async () => {
await smartdelay.delayFor(2000);
task1Executed = true;
@ -13,7 +11,7 @@ let task1 = new taskbuffer.Task({
});
let task2Executed = false;
let task2 = new taskbuffer.Task({
const task2 = new taskbuffer.Task({
taskFunction: async () => {
await smartdelay.delayFor(2000);
task2Executed = true;
@ -21,7 +19,7 @@ let task2 = new taskbuffer.Task({
});
let task3Executed = false;
let task3 = new taskbuffer.Task({
const task3 = new taskbuffer.Task({
taskFunction: async () => {
await smartdelay.delayFor(2000);
task3Executed = true;
@ -29,7 +27,7 @@ let task3 = new taskbuffer.Task({
});
tap.test('expect run in Parallel', async () => {
let testTaskparallel = new taskbuffer.Taskparallel({
const testTaskparallel = new taskbuffer.Taskparallel({
taskArray: [task1, task2, task3]
});
await testTaskparallel.trigger();

View File

@ -6,7 +6,7 @@ import * as smartdelay from '@pushrocks/smartdelay';
let myTaskManager: taskbuffer.TaskManager;
let taskRunCounter = 0;
let taskDone = smartpromise.defer();
const taskDone = smartpromise.defer();
tap.test('should create an instance of TaskManager', async () => {
myTaskManager = new taskbuffer.TaskManager();

View File

@ -4,9 +4,9 @@ import taskbuffer = require('../ts/index');
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartdelay from '@pushrocks/smartdelay';
let flowTask1 = new taskbuffer.Task({
const flowTask1 = new taskbuffer.Task({
taskFunction: (x: number) => {
let done = smartpromise.defer();
const done = smartpromise.defer();
console.log('flowTask1');
console.log(x);
done.resolve(x);
@ -14,9 +14,9 @@ let flowTask1 = new taskbuffer.Task({
}
});
let flowTaskBuffered = new taskbuffer.Task({
const flowTaskBuffered = new taskbuffer.Task({
taskFunction: (x: number) => {
let done = smartpromise.defer();
const done = smartpromise.defer();
console.log('flowTask1');
console.log(x);
done.resolve(x);
@ -26,9 +26,9 @@ let flowTaskBuffered = new taskbuffer.Task({
bufferMax: 1
});
let flowTask2 = new taskbuffer.Task({
const flowTask2 = new taskbuffer.Task({
taskFunction: (x: number) => {
let done = smartpromise.defer();
const done = smartpromise.defer();
console.log('flowTask2');
console.log(x);
done.resolve(x);
@ -37,27 +37,27 @@ let flowTask2 = new taskbuffer.Task({
preTask: flowTask1
});
let flowTask3 = new taskbuffer.Taskchain({
const flowTask3 = new taskbuffer.Taskchain({
taskArray: [flowTask1, flowTask2]
});
tap.test('should let a value flow through a task', async () => {
let result = await flowTask1.trigger(12);
const result = await flowTask1.trigger(12);
expect(result).to.equal(12);
});
tap.test('expect values to flow between tasks', async () => {
let result = await flowTask2.trigger(12);
const result = await flowTask2.trigger(12);
expect(result).to.equal(12);
});
tap.test('expect values to flow between tasks when buffered', async () => {
let result = await flowTaskBuffered.trigger(12);
const result = await flowTaskBuffered.trigger(12);
expect(result).to.equal(12);
});
tap.test('expect values to flow between tasks in Taskchain', async () => {
let result = await flowTask3.trigger(12);
const result = await flowTask3.trigger(12);
expect(result).to.equal(12);
});

View File

@ -5,7 +5,7 @@ import { Task } from './taskbuffer.classes.task';
import { Objectmap } from '@pushrocks/lik';
export class TaskManager {
taskMap = new plugins.lik.Objectmap<Task>();
public taskMap = new plugins.lik.Objectmap<Task>();
private cronJobMap = new plugins.lik.Objectmap<ICronJob>();
constructor() {
// nothing here
@ -15,7 +15,7 @@ export class TaskManager {
* checks if a task is already present
* @param taskNameArg
*/
getTaskByName(taskNameArg): Task {
public getTaskByName(taskNameArg): Task {
return this.taskMap.find(itemArg => {
return itemArg.name === taskNameArg;
});
@ -25,7 +25,7 @@ export class TaskManager {
* adds a Task to the TaskManager
* @param taskArg
*/
addTask(taskArg: Task): void {
public addTask(taskArg: Task): void {
if (!taskArg.name) {
throw new Error('taskArg needs a name to be added to taskManager');
}
@ -37,9 +37,9 @@ export class TaskManager {
* @param taskArg
* @param cronStringArg
*/
addAndScheduleTask(taskArg: Task, cronStringArg: string) {
public addAndScheduleTask(taskArg: Task, cronStringArg: string) {
this.addTask(taskArg);
let taskName = taskArg.name;
const taskName = taskArg.name;
this.scheduleTaskByName(taskName, cronStringArg);
}
@ -47,8 +47,8 @@ export class TaskManager {
* triggers a task in the TaskManagerByName
* @param taskNameArg
*/
triggerTaskByName(taskNameArg: string): Promise<any> {
let taskToTrigger = this.getTaskByName(taskNameArg);
public triggerTaskByName(taskNameArg: string): Promise<any> {
const taskToTrigger = this.getTaskByName(taskNameArg);
if (!taskToTrigger) {
throw new Error(`There is no task with the name of ${taskNameArg}`);
}
@ -59,9 +59,9 @@ export class TaskManager {
* schedules the task by name
* @param taskNameArg
*/
scheduleTaskByName(taskNameArg: string, cronStringArg: string) {
let taskToSchedule = this.getTaskByName(taskNameArg);
let job = new plugins.cron.CronJob({
public scheduleTaskByName(taskNameArg: string, cronStringArg: string) {
const taskToSchedule = this.getTaskByName(taskNameArg);
const job = new plugins.cron.CronJob({
cronTime: cronStringArg,
onTick: () => {
this.triggerTaskByName(taskNameArg);
@ -75,8 +75,8 @@ export class TaskManager {
});
}
descheduleTaskByName(taskNameArg: string) {
let descheduledCron = this.cronJobMap.findOneAndRemove(itemArg => {
public descheduleTaskByName(taskNameArg: string) {
const descheduledCron = this.cronJobMap.findOneAndRemove(itemArg => {
return itemArg.taskNameArg === taskNameArg;
});
descheduledCron.job.stop();
@ -85,7 +85,7 @@ export class TaskManager {
* returns all schedules of a specific task
* @param taskNameArg
*/
getSchedulesForTaskName(taskNameArg: string) {}
public getSchedulesForTaskName(taskNameArg: string) {}
}
export interface ICronJob {