Skip to content

Commit 53243e1

Browse files
Add sample signal workflow
Signed-off-by: Ender Demirkaya <[email protected]>
1 parent bb21191 commit 53243e1

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- THIS IS A GENERATED FILE -->
2+
<!-- PLEASE DO NOT EDIT -->
3+
4+
# Sample Generator
5+
6+
This folder is NOT part of the actual sample. It exists only for contributors who work on this sample. Please disregard it if you are trying to learn about Cadence.
7+
8+
To create a better learning experience for Cadence users, each sample folder is designed to be self contained. Users can view every part of writing and running workflows, including:
9+
10+
* Cadence client initialization
11+
* Worker with workflow and activity registrations
12+
* Workflow starter
13+
* and the workflow code itself
14+
15+
Some samples may have more or fewer parts depending on what they need to demonstrate.
16+
17+
In most cases, the workflow code (e.g. `workflow.go`) is the part that users care about. The rest is boilerplate needed to run that workflow. For each sample folder, the workflow code should be written by hand. The boilerplate can be generated. Keeping all parts inside one folder gives early learners more value because they can see everything together rather than jumping across directories.
18+
19+
## Contributing
20+
21+
* When creating a new sample, follow the steps mentioned in the README file in the main samples folder.
22+
* To update the sample workflow code, edit the workflow file directly.
23+
* To update the worker, client, or other boilerplate logic, edit the generator file. If your change applies to all samples, update the common generator file inside the `template` folder. Edit the generator file in this folder only when the change should affect this sample alone.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Simple Signal Workflow
2+
3+
This workflow takes an input message and greet you as response. Try the following CLI
4+
5+
```bash
6+
cadence --env development \
7+
--domain cadence-samples \
8+
workflow start \
9+
--tl cadence-samples-worker \
10+
--et 60 \
11+
--workflow_type cadence_samples.SimpleSignalWorkflow
12+
```
13+
14+
Verify that your workflow started. Your can find your worklow by looking at the "Workflow type" column.
15+
16+
If this is your first sample, please refer to [HelloWorkflow sample](https://github.com/cadence-workflow/cadence-samples/tree/master/new_samples/hello_world) about how to view your workflows.
17+
18+
19+
### Signal your workflow
20+
21+
This workflow will need a signal to complete successfully. Below is how you can send a signal. In this example, we are sending a `bool` value `true` (JSON formatted) via the signal called `complete`
22+
23+
```bash
24+
cadence --env development \
25+
--domain cadence-samples \
26+
workflow signal \
27+
--wid <workflow_id> \
28+
--name complete \
29+
--input 'true'
30+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package main
2+
3+
import "github.com/uber-common/cadence-samples/new_samples/template"
4+
5+
func main() {
6+
// Define the data for HelloWorld
7+
data := template.TemplateData{
8+
SampleName: "Signal Workflow",
9+
Workflows: []string{"SimpleSignalWorkflow"},
10+
Activities: []string{"SimpleSignalActivity"},
11+
}
12+
13+
template.GenerateAll(data)
14+
}
15+
16+
// Implement custom generator below

0 commit comments

Comments
 (0)