Skip to content

Commit

Permalink
Pull code live from Github during build
Browse files Browse the repository at this point in the history
  • Loading branch information
boney9 committed Apr 7, 2023
1 parent 67fb46f commit def47b6
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 61 deletions.
1 change: 1 addition & 0 deletions .idea/documentation.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion codeblocks/codeblocks.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/service/WorkflowService.java---1":"{`\n StartWorkflowRequest request = new StartWorkflowRequest();\n request.setName(\"deposit_payment\");\n Map<String, Object> inputData = new HashMap<>();\n inputData.put(\"amount\", depositDetail.getAmount());\n inputData.put(\"accountId\", depositDetail.getAccountId());\n request.setInput(inputData);\n\n String workflowId = workflowClient.startWorkflow(request);\n log.info(\"Workflow id: {}\", workflowId);\n`}","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/service/WorkflowService.java---1-lines":"#L22-L32","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/ConductorWorkers.java---1":"{`\n /** Note: Using this setting, up to 5 tasks will run in parallel, with tasks being polled every 200ms */\n @WorkerTask(value = \"fraud-check\", threadCount = 5, pollingInterval = 200)\n public FraudCheckResult checkForFraudTask(DepositDetail depositDetail) {\n return fraudCheckService.checkForFraud(depositDetail);\n }\n`}","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/ConductorWorkers.java---1-lines":"#L17-L23"}
{"https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/service/WorkflowService.java---1":"{`\n StartWorkflowRequest request = new StartWorkflowRequest();\n request.setName(\"deposit_payment\");\n Map<String, Object> inputData = new HashMap<>();\n inputData.put(\"amount\", depositDetail.getAmount());\n inputData.put(\"accountId\", depositDetail.getAccountId());\n request.setInput(inputData);\n\n String workflowId = workflowClient.startWorkflow(request);\n log.info(\"Workflow id: {}\", workflowId);\n`}","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/service/WorkflowService.java---1-lines":"#L22-L32","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/controller/BankingApiController.java---1":"{` @PostMapping(value = \"/triggerDepositFlow\", produces = \"application/json\")\n public ResponseEntity<Map<String, Object>> triggerDepositFlow(@RequestBody DepositDetail depositDetail) {\n log.info(\"Starting deposit flow for: {}\", depositDetail);\n return ResponseEntity.ok(workflowService.startDepositWorkflow(depositDetail));\n }\n`}","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/controller/BankingApiController.java---1-lines":"#L32-L37","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/ConductorWorkers.java---1":"{`\n /** Note: Using this setting, up to 5 tasks will run in parallel, with tasks being polled every 200ms */\n @WorkerTask(value = \"fraud-check\", threadCount = 5, pollingInterval = 200)\n public FraudCheckResult checkForFraudTask(DepositDetail depositDetail) {\n return fraudCheckService.checkForFraud(depositDetail);\n }\n`}","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/ConductorWorkers.java---1-lines":"#L17-L23"}
8 changes: 7 additions & 1 deletion docs/getting-started/step2.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ for integration with applications or services.

View our documentation on [Conductor Clients & SDKs](/content/category/sdks) to learn how to import the required dependencies in our applications.

Let's look at some __code examples__ of how to trigger a workflow by it's name.
Let's look at some __code examples__ of how to trigger a workflow by it's name. We have also linked the repository where this code sample is hosted. To test these ourselves
we can also clone them to local and try it out.

<Tabs>
<TabItem value="Java" label="Java">
Expand Down Expand Up @@ -115,6 +116,11 @@ console.log("Workflow id: {}", workflowId)
</Tabs>


As an example, we might invoke this method when an endpoint is called such as this API call in Java

```java dynamic https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/controller/BankingApiController.java section=1 .../controller/BankingApiController.java
```


In addition to triggering from code, we can also run them from:

Expand Down
52 changes: 19 additions & 33 deletions docs/getting-started/step3.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import CodeBlock from '@theme/CodeBlock';

# Step 3: Adding Custom Code Worker

Continuing the use case from the previous step, we now have a requirement to add a fraud check if the deposit amount is greater than $50,000.
Continuing the use case from the previous step, we now have a requirement to add a fraud check for all deposit transactions >= $10,000

<Tabs>
<TabItem value="UI" label="UI">
Expand All @@ -18,29 +18,29 @@ Continuing the use case from the previous step, we now have a requirement to add


1. In your current definition, add a [Switch](/content/reference-docs/operators/switch-task) task before the deposit task
2. Add a switch case for checking > $50,000, and add a [Worker](/content/reference-docs/operators/simple-task) task for the case with the name `fraud-check`
2. Add a switch case for checking amounts >= 10000, and add a [Worker](/content/reference-docs/operators/simple-task) task for the case with the name `fraud-check`
3. Run workflow.

</div>
<div className="col">
<div className="embed-loom-video">
<iframe
width="100%"
height="300px"
height="350px"
allow="fullscreen;"
src={"https://www.youtube.com/embed/J0TDfs6nJhg"}
src={"https://player.vimeo.com/video/815581464?h=ce49f5768a"}
></iframe></div>
</div>
</div>
</TabItem>
</Tabs>
We can see that when we run this workflow for amounts > $50,000, it runs a fraud check. If we named the task `fraud-check`, we'd notice that it actually executed (in playground env), but how?
That's because there is a pre-defined task that is polling and running all the tasks named `fraud-check`.
We can see that when we run this workflow for amounts >= $10,000, it runs a fraud check. If we named the task `fraud-check`, we'd notice that it actually executed (in playground env), but how?
That's because there is a pre-defined task that is polling and running all the tasks named `fraud-check`. We also have the required permissions in the playground for this task.

So how can we implement this task for ourselves? First let's rename the task to a new unique name for ourselves - for ex: `fraud-check-<replace-with-your-name>`. And now let’s see how this custom fraud check can be implemented:
So how can we implement this task for ourselves? First let's rename the task to a new unique name for ourselves - for ex: `fraud-check-<replace-with-a-unique-value>`. And now let’s see how this custom fraud check can be implemented:

View our documentation on [Conductor Clients & SDKs](/content/category/sdks) list and how to import the required dependencies in our applications.
View our documentation on [Conductor Clients & SDKs](/content/category/sdks) list and how to import the required dependencies in our applications. Refer to the linked repositories in the code samples below to see how to implement the worker.

<Tabs>
<TabItem value="Java" label="Java">
Expand Down Expand Up @@ -131,34 +131,20 @@ View our documentation on [Conductor Clients & SDKs](/content/category/sdks) li
</TabItem>
</Tabs>

So far, we haven't done anything here even if the fraud check fails, but we can add another inline task that can check for the
outcome of fraud check and sends a different message to our users via SMS or Email.

Once we have cloned the repo or copied required elements to our local machines, we can run this locally by connecting to playground server.
To do this we also have give our application the required permissions.
Refer to this [video](/content/videos/access-key-secret) to add permission to execute the custom worker we just created above (`fraud-check-<replace-with-a-unique-value>`).
After providing the permissions, we can change the definition to run our worker (`fraud-check-<replace-with-a-unique-value>`) and start the application.
We can see that now our worker is picking up the task.

<Tabs>
<TabItem value="UI" label="UI">

<div className="row">
<div className="col col--4">
This is the __first example__ of how a distributed worker is executed in Conductor, __without__ exposing an endpoint
or creating any sort of inbound connectivity, we were able to execute the a task directly from our local machine pointing to the playground server.


1. In your current workflow, add a [Inline](/content/reference-docs/system-tasks/inline) task after the switch case
2. Add another switch case to process the deposit only if the fraud check passes
3. Run workflow.

</div>
<div className="col">
<div className="embed-loom-video">
<iframe
width="100%"
height="300px"
allow="fullscreen;"
src={"https://player.vimeo.com/video/814101164?h=e8e6172101"}
></iframe></div>
</div>
</div>
</TabItem>
</Tabs>
:::tip Distributed workers in Conductor
We can run similar workflows in production too, workers could live in __any applications__ or even __third party services__ and we can connect them all together using
Conductor. All of this without having to worry about creating inbound connections or exposing unwanted API endpoints.
:::

## Related Topics

Expand Down
41 changes: 27 additions & 14 deletions docs/getting-started/step4.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@ import TabItem from '@theme/TabItem';
import Install from '@site/src/components/install.mdx';


# Step 4: Adding Wait Conditions
# Step 4: Running an inline function

The wait task in Conductor is used if the workflow is to be paused for external signals. The signals can be human manual interventions or an event from external sources such as Kafka, SQS, etc. Let’s learn how you can pause your workflows using wait tasks.
So far, we haven't done anything here even if the fraud check fails. How can we handle the case where the fraud check returned a fail and we want to skip
processing the deposit transaction, but we can add another inline task that can check for the outcome of fraud check and sends a different message to our users via SMS or Email.

#### In your current workflow, what if you want to send the SMS only after 10 mins?

:::tip
Orkes Conductor doesn't limit your wait conditions. We can wait for __mins__, __days__, __months__ or even __years__! It can also wait for external signals like manual approval or events from messaging systems such as __Kafka/SQS__.
:::

<Tabs>
<TabItem value="UI" label="UI">

<div className="row">
<div className="col col--4">

1. In your current workflow, add a [Wait](/content/reference-docs/operators/wait) task before the SMS task.
2. You can configure the wait task parameters to wait for 10 mins.
3. Run workflow directly from the UI using the Run Workflow button.
1. In your current workflow, add a [Inline](/content/reference-docs/system-tasks/inline) task after the switch case
2. Add another switch case to process the deposit only if the fraud check passes
3. Add an inline to compose the correct message for users
4. Pass the message as inputs to the send-message tasks
5. Run workflow

</div>
<div className="col">
Expand All @@ -33,17 +31,32 @@ Orkes Conductor doesn't limit your wait conditions. We can wait for __mins__, __
width="100%"
height="300px"
allow="fullscreen;"
src={"https://www.youtube.com/embed/J0TDfs6nJhg"}
src={"https://player.vimeo.com/video/814101164?h=e8e6172101"}
></iframe></div>
</div>
</div>
</TabItem>
</Tabs>
Since you have configured the wait task to wait for 10 mins, once the workflow execution reaches this task, it waits for 10 mins and then proceeds to the next task; sending an SMS.
:::tip
INLINE task is a great tool for writing basic logic, such as a predicate condition or object data transforms. With Javascript, you can
write complex actions that will be executed by Conductor without having to find a place to host and run this worker.
:::

INLINE tasks can be scripted from the following template
```javascript
(function() {
// Your code here
// Variables for this function needs to be explicitly added as inputs and once added you can
// refer to them using the $.<variable-name> notation.
return $.amount > 10000;
})();
```

Read more on INLINE tasks [here](/content/reference-docs/system-tasks/inline)

## Related Topics

* [API Reference for Wait](/content/reference-docs/operators/wait)
* [Scheduling workflows](/content/guides/scheduling-workflows)
- Passing [inputs into workflow for tasks](/content/guides/passing-data-task-to-task#task-inputs-referred-from-workflow-inputs)
- Passing the [output of one task to the input](/content/guides/passing-data-task-to-task#task-inputs-referred-from-other-task-outputs) of another
- [Client SDKs](/content/conductor-clients)
26 changes: 14 additions & 12 deletions docs/getting-started/step5.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ import TabItem from '@theme/TabItem';
import Install from '@site/src/components/install.mdx';


# Step 5: Running an inline function
# Step 5: Adding Wait Conditions

Occasionally we will need to write some logic, such as a complex predicate or a basic transform. In such cases we can use
the INLINE task feature.
The wait task in Conductor is used if the workflow is to be paused for external signals. The signals can be human manual interventions or an event from external sources such as Kafka, SQS, etc. Let’s learn how you can pause your workflows using wait tasks.

#### In your current workflow, what if you want to send the SMS only after 10 mins?

:::tip
Orkes Conductor doesn't limit your wait conditions. We can wait for __mins__, __days__, __months__ or even __years__! It can also wait for external signals like manual approval or events from messaging systems such as __Kafka/SQS__.
:::

<Tabs>
<TabItem value="UI" label="UI">

<div className="row">
<div className="col col--4">

1. Add [HTTP](/content/reference-docs/system-tasks/http) worker to retrieve stock tickers.
2. Add [Dynamic Fork](/content/reference-docs/operators/dynamic-fork) based on the output of the HTTP worker.
3. Create the [Subworkflow](/content/reference-docs/operators/sub-workflow). Include the following tasks in the subworkflow.<ul><li>Retrieve the previous day’s closing price and volume</li><li>Retrieve today's opening price</li><li>Run a trade execution</li></ul>
4. Run Workflow.
1. In your current workflow, add a [Wait](/content/reference-docs/operators/wait) task before the SMS task.
2. You can configure the wait task parameters to wait for 10 mins.
3. Run workflow directly from the UI using the Run Workflow button.

</div>
<div className="col">
Expand All @@ -36,12 +40,10 @@ the INLINE task feature.
</TabItem>
</Tabs>
As we can see, this workflow triggers a sub-workflow for each ticker from the output of the previous step. Let’s try running this with 100 tickers. In this test, the API limits the tickers to 100. Still, we can run several thousand tasks in parallel, all without worrying about the state of the execution or where it's being executed. When all the forks are complete, the workflow resumes the next step enabling us to do more advanced tasks with minimal effort.
Since you have configured the wait task to wait for 10 mins, once the workflow execution reaches this task, it waits for 10 mins and then proceeds to the next task; sending an SMS.

The mock APIs used in this example are available here on this repo:

## Related Topics

- Passing [inputs into workflow for tasks](/content/guides/passing-data-task-to-task#task-inputs-referred-from-workflow-inputs)
- Passing the [output of one task to the input](/content/guides/passing-data-task-to-task#task-inputs-referred-from-other-task-outputs) of another
- [Client SDKs](/content/conductor-clients)
* [API Reference for Wait](/content/reference-docs/operators/wait)
* [Scheduling workflows](/content/guides/scheduling-workflows)

0 comments on commit def47b6

Please sign in to comment.