diff --git a/.idea/documentation.iml b/.idea/documentation.iml index 786c549c..bdf3f226 100644 --- a/.idea/documentation.iml +++ b/.idea/documentation.iml @@ -7,6 +7,7 @@ + diff --git a/codeblocks/codeblocks.json b/codeblocks/codeblocks.json index b9440fe5..6f131b31 100644 --- a/codeblocks/codeblocks.json +++ b/codeblocks/codeblocks.json @@ -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 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"} \ No newline at end of file +{"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 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> 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"} \ No newline at end of file diff --git a/docs/getting-started/step2.md b/docs/getting-started/step2.md index 631ff03e..a58c703d 100644 --- a/docs/getting-started/step2.md +++ b/docs/getting-started/step2.md @@ -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. @@ -115,6 +116,11 @@ console.log("Workflow id: {}", workflowId) +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: diff --git a/docs/getting-started/step3.md b/docs/getting-started/step3.md index 1e3bbfd8..fc9c25d6 100644 --- a/docs/getting-started/step3.md +++ b/docs/getting-started/step3.md @@ -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 @@ -18,7 +18,7 @@ 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. @@ -26,21 +26,21 @@ Continuing the use case from the previous step, we now have a requirement to add
-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-`. 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-`. 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. @@ -131,34 +131,20 @@ View our documentation on [Conductor Clients & SDKs](/content/category/sdks) li -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-`). +After providing the permissions, we can change the definition to run our worker (`fraud-check-`) and start the application. +We can see that now our worker is picking up the task. - - - -
-
+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. - -
-
-
-
-
-
-
-
+:::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 diff --git a/docs/getting-started/step4.md b/docs/getting-started/step4.md index 32ae0dd9..5dd22953 100644 --- a/docs/getting-started/step4.md +++ b/docs/getting-started/step4.md @@ -6,15 +6,11 @@ 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__. -::: @@ -22,9 +18,11 @@ Orkes Conductor doesn't limit your wait conditions. We can wait for __mins__, __
-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
@@ -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"} >
-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 $. 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) \ No newline at end of file +- 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) \ No newline at end of file diff --git a/docs/getting-started/step5.md b/docs/getting-started/step5.md index 64ad248d..d080bbb6 100644 --- a/docs/getting-started/step5.md +++ b/docs/getting-started/step5.md @@ -6,10 +6,15 @@ 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__. +::: @@ -17,10 +22,9 @@ the INLINE task feature.
-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.
  • Retrieve the previous day’s closing price and volume
  • Retrieve today's opening price
  • Run a trade execution
-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.
@@ -36,12 +40,10 @@ the INLINE task feature. -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) \ No newline at end of file +* [API Reference for Wait](/content/reference-docs/operators/wait) +* [Scheduling workflows](/content/guides/scheduling-workflows) \ No newline at end of file