Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated tasks #6

Merged
merged 1 commit into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 144 additions & 5 deletions docs/reference-docs/dynamic-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ sidebar_position: 1

## What is a Dynamic Task?

TODO: What is a Dynamic task? How does it work?
Dynamic Task allows to execute one of the registered Tasks dynamically at run-time.
It accepts the task name to execute as `taskToExecute` in `inputParameters`.

## Common Use Cases

TODO: List out some common use cases
Consider a scenario, when we have to make decision of executing a task dynamically i.e. while the workflow is still
running. In such cases, Dynamic Task would be useful.

## Configuration / Properties

Dynamic task is defined directly inside the workflow with type `DYNAMIC`.

### Inputs

TODO: Talk about inputs for the task
Following are the input parameters :

|name|description|
|---|---|
| dynamicTaskNameParam|Name of the parameter from the task input whose value is used to schedule the task. e.g. if the value of the parameter is ABC, the next task scheduled is of type 'ABC'.|

### Output

Expand All @@ -24,9 +32,140 @@ TODO: Talk about output of the task, what to expect

## Examples

TODO: Example 1
Suppose in a workflow, we have to take decision to ship the courier with the shipping
service providers on the basis of Post Code.

Following task `shipping_info` generates an output on the basis of which decision would be
taken to run the next task.

```json
{
"name": "shipping_info",
"retryCount": 3,
"timeoutSeconds": 600,
"pollTimeoutSeconds": 1200,
"timeoutPolicy": "TIME_OUT_WF",
"retryLogic": "FIXED",
"retryDelaySeconds": 300,
"responseTimeoutSeconds": 300,
"concurrentExecLimit": 100,
"rateLimitFrequencyInSeconds": 60,
"ownerEmail":"[email protected]",
"rateLimitPerFrequency": 1
}
```

Following are the two worker tasks, one among them would execute on the basis of output generated
by the `shipping_info` task :

```json
{
"name": "ship_via_fedex",
"retryCount": 3,
"timeoutSeconds": 600,
"pollTimeoutSeconds": 1200,
"timeoutPolicy": "TIME_OUT_WF",
"retryLogic": "FIXED",
"retryDelaySeconds": 300,
"responseTimeoutSeconds": 300,
"concurrentExecLimit": 100,
"rateLimitFrequencyInSeconds": 60,
"ownerEmail":"[email protected]",
"rateLimitPerFrequency": 2
},
{
"name": "ship_via_ups",
"retryCount": 3,
"timeoutSeconds": 600,
"pollTimeoutSeconds": 1200,
"timeoutPolicy": "TIME_OUT_WF",
"retryLogic": "FIXED",
"retryDelaySeconds": 300,
"responseTimeoutSeconds": 300,
"concurrentExecLimit": 100,
"rateLimitFrequencyInSeconds": 60,
"ownerEmail":"[email protected]",
"rateLimitPerFrequency": 2
}
```


We will create the Workflow with the following definition :

```json
{
"name": "Shipping_Flow",
"description": "Ships smartly on the basis of Shipping info",
"version": 1,
"tasks": [
{
"name": "shipping_info",
"taskReferenceName": "shipping_info",
"inputParameters": {
},
"type": "SIMPLE"
},
{
"name": "shipping_task",
"taskReferenceName": "shipping_task",
"inputParameters": {
"taskToExecute": "${shipping_info.output.shipping_service}"
},
"type": "DYNAMIC",
"dynamicTaskNameParam": "taskToExecute"
}

],
"restartable": true,
"ownerEmail":"[email protected]",
"workflowStatusListenerEnabled": true,
"schemaVersion": 2
}
```

Workflow is the created as shown in the below diagram.


![Conductor UI - Workflow Diagram](/img/tutorial/ShippingWorkflow.png)


Note : `shipping_task` is a `DYNAMIC` task and the `taskToExecute` parameter can be set
with input value provided while running the workflow or with the output of previous tasks.
Here, it is set to the output provided by the previous task i.e.
`${shipping_info.output.shipping_service}`.

If the input value is provided while running the workflow it can be accessed by
`${workflow.input.shipping_service}`.

```json
{
"shipping_service": "ship_via_fedex"
}
```

We can see in the below example that on the basis of Post Code the shipping service is being
decided.

```js reference
https://github.com/orkes-io/orkesworkers/blob/main/src/main/java/io/orkes/samples/workers/ShippingInfoWorker.java#L10-L36
```

Based on given set of inputs i.e. Post Code starts with '9' hence, `ship_via_fedex` is executed -

![Conductor UI - Workflow Run](/img/tutorial/ShippingWorkflowRunning.png)

If the Post Code started with anything other than 9 `ship_via_ups` is executed -

![Conductor UI - Workflow Run](/img/tutorial/ShippingWorkflowUPS.png)

If the incorrect task name or the task that doesn't exist is provided then the workflow fails and
we get the error `"Invalid task specified. Cannot find task by name in the task definitions."`

If the null reference is provided in the task name then also the workflow fails and we get the
error `"Cannot map a dynamic task based on the parameter and input. Parameter= taskToExecute, input= {taskToExecute=null}"`



TODO: Example 2

## FAQs

Expand Down
129 changes: 126 additions & 3 deletions docs/reference-docs/http-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,131 @@ sidebar_position: 1

# Http Task

TODO
## What is a HTTP Task?

## Summary
An HTTP task is useful when you have a requirements such as

1. Making calls to another service that exposes an API via HTTP
2. Fetch any resource or data present on an endpoint

## Common Use Cases

If there is a scenario where, we need to make a call to a microservice and fetch some data or resource and use it inside
our workflow. In such cases HTTP Task would very helpful. Using HTTP tasks you can avoid having to write the code that
talks to these services and instead let Conductor manage it directly. This can reduce the code you have to maintain and
allows for a lot of flexibility.

## Configuration / Properties

HTTP task is defined directly inside the workflow with type `HTTP`.

|name|type|description|
|---|---|---|
| http_request | HttpRequest | JSON object (see below) |

### Inputs

|Name|Type|Example|Description|
|---|---|---|---|
| uri | String || URI for the service. Can be a partial when using vipAddress or includes the server address.|
| method | String || HTTP method. One of the GET, PUT, POST, DELETE, OPTIONS, HEAD|
| accept | String || Accept header as required by server. Defaults to ```application/json``` |
| contentType | String || Content Type - supported types are ```text/plain```, ```text/html```, and ```application/json``` (Default)|
| headers| Map[String, Any] || A map of additional http headers to be sent along with the request.|
| body| Map[] || Request body |
| vipAddress | String || When using discovery based service URLs.|
| asyncComplete | Boolean |TODO: Link to details| ```false``` to mark status COMPLETED upon execution ; ```true``` to keep it IN_PROGRESS, wait for an external event (via Conductor or SQS or EventHandler) to complete it.
| oauthConsumerKey | String || [OAuth](https://oauth.net/core/1.0/) client consumer key |
| oauthConsumerSecret | String || [OAuth](https://oauth.net/core/1.0/) client consumer secret |
| connectionTimeOut | Integer || Connection Time Out in milliseconds. If set to 0, equivalent to infinity. Default: 100. |
| readTimeOut | Integer || Read Time Out in milliseconds. If set to 0, equivalent to infinity. Default: 150. |

### Output

|name|type|description|
|---|---|---|
| response | Map | JSON body containing the response if one is present |
| headers | Map[String, Any] | Response Headers |
| statusCode | Integer | [Http Status Code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) |
| reasonPhrase | String | Http Status Code's reason phrase |

## Examples

Following is the example of HTTP task with `GET` method.

```json

{
"name": "Get Example",
"taskReferenceName": "get_example",
"inputParameters": {
"http_request": {
"uri": "https://jsonplaceholder.typicode.com/posts/1",
"method": "GET"
}
},
"type": "HTTP"
}
```

Following is the example of HTTP task with `POST` method.

```json
{
"name": "POST Example",
"taskReferenceName": "post_example",
"inputParameters": {
"http_request": {
"uri": "https://jsonplaceholder.typicode.com/posts/",
"method": "POST"
}
},
"type": "HTTP"
}
```

Following is the example of HTTP task with `PUT` method.

```json
{
"name": "PUT Example",
"taskReferenceName": "put_example",
"inputParameters": {
"http_request": {
"uri": "https://jsonplaceholder.typicode.com/posts/1",
"method": "PUT"
}
},
"type": "HTTP"
}
```

Following is the example of HTTP task with `DELETE` method.

```json
{
"name": "DELETE Example",
"taskReferenceName": "delete_example",
"inputParameters": {
"http_request": {
"uri": "https://jsonplaceholder.typicode.com/posts/1",
"method": "DELETE"
}
},
"type": "HTTP"
}
```

In order to implement HTTP task in our workflow, we need to define HTTP task as shown above under the tasks section in
the workflow. We can choose our method type and specify all the attributes.

## FAQs

TODO: Gotchas and other nuances

1. Question 1
1. Answer

1. Question 2
1. Answer

TODO
23 changes: 20 additions & 3 deletions docs/reference-docs/set-variable-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,25 @@ sidebar_position: 1

# Set Variable Task

TODO
## What is a Set Variable Task?

## Summary
## Common Use Cases

## Configuration / Properties

### Inputs

### Output

## Examples

## FAQs

TODO: Gotchas and other nuances

1. Question 1
1. Answer

1. Question 2
1. Answer

TODO
Loading