Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
boney9 committed Sep 26, 2023
1 parent 87e3155 commit dea9f74
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 18 deletions.
2 changes: 1 addition & 1 deletion codeblocks/codeblocks.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"https://github.com/orkes-io/workflow-cicd/blob/main/src/deploy_workflows.sh---1":"{`export response=\\`curl -s -X POST $CONDUCTOR_SERVER_URL/token -H 'Content-Type:application/json' -d '{\n\t\"keyId\": \"'\"$KEY\"'\",\n\t\"keySecret\": \"'\"$SECRET\"'\"\n}'\\`\n\nif [[ \"$response\" != *'token'* ]]; then\n echo \"Unable to generate the auth header. Please check KEY, SECRET and CONDUCTOR_SERVER_URL variables\"\n echo \"Server response:\"\n echo $response\n exit 1\nfi\n\nexport token=\\`echo $response | cut -d '\"' -f4\\`\n\nfor FILE in main/resources/workflows/*;\n do\n echo \"Deploying @$FILE\";\n\n curl -X POST $CONDUCTOR_SERVER_URL/metadata/workflow?overwrite=true \\\n -H \"X-Authorization: $token\" \\\n -H \"accept: */*\" \\\n -H \"Content-Type: application/json\" \\\n -d @$FILE\n done\n`}","https://github.com/orkes-io/workflow-cicd/blob/main/src/deploy_workflows.sh---1-lines":"#L8-L32","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/ConductorWorkers.java---1":"{`\n /**\n * Note: Using this setting, up to 5 tasks will run in parallel, with tasks being polled every 200ms\n */\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":"#L27-L35","https://github.com/conductor-sdk/csharp-sdk-examples/blob/main/Examples/Worker/Workers.cs---1":"{` // Note: Using this setting, up to 5 tasks will run in parallel, with tasks being polled every 200ms\n [WorkerTask(taskType: \"fraud-check\", batchSize: 5, domain: null, pollIntervalMs: 200, workerId: \"workerId\")]\n public TaskResult FraudWorker(Task task)\n {\n var depositDetail = (DepositDetail)task.InputData[\"depositDetail\"];\n var fraudCheckResult = _fraudCheckService.CheckForFraud(depositDetail);\n var result = task.Completed();\n result.OutputData = Examples.Util.TypeUtil.GetDictionaryFromObject(fraudCheckResult);\n return result;\n }`}","https://github.com/conductor-sdk/csharp-sdk-examples/blob/main/Examples/Worker/Workers.cs---1-lines":"#L25-L34","https://github.com/conductor-sdk/javascript-sdk-examples/blob/main/src/banking/workers/workers.js---1":"{`const fraudCheckWorker = {\n taskDefName: \"fraud-check\",\n execute: async ({ inputData }) => {\n const { amount, accountId } = inputData;\n const fraudResult = fraudService.isFraudulentTxn(accountId, amount);\n return {\n outputData: fraudResult,\n status: \"COMPLETED\",\n };\n },\n};`}","https://github.com/conductor-sdk/javascript-sdk-examples/blob/main/src/banking/workers/workers.js---1-lines":"#L4-L14","https://github.com/conductor-sdk/typescript-examples/blob/main/src/banking/workers/workers.ts---1":"{`export const fraudCheckWorker: ConductorWorker = {\n taskDefName: \"fraud-check\",\n execute: async ({ inputData }) => {\n const amount = inputData?.amount;\n const accountId = inputData?.accountId;\n const fraudResult = fraudService.isFraudulentTxn(accountId, amount);\n return {\n outputData: fraudResult,\n status: \"COMPLETED\",\n };\n },\n};`}","https://github.com/conductor-sdk/typescript-examples/blob/main/src/banking/workers/workers.ts---1-lines":"#L5-L16","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/ConductorWorkers.java---2":"{`\n @WorkerTask(value = \"retrieve-deposit-batch\", threadCount = 5, pollingInterval = 200)\n public List<DepositDetail> retrieveDepositBatch(@InputParam(\"batchCount\") Integer batchCount) {\n if (batchCount == null) {\n batchCount = random.nextInt(5, 11);\n }\n batchCount = Math.min(100, batchCount); // Limit to 100 in playground\n List<DepositDetail> depositDetails = IntStream.range(0, batchCount)\n .mapToObj(i -> DepositDetail.builder()\n .accountId(\"acc-id-\" + i)\n .amount(BigDecimal.valueOf(i * 1500L)) // Create random amounts\n .build())\n .toList();\n log.info(\"Returning {} transactions\", depositDetails.size());\n return depositDetails;\n }\n`}","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/ConductorWorkers.java---2-lines":"#L40-L56","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/csharp-sdk-examples/blob/main/Examples/Service/WorkflowService.cs---1":"{` var request = new StartWorkflowRequest\n {\n Name = WORKFLOW_NAME,\n Version = WORKFLOW_VERSION,\n Input = Examples.Util.TypeUtil.GetDictionaryFromObject(depositDetail)\n };\n var workflowId = _workflowClient.StartWorkflow(request);\n Console.WriteLine($\"Started deposit workflow id: {workflowId}\");\n return workflowId;`}","https://github.com/conductor-sdk/csharp-sdk-examples/blob/main/Examples/Service/WorkflowService.cs---1-lines":"#L23-L31","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/PollUntilConditionMeetsWorker.java---1":"{` @Override\n public TaskResult execute(Task task) {\n TaskResult taskResult = new TaskResult(task);\n if (!task.getInputData().containsKey(POLL_COUNTER)) {\n taskResult.addOutputData(\"message\", \"pollCounter param not found in input, will use default of \" + defaultPollCount + \" polls\");\n }\n\n int pollCounter = Math.min(10, castToInt(task.getInputData().getOrDefault(POLL_COUNTER, defaultPollCount)));\n int pollIntervalSeconds = Math.min(10, castToInt(task.getInputData().getOrDefault(POLL_INTERVAL_SECONDS, 5)));\n\n // Add these to the output for context\n taskResult.addOutputData(POLL_INTERVAL_SECONDS, pollIntervalSeconds + \" (this test task has a max limit of 10 seconds)\");\n taskResult.addOutputData(POLL_COUNTER, pollCounter + \" (this test task has a max limit of 10 iterations)\");\n\n // We can read current iteration from the task output as the data will be retained on the worker when polled\n int currentIteration = castToInt(taskResult.getOutputData().getOrDefault(CURRENT_ITERATION, 0));\n\n // Increment the current iteration and set to the task output\n taskResult.addOutputData(CURRENT_ITERATION, ++currentIteration);\n taskResult.addOutputData(\"updatedTime\", new Date().toString());\n\n // While condition is not met, keep task in progress\n if (currentIteration < pollCounter) {\n taskResult.setStatus(TaskResult.Status.IN_PROGRESS);\n // Set to configured seconds to callback, and you can set this to any value as per the requirements\n taskResult.setCallbackAfterSeconds(pollIntervalSeconds);\n return taskResult;\n }\n\n // Set task as completed now that the poll count condition is met\n taskResult.setStatus(TaskResult.Status.COMPLETED);\n return taskResult;\n }`}","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/PollUntilConditionMeetsWorker.java---1-lines":"#L24-L56"}
{"https://github.com/orkes-io/workflow-cicd/blob/main/src/deploy_workflows.sh---1":"{`export response=\\`curl -s -X POST $CONDUCTOR_SERVER_URL/token -H 'Content-Type:application/json' -d '{\n\t\"keyId\": \"'\"$KEY\"'\",\n\t\"keySecret\": \"'\"$SECRET\"'\"\n}'\\`\n\nif [[ \"$response\" != *'token'* ]]; then\n echo \"Unable to generate the auth header. Please check KEY, SECRET and CONDUCTOR_SERVER_URL variables\"\n echo \"Server response:\"\n echo $response\n exit 1\nfi\n\nexport token=\\`echo $response | cut -d '\"' -f4\\`\n\nfor FILE in main/resources/workflows/*;\n do\n echo \"Deploying @$FILE\";\n\n curl -X POST $CONDUCTOR_SERVER_URL/metadata/workflow?overwrite=true \\\n -H \"X-Authorization: $token\" \\\n -H \"accept: */*\" \\\n -H \"Content-Type: application/json\" \\\n -d @$FILE\n done\n`}","https://github.com/orkes-io/workflow-cicd/blob/main/src/deploy_workflows.sh---1-lines":"#L8-L32","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/ConductorWorkers.java---1":"{`\n /**\n * Note: Using this setting, up to 5 tasks will run in parallel, with tasks being polled every 200ms\n */\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":"#L27-L35","https://github.com/conductor-sdk/csharp-sdk-examples/blob/main/Examples/Worker/Workers.cs---1":"{` // Note: Using this setting, up to 5 tasks will run in parallel, with tasks being polled every 200ms\n [WorkerTask(taskType: \"fraud-check\", batchSize: 5, domain: null, pollIntervalMs: 200, workerId: \"workerId\")]\n public TaskResult FraudWorker(Task task)\n {\n var depositDetail = (DepositDetail)task.InputData[\"depositDetail\"];\n var fraudCheckResult = _fraudCheckService.CheckForFraud(depositDetail);\n var result = task.Completed();\n result.OutputData = Examples.Util.TypeUtil.GetDictionaryFromObject(fraudCheckResult);\n return result;\n }`}","https://github.com/conductor-sdk/csharp-sdk-examples/blob/main/Examples/Worker/Workers.cs---1-lines":"#L25-L34","https://github.com/conductor-sdk/javascript-sdk-examples/blob/main/src/banking/workers/workers.js---1":"{`const fraudCheckWorker = {\n taskDefName: \"fraud-check\",\n execute: async ({ inputData }) => {\n const { amount, accountId } = inputData;\n const fraudResult = fraudService.isFraudulentTxn(accountId, amount);\n return {\n outputData: fraudResult,\n status: \"COMPLETED\",\n };\n },\n domain: \"fraud\", // Optional\n pollInterval: 100, // Optional can be specified in the TaskManager\n concurrency: 1, // Optional can be specified in the TaskManager\n};`}","https://github.com/conductor-sdk/javascript-sdk-examples/blob/main/src/banking/workers/workers.js---1-lines":"#L4-L17","https://github.com/conductor-sdk/typescript-examples/blob/main/src/banking/workers/workers.ts---1":"{`export const fraudCheckWorker: ConductorWorker = {\n taskDefName: \"fraud-check\",\n execute: async ({ inputData }) => {\n const amount = inputData?.amount;\n const accountId = inputData?.accountId;\n const fraudResult = fraudService.isFraudulentTxn(accountId, amount);\n return {\n outputData: fraudResult,\n status: \"COMPLETED\",\n };\n },\n domain: \"fraud\", // Optional\n pollInterval: 100, // Optional can be specified in the TaskManager\n concurrency: 2, // Optional can be specified in the TaskManager\n};`}","https://github.com/conductor-sdk/typescript-examples/blob/main/src/banking/workers/workers.ts---1-lines":"#L5-L19","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/ConductorWorkers.java---2":"{`\n @WorkerTask(value = \"retrieve-deposit-batch\", threadCount = 5, pollingInterval = 200)\n public List<DepositDetail> retrieveDepositBatch(@InputParam(\"batchCount\") Integer batchCount) {\n if (batchCount == null) {\n batchCount = random.nextInt(5, 11);\n }\n batchCount = Math.min(100, batchCount); // Limit to 100 in playground\n List<DepositDetail> depositDetails = IntStream.range(0, batchCount)\n .mapToObj(i -> DepositDetail.builder()\n .accountId(\"acc-id-\" + i)\n .amount(BigDecimal.valueOf(i * 1500L)) // Create random amounts\n .build())\n .toList();\n log.info(\"Returning {} transactions\", depositDetails.size());\n return depositDetails;\n }\n`}","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/ConductorWorkers.java---2-lines":"#L40-L56","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/csharp-sdk-examples/blob/main/Examples/Service/WorkflowService.cs---1":"{` var request = new StartWorkflowRequest\n {\n Name = WORKFLOW_NAME,\n Version = WORKFLOW_VERSION,\n Input = Examples.Util.TypeUtil.GetDictionaryFromObject(depositDetail)\n };\n var workflowId = _workflowClient.StartWorkflow(request);\n Console.WriteLine($\"Started deposit workflow id: {workflowId}\");\n return workflowId;`}","https://github.com/conductor-sdk/csharp-sdk-examples/blob/main/Examples/Service/WorkflowService.cs---1-lines":"#L23-L31","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/PollUntilConditionMeetsWorker.java---1":"{` @Override\n public TaskResult execute(Task task) {\n TaskResult taskResult = new TaskResult(task);\n if (!task.getInputData().containsKey(POLL_COUNTER)) {\n taskResult.addOutputData(\"message\", \"pollCounter param not found in input, will use default of \" + defaultPollCount + \" polls\");\n }\n\n int pollCounter = Math.min(10, castToInt(task.getInputData().getOrDefault(POLL_COUNTER, defaultPollCount)));\n int pollIntervalSeconds = Math.min(10, castToInt(task.getInputData().getOrDefault(POLL_INTERVAL_SECONDS, 5)));\n\n // Add these to the output for context\n taskResult.addOutputData(POLL_INTERVAL_SECONDS, pollIntervalSeconds + \" (this test task has a max limit of 10 seconds)\");\n taskResult.addOutputData(POLL_COUNTER, pollCounter + \" (this test task has a max limit of 10 iterations)\");\n\n // We can read current iteration from the task output as the data will be retained on the worker when polled\n int currentIteration = castToInt(taskResult.getOutputData().getOrDefault(CURRENT_ITERATION, 0));\n\n // Increment the current iteration and set to the task output\n taskResult.addOutputData(CURRENT_ITERATION, ++currentIteration);\n taskResult.addOutputData(\"updatedTime\", new Date().toString());\n\n // While condition is not met, keep task in progress\n if (currentIteration < pollCounter) {\n taskResult.setStatus(TaskResult.Status.IN_PROGRESS);\n // Set to configured seconds to callback, and you can set this to any value as per the requirements\n taskResult.setCallbackAfterSeconds(pollIntervalSeconds);\n return taskResult;\n }\n\n // Set task as completed now that the poll count condition is met\n taskResult.setStatus(TaskResult.Status.COMPLETED);\n return taskResult;\n }`}","https://github.com/conductor-sdk/orkes-java-springboot2-example/blob/main/src/main/java/io/orkes/example/banking/workers/PollUntilConditionMeetsWorker.java---1-lines":"#L24-L56"}
Loading

0 comments on commit dea9f74

Please sign in to comment.