1.0.1 • Published 4 years ago

@tailored-apps/taskrunner v1.0.1

Weekly downloads
14
License
ISC
Repository
gitlab
Last release
4 years ago

@tailored-apps/taskrunner

js-standard-style

@tailored-apps/taskrunner is a simple class which helps running and queueing background tasks. If you run multiple tasks at the same time, the runner take care that only once is running and all others will be locally queued. This is as well part of the api-skeleton-2.

Installation and Updating

npm install @tailored-apps/taskrunner

Usage

import Taskrunner from '@tailored-apps/taskrunner'

const task = new Taskrunner(task, interval, logger, friendlyName, logLevel)
task.run()

Options

NameDefault ValueDescription
taskthe function which should be executed
intervalthe interval, in seconds, between the task should run again
loggerany valid logger, like winston
friendlyNamePeriodicTaskan human readable name for the task, which will be shown in the logs
logLevelinfoselector of which kind of logs should be created by the taskrunner

Statistics

If you want to save task statics, for example in your selected database, you are able to extend taskrunner and overwrite the saveStat (stats) function.

import Taskrunner from '@tailored-apps/taskrunner'

class ExtendedTaskrunner extends Taskrunner {
	saveStats (stats) {
    	// add your prefered way to save task statistics here
    }
}

export default ExtendedTaskrunner

stats

PropertyFormatValue
errorbooleanif the task failed
taskstringthe friendly task name
startdateexecution start date
enddateexecution end date
elapsednumberthe duration of the task, in seconds
1.0.1

4 years ago

1.0.0

4 years ago