Skip to content

workflow

axios edited this page Jan 26, 2021 · 5 revisions

Get details from the code.

Usage

  • operator.js
'use strict';

async function a(context) {
  console.log('a');
}

async function b(context) {
  console.log('b');
}

async function c(context) {
  console.log('c');
}

module.exports = {
  a, b, c
};
  • work.js
'use strict';

const operator = require('./operator');
const { Workflow } = require('@axiosleo/cli-tool');

const workflow = new Workflow(operator);
workflow.start({
  workflows: [
    'a',
    'b',
    'c',
  ]
}).then((context) => {
  console.log(context);
}).catch((context) => {
  console.log(context);
});

Context demo

  • success
context = {
  workflows: [ 'a', 'b', 'c' ],
  success: true,
  curr: {},
  step_data: {
    a: {
      workflow: 'a',
      start: 1611663346927,
      end: 1611663346936,
      success: true
    },
    b: {
      workflow: 'b',
      start: 1611663346936,
      end: 1611663346936,
      success: true
    },
    c: {
      workflow: 'c',
      start: 1611663346936,
      end: 1611663346936,
      success: true
    }
  }
}
  • failed
context = {
  workflows: [ 'a', 'b', 'c' ],
  success: false,
  curr: {
    workflow: 'error',
    start: 1611664311892,
    end: 1611664311892,
    error: Error instance
  },
  step_data: {
    a: {
      workflow: 'a',
      start: 1611664311880,
      end: 1611664311891,
      success: true
    },
    b: {
      workflow: 'b',
      start: 1611664311891,
      end: 1611664311891,
      success: true
    },
    c: {
      workflow: 'c',
      start: 1611664311891,
      end: 1611664311892,
      success: false,
      error: Error instance
    }
  }
}

Clone this wiki locally