@tailored-apps/taskrunner

1.0.1 • Public • Published

@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

Name Default Value Description
task the function which should be executed
interval the interval, in seconds, between the task should run again
logger any valid logger, like winston
friendlyName PeriodicTask an human readable name for the task, which will be shown in the logs
logLevel info selector 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

Property Format Value
error boolean if the task failed
task string the friendly task name
start date execution start date
end date execution end date
elapsed number the duration of the task, in seconds

Readme

Keywords

Package Sidebar

Install

npm i @tailored-apps/taskrunner

Weekly Downloads

26

Version

1.0.1

License

ISC

Unpacked Size

47.5 kB

Total Files

6

Last publish

Collaborators

  • dabls
  • tailoredapps