Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
be3d2d41d6 | |||
2affa189a7 | |||
8c4c2a552c | |||
eff9c6e6c9 | |||
4c7a373d98 | |||
6b93a2e7ac | |||
9c6487c779 | |||
e3f37f5027 | |||
1152bb1138 | |||
9df7787450 | |||
3e81fdacad | |||
f74da6ff0b | |||
e9d976ad1e | |||
f6d314695a | |||
d35b34f4aa |
24
.gitignore
vendored
24
.gitignore
vendored
@ -1,4 +1,22 @@
|
||||
coverage/
|
||||
node_modules
|
||||
pages/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
|
||||
# custom
|
@ -1,5 +1,5 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
@ -26,6 +26,7 @@ mirror:
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
@ -36,44 +37,35 @@ snyk:
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci node install lts
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
@ -86,19 +78,11 @@ release:
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [codeclimate.json]
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
@ -114,12 +98,15 @@ trigger:
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
image: hosttoday/ht-docker-dbase:npmci
|
||||
services:
|
||||
- docker:stable-dind
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
@ -130,13 +117,3 @@ pages:
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
|
||||
windowsCompatibility:
|
||||
image: stefanscherer/node-windows:10-build-tools
|
||||
stage: metadata
|
||||
script:
|
||||
- npm install & npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- windows
|
||||
allow_failure: true
|
||||
|
@ -1,12 +1,17 @@
|
||||
{
|
||||
"npmts":{
|
||||
"mode":"default",
|
||||
"testConfig": {
|
||||
"parallel": false
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
"npmAccessLevel": "public",
|
||||
"npmRegistryUrl": "registry.npmjs.org"
|
||||
},
|
||||
"gitzone": {
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"gitrepo": "taskbuffer",
|
||||
"shortDescription": "flexible task management. TypeScript ready!",
|
||||
"npmPackagename": "@pushrocks/taskbuffer",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
1518
package-lock.json
generated
1518
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
42
package.json
42
package.json
@ -1,12 +1,13 @@
|
||||
{
|
||||
"name": "@pushrocks/taskbuffer",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.9",
|
||||
"private": false,
|
||||
"description": "flexible task management. TypeScript ready!",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "tstest test/",
|
||||
"build": "echo \"Not needed for now\""
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -26,18 +27,31 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/taskbuffer#readme",
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^3.0.1",
|
||||
"@pushrocks/smartdelay": "^2.0.1",
|
||||
"@pushrocks/smartlog": "^2.0.1",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@types/cron": "^1.3.0",
|
||||
"cron": "^1.3.0",
|
||||
"rxjs": "^6.2.2"
|
||||
"@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/tstest": "^1.0.7",
|
||||
"@pushrocks/tapbundle": "^3.0.1",
|
||||
"@types/node": "^10.5.4"
|
||||
"@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"
|
||||
},
|
||||
"private": true
|
||||
"files": [
|
||||
"ts/*",
|
||||
"ts_web/*",
|
||||
"dist/*",
|
||||
"dist_web/*",
|
||||
"dist_ts_web/*",
|
||||
"assets/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
]
|
||||
}
|
||||
|
77
readme.md
77
readme.md
@ -1,64 +1,22 @@
|
||||
# taskbuffer
|
||||
|
||||
# @pushrocks/taskbuffer
|
||||
flexible task management. TypeScript ready!
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/taskbuffer)
|
||||
[](https://GitLab.com/pushrocks/taskbuffer)
|
||||
[](https://github.com/pushrocks/taskbuffer)
|
||||
[](https://pushrocks.gitlab.io/taskbuffer/)
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/taskbuffer)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/taskbuffer)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/taskbuffer)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/taskbuffer/)
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/pushrocks/taskbuffer/commits/master)
|
||||
[](https://gitlab.com/pushrocks/taskbuffer/commits/master)
|
||||
[](https://www.npmjs.com/package/@pushrocks/taskbuffer)
|
||||
[](https://snyk.io/test/npm/@pushrocks/taskbuffer)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://prettier.io/)
|
||||
|
||||
[](https://GitLab.com/pushrocks/taskbuffer/commits/master)
|
||||
[](https://GitLab.com/pushrocks/taskbuffer/commits/master)
|
||||
[](https://www.npmjs.com/package/taskbuffer)
|
||||
[](https://david-dm.org/pushrocks/taskbuffer)
|
||||
[](https://www.bithound.io/github/pushrocks/taskbuffer/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/taskbuffer)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install taskbuffer --save
|
||||
```
|
||||
|
||||
## Concepts
|
||||
|
||||
### class `Task`
|
||||
|
||||
- A Task in its most simple form is a function that is executed when the task runs.
|
||||
- A Task can have a **preTask** and an **afterTask**
|
||||
(those are run before or after the main function whenever the task is called)
|
||||
- A Task can be buffered.
|
||||
That means it can be called multiple times in a very short time.
|
||||
However execution happens in line:
|
||||
meaning execution of the task's main function is on halt until the previous task call has finished.
|
||||
You can set bufferMax number, which is the max number of buffered task calls.
|
||||
Any additional calls will then be truncated
|
||||
- Task.trigger() and Task.triggerBuffered() always return a Promise
|
||||
which is fullfilled once the related task call has completed.
|
||||
- Task.triggered() is an Observable stream that emits events every time a task call is called and every time a call is completed.
|
||||
- Task is compatible to gulp streams.
|
||||
|
||||
### class `TaskChain`
|
||||
|
||||
- TaskChain extends Task.
|
||||
- Multiple Tasks can be combined in a bigger task using a TaskChain.
|
||||
- While the tasks are async in themselve, TaskChain **runs Tasks serialized** (one after the other)
|
||||
- that means that tasks can rely on each other and
|
||||
|
||||
### class `TaskParallel`
|
||||
|
||||
- TaskParallel extends Task.
|
||||
- like TaskChain, however **tasks run in parallel**
|
||||
- Tasks cannot rely on each other.
|
||||
|
||||
### Usage
|
||||
## Usage
|
||||
|
||||
We highly recommend TypeScript as this module supports **TypeScript intellisense**.
|
||||
|
||||
@ -85,3 +43,10 @@ For further information read the linked docs at the top of this README.
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
|
||||
[](https://push.rocks)
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
|
@ -8,11 +8,8 @@ import * as smartdelay from '@pushrocks/smartdelay';
|
||||
let testTask: taskbuffer.Task;
|
||||
|
||||
let testPreTask = new taskbuffer.Task({
|
||||
taskFunction: function() {
|
||||
let done = smartpromise.defer();
|
||||
taskFunction: async () => {
|
||||
console.log('preTask executed');
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
},
|
||||
preTask: testTask
|
||||
});
|
||||
@ -35,14 +32,14 @@ let task1 = new taskbuffer.Task({
|
||||
|
||||
let task2 = new taskbuffer.Task({
|
||||
name: 'Task 1',
|
||||
taskFunction: () => {
|
||||
let done = smartpromise.defer();
|
||||
taskFunction: async () => {
|
||||
const done = smartpromise.defer();
|
||||
console.log('Task2 started');
|
||||
setTimeout(() => {
|
||||
console.log('Task2 executed');
|
||||
done.resolve();
|
||||
}, 5000);
|
||||
return done.promise;
|
||||
await done.promise;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import taskbuffer = require('../ts/index');
|
||||
|
||||
import * as smartq from 'smartq';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
|
||||
let task1Executed = false;
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -100,7 +100,7 @@ export class Task {
|
||||
if (stateArg === 'locked') {
|
||||
this._state = 'locked';
|
||||
} else {
|
||||
plugins.smartlog.defaultLogger.error('state type ' + stateArg + ' could not be set');
|
||||
plugins.smartlog.defaultLogger.log('error', 'state type ' + stateArg + ' could not be set');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ export class Taskchain extends Task {
|
||||
if (typeof this.taskArray[taskCounter] !== 'undefined') {
|
||||
console.log(this.name + ' running: Task' + this.taskArray[taskCounter].name);
|
||||
this.taskArray[taskCounter].trigger(x).then(x => {
|
||||
plugins.smartlog.defaultLogger.info(this.taskArray[taskCounter].name);
|
||||
plugins.smartlog.defaultLogger.log('info', this.taskArray[taskCounter].name);
|
||||
taskCounter++;
|
||||
iterateTasks(x);
|
||||
});
|
||||
|
@ -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 {
|
||||
|
16
tslint.json
16
tslint.json
@ -1,3 +1,17 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
||||
|
Reference in New Issue
Block a user