|
| 1 | +<!-- THIS IS A GENERATED FILE --> |
| 2 | +<!-- PLEASE DO NOT EDIT --> |
| 3 | + |
| 4 | +# Hello World Sample |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | + |
| 8 | +0. Install Cadence CLI. See instruction [here](https://cadenceworkflow.io/docs/cli/). |
| 9 | +1. Run the Cadence server: |
| 10 | + 1. Clone the [Cadence](https://github.com/cadence-workflow/cadence) repository if you haven't done already: `git clone https://github.com/cadence-workflow/cadence.git` |
| 11 | + 2. Run `docker compose -f docker/docker-compose.yml up` to start Cadence server |
| 12 | + 3. See more details at https://github.com/uber/cadence/blob/master/README.md |
| 13 | +2. Once everything is up and running in Docker, open [localhost:8088](localhost:8088) to view Cadence UI. |
| 14 | +3. Register the `cadence-samples` domain: |
| 15 | + |
| 16 | +```bash |
| 17 | +cadence --env development --domain cadence-samples domain register |
| 18 | +``` |
| 19 | + |
| 20 | +Refresh the [domains page](http://localhost:8088/domains) from step 2 to verify `cadence-samples` is registered. |
| 21 | + |
| 22 | +## Steps to run sample |
| 23 | + |
| 24 | +Inside the folder this sample is defined, run the following command: |
| 25 | + |
| 26 | +```bash |
| 27 | +go run . |
| 28 | +``` |
| 29 | + |
| 30 | +This will call the main function in main.go which starts the worker, which will be execute the sample workflow code |
| 31 | + |
| 32 | +### Start your workflow |
| 33 | + |
| 34 | +This workflow takes an input message and greet you as response. Try the following CLI |
| 35 | + |
| 36 | +```bash |
| 37 | +cadence --env development \ |
| 38 | + --domain cadence-samples \ |
| 39 | + workflow start \ |
| 40 | + --workflow_type cadence_samples.HelloWorldWorkflow \ |
| 41 | + --tl cadence-samples-worker \ |
| 42 | + --et 60 \ |
| 43 | + --input '{"message":"Cadence"}' |
| 44 | +``` |
| 45 | + |
| 46 | +Here are the details to this command: |
| 47 | + |
| 48 | +* `--domain` option describes under which domain to run this workflow |
| 49 | +* `--env development` calls the "local" cadence server |
| 50 | +* `--workflow_type` option describes which workflow to execute |
| 51 | +* `-tl` (or `--tasklist`) tells cadence-server which tasklist to schedule tasks with. This is the same tasklist the worker polls tasks from. See worker.go |
| 52 | +* `--et` (or `--execution_timeout`) tells cadence server how long to wait until timing out the workflow |
| 53 | +* `--input` is the input to your workflow |
| 54 | + |
| 55 | +To see more options run `cadence --help` |
| 56 | + |
| 57 | +### View your workflow |
| 58 | + |
| 59 | +#### Cadence UI (cadence-web) |
| 60 | + |
| 61 | +Click on `cadence-samples` domain in cadence-web to view your workflow. |
| 62 | + |
| 63 | +* In Summary tab, you will see the input and output to your workflow |
| 64 | +* Click on History tab to see individual steps. |
| 65 | + |
| 66 | +#### CLI |
| 67 | + |
| 68 | +List workflows using the following command: |
| 69 | + |
| 70 | +```bash |
| 71 | + cadence --env development --domain cadence-samples --workflow list |
| 72 | +``` |
| 73 | + |
| 74 | +You can view an individual workflow by using the following command: |
| 75 | + |
| 76 | +```bash |
| 77 | +cadence --env development \ |
| 78 | + --domain cadence-samples \ |
| 79 | + --workflow describe \ |
| 80 | + --wid <workflow_id> |
| 81 | +``` |
| 82 | + |
| 83 | +* `workflow` is the noun to run commands within workflow scope |
| 84 | +* `describe` is the verb to return the summary of the workflow |
| 85 | +* `--wid` (or `--workflow_id`) is the option to pass the workflow id. If there are multiple "run"s, it will return the latest one. |
| 86 | +* (optional) `--rid` (or `--run_id`) is the option to pass the run id to describe a specific run, instead of the latest. |
| 87 | + |
| 88 | +To view the entire history of the workflow, use the following command: |
| 89 | + |
| 90 | +```bash |
| 91 | +cadence --env development \ |
| 92 | + --domain cadence-samples \ |
| 93 | + --workflow show \ |
| 94 | + --wid <workflow_id> |
| 95 | +``` |
| 96 | + |
| 97 | +## References |
| 98 | + |
| 99 | +* The website: https://cadenceworkflow.io |
| 100 | +* Cadence's server: https://github.com/uber/cadence |
| 101 | +* Cadence's Go client: https://github.com/uber-go/cadence-client |
| 102 | + |
0 commit comments