Skip to content

Latest commit

 

History

History
158 lines (95 loc) · 5.79 KB

api.md

File metadata and controls

158 lines (95 loc) · 5.79 KB

BootMe

API


Task

Represent a task object

Config : Object

Return the current task config

setName(string: name) : Task

Set the task name

addHook(string: ['onInit', 'onBefore', 'onAfter'], async function: handler) : Task

Create a new hook

setAction(async function: handler) : Task

Set the main task action

setConfig([Object, async function, function]: config) : [Task, Promise]

Set the task config

setInit(async function: handler) : Task

Set the initialization function. It's one-time shortcut for addHook('onInit', fn)

setRollback(async function: handler) : Task

Set the initialization function. It's one-time shortcut for addHook('onRollback', fn)

Registry

Represent the centric task registry

addTask(Task: task): void

Add a new task to the registry.

setRef(String: taskName, String: key, Any: value)

Set the refs property of the task config to configure task dependencies

setConfig(String: taskName, Object: value)

Merge the value to the task config

shareConfig(Object: value)

Configure a shared config from which all tasks inherit

addHook(String: taskName, string: ['onInit', 'onBefore', 'onAfter'], async function: handler) : Task

Add a hook to the task

Pipeline

Represent pipeline to execute all tasks

execute()

Run the pipeline. We don't provide a finish callback because it's a queue and is changed at runtime.

getValue(String: taskName)

Try to get the value from the result of this task, otherwise the value is taken from the task config. That's the reason to provide always a default value in the task config.

{
  "a": 1,
  "refs": {
    "a": "previousTaskName"
  }
}

rollback() : Promise

The whole pipeline is rollbacked and all onRollback hooks from all tasks are called.

restore() : Promise

The whole pipeline is restored and all onRollback hooks from all tasks are called. The difference between a rollback and restore is that a restore is intentional and therefore no onBefore, onAfter hooks are called only onInit.

hasError(String: taskName) : Boolean

Check if a task has thrown an error

hasResult(String: taskName) : Boolean

Check if a task has respond with a truthy value

onTaskStart(async function: handler)

Add a global onTaskStart hook. This hook is executed before a task is executed.

onTaskEnd(async function: handler)

Add a global onTaskEnd hook. This hook is executed after a task was executed.

onTaskRollback(async function: handler)

Add a global onTaskRollback hook. This hook is executed after a complete rollback was proceed.

State

State provide an api to add additional tasks and access to the current pipeline instance.

addJob(async function: handler)

Execute a job. A job is a single function and is excuted in creation order. The parent task is waiting before all sub-jobs are done.

addTask(Task: handler)

Execute a task. The task is excuted in creation order. The parent task is waiting before all sub-tasks are done.

getValue(String: taskName)

This is shortcut for getValue(String: taskName)