1 |
|
2 | var d = require("debug")("raptorjs:workflow")
|
3 | const Base = require("./Base")
|
4 |
|
5 | class Workflow extends Base {
|
6 |
|
7 | constructor (container) {
|
8 | super(container)
|
9 | this.states = {
|
10 | died: 0,
|
11 | stopped: 10,
|
12 | started: 20
|
13 | }
|
14 | }
|
15 |
|
16 | start(id, args) {
|
17 | d("Start workflow instance %s", id)
|
18 | return this.getClient().post(this.route("WORKFLOW_START", id), args || {})
|
19 | }
|
20 |
|
21 | stop(id) {
|
22 | d("Stop workflow instance %s", id)
|
23 | return this.getClient().post(this.route("WORKFLOW_STOP", id))
|
24 | }
|
25 |
|
26 | create(workflow) {
|
27 | d("Create workflow instance ", workflow)
|
28 | return this.getClient().post(this.route("WORKFLOW_CREATE"), workflow)
|
29 | }
|
30 |
|
31 | delete(id) {
|
32 | d("Delete workflow instance %s", id)
|
33 | return this.getClient().delete(this.route("WORKFLOW_DELETE", id))
|
34 | }
|
35 |
|
36 | get(id) {
|
37 | d("Get workflow %s", id)
|
38 | return this.getClient().get(this.route("WORKFLOW_GET", id))
|
39 | }
|
40 |
|
41 | list() {
|
42 | d("List workflows")
|
43 | return this.getClient().get(this.route("WORKFLOW_LIST"))
|
44 | }
|
45 |
|
46 | }
|
47 |
|
48 | module.exports = Workflow
|