Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgerlag committed Jul 11, 2019
1 parent a73792d commit 287e660
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/*.user
/.vs
/.idea
2 changes: 1 addition & 1 deletion docs/samples/01-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ or
POST /api/definition
Content-Type: application/json
```
```yml
```json
{
"Id": "Hello1",
"Steps": [
Expand Down
62 changes: 58 additions & 4 deletions docs/samples/02-primitives.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,17 @@ Steps:

Use the `WaitFor` step type to pause your workflow and wait for an external event.

The following example will wait for an external event of name `my-event` with a key of `5`. You can of course, choose a name and key based on data in the custom data object of your workflow instance, using a Python expression.

```yml
Id: waitfor-test
Steps:
- Id: Step1
StepType: WaitFor
NextStepId: Step2
Inputs:
EventName: '...'
EventKey: '...'
EventName: '"my-event"'
EventKey: '5'
Outputs:
EventData: step.EventData
- Id: Step2
Expand All @@ -251,5 +253,57 @@ Steps:
Message: 'data.EventData'
```

TODO: Event API
...
We can then use the event API to publish an event of a given name and key so that all workflows that are listening for it will be notified and recieve any data associated with the event.

First, let's start a new workflow instance.
```
POST /api/workflow/waitfor-test
{}
```
Response:
```json
{
"workflowId": "5d274481ec9ce50001bc9c34",
"data": {},
"definitionId": "waitfor-test",
"version": 2,
"status": "Runnable",
"reference": null,
"startTime": "2019-07-11T14:15:29.86Z",
"endTime": null
}
```

Then, let's publish an event with a name of `my-event` and a key of 5. We'll also pass the string `"test"` as data on the event.

```
POST /api/event/my-event/5
```
```
"test"
```

This will notify all workflows that are waiting on this particular name/key combo and pass `"test"` to them. The outcome of this particular example will store the data from the event in the workflow's own internal data object.

So, if we query the status of the workflow, we will see:
```
GET /api/workflow/5d274481ec9ce50001bc9c34
```
Response:
```json
{
"workflowId": "5d274481ec9ce50001bc9c34",
"data": {
"EventData": "test"
},
"definitionId": "waitfor-test",
"version": 2,
"status": "Complete",
"reference": null,
"startTime": "2019-07-11T14:15:29.86Z",
"endTime": "2019-07-11T14:15:30.185Z"
}
```


TODO: effective date
80 changes: 80 additions & 0 deletions docs/samples/99-api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Steps:
Level: '"Information"'
```
Posting to a definition ID that already exists, will create a second version of that workflow definition and all existing workflows that were started on the old verison, will continue on the old version but all workflows that are started after this will run on the new version.
### Workflow API
Expand All @@ -47,14 +48,85 @@ Content-Type: application/x-yaml
CustomMessage: foobar
```

##### Response

```json
{
"workflowId": "5d26ae05ec9ce50001bc9c2a",
"data": {
"CustomMessage": "foobar"
},
"definitionId": "HelloWorld",
"version": 1,
"status": "Runnable",
"reference": null,
"startTime": "2019-07-11T03:33:25.203Z",
"endTime": null
}
```

#### Querying a workflow

If you have the `workflowId` that you get back when you start a workflow, you can query it's status via the API.

```
GET /api/workflow/<<WorkflowId>>
```

##### Response

```json
{
"workflowId": "5d26ae05ec9ce50001bc9c2a",
"data": {
"CustomMessage": "foobar"
},
"definitionId": "HelloWorld",
"version": 1,
"status": "Runnable",
"reference": null,
"startTime": "2019-07-11T03:33:25.203Z",
"endTime": null
}
```

#### Suspending a workflow

You can suspend a workflow with a `PUT`

```
PUT /api/workflow/<<WorkflowId>>/suspend
```


#### Resuming a workflow

You can resume a suspended a workflow with a `PUT`

```
PUT /api/workflow/<<WorkflowId>>/resume
```

#### Terminting a workflow

You can abort a workflow with a `DELETE`

```
DELETE /api/workflow/<<WorkflowId>>
```


### Event API

You can publish an event with a particular name and key and attach some data to all workflows that may be listening to it. Use the event API.

```
POST /api/event/<<name>>/<<key>>
```
```
<<data>>
```


### Lambda API

Expand All @@ -73,5 +145,13 @@ c = a + b

#### Viewing a lambda

```
GET /api/lambda/<<id>>
```


### Diagnostic API

```
GET /api/info
```
4 changes: 0 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ Steps:

Now, when we start a new instance of the workflow, we also initialize it with some data.

```
POST /api/workflow/Hello2
Content-Type: application/json
```
```
POST /api/workflow/Hello2
Content-Type: application/x-yaml
Expand Down

0 comments on commit 287e660

Please sign in to comment.