Skip to content

Commit 900008a

Browse files
Eliminate domain registration step from samples because Cadence comes with 'default' domain now (#89)
1 parent 6739dd6 commit 900008a

File tree

15 files changed

+30
-185
lines changed

15 files changed

+30
-185
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test.log
1414
vendor/
1515
# Executables produced by cadence-samples repo
1616
bin/
17+
docker-compose.yml

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Cadence Samples ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/uber-common/cadence-samples/build.yml)
22

33
These are some samples to demostrate various capabilities of Cadence client and server. You can learn more about cadence at:
4-
* Cadence: https://github.com/uber/cadence
5-
* Cadence Client: https://github.com/uber-go/cadence-client
4+
* Cadence Server: https://github.com/cadence-workflow/cadence
5+
* Cadence Client: https://github.com/cadence-workflow/cadence-go-client
66

7-
## Prerequisite
8-
Run Cadence Server
7+
## Prerequisite for running samples
98

10-
See instructions for running the Cadence Server: https://github.com/uber/cadence/blob/master/README.md
11-
12-
See instructions for using CLI to register a domain(name as "samples-domain"): https://cadenceworkflow.io/docs/cli/#quick-start
13-
or https://github.com/uber/cadence/blob/master/tools/cli/README.md
9+
Run Cadence server:
10+
```
11+
curl -LO https://raw.githubusercontent.com/cadence-workflow/cadence/refs/heads/master/docker/docker-compose.yml
12+
docker-compose up
13+
```
1414

1515

1616
## Steps to run samples
@@ -20,10 +20,12 @@ make
2020
```
2121

2222
### Run HelloWorld Sample
23+
2324
* Start workers for helloworld workflow and activities
2425
```
2526
./bin/helloworld -m worker
2627
```
28+
2729
* Start workflow execution for helloworld workflow
2830
```
2931
./bin/helloworld -m trigger

cmd/samples/README.md

Lines changed: 0 additions & 160 deletions
This file was deleted.

cmd/samples/expense/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ This sample workflow process an expense request. The key part of this sample is
33

44
# Sample Description
55
* Create a new expense report.
6-
* Wait for the expense report to be approved. This could take an arbitrary amount of time. So the activity's Execute method has to return before it is actually approved. This is done by returning a special error so the framework knows the activity is not completed yet.
7-
* When the expense is approved (or rejected), somewhere in the world needs to be notified, and it will need to call WorkflowClient.CompleteActivity() to tell cadence service that that activity is now completed. In this sample case, the dummy server do this job. In real world, you will need to register some listener to the expense system or you will need to have your own pulling agent to check for the expense status periodic.
6+
* Wait for the expense report to be approved. This could take an arbitrary amount of time. So the activity's Execute method has to return before it is actually approved. This is done by returning a special error so the framework knows the activity is not completed yet.
7+
* When the expense is approved (or rejected), somewhere in the world needs to be notified, and it will need to call WorkflowClient.CompleteActivity() to tell cadence service that that activity is now completed. In this sample case, the dummy server do this job. In real world, you will need to register some listener to the expense system or you will need to have your own pulling agent to check for the expense status periodic.
88
* After the wait activity is completed, it did the payment for the expense. (dummy step in this sample case)
99

1010
This sample rely on an a dummy expense server to work.
1111

1212
# Steps To Run Sample
13-
* You need a cadence service running. See https://github.com/uber/cadence/blob/master/README.md for more details.
14-
* Start the dummy server
13+
* You need a cadence service running. See https://github.com/cadence-workflow/cadence/blob/master/README.md for more details.
14+
* Start the dummy server
1515
```
1616
./bin/expense_dummy
1717
```

cmd/samples/pageflow/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ User interactions are implemented through workflow signals, and the latest workf
77
You should be able to inspect workflow run through Cadence UI (http://localhost:8088/ if you use the standard Cadence docker image).
88

99
# Steps to run locally
10-
Make sure you start cadence server first and create the "samples-domain" domain.
10+
Make sure you start cadence server first.
1111

1212
### `npm install`
1313
Make sure you are running at least node v14 (`nvm use 14`) and install dependencies. May take a while for the first time installing these packages.

cmd/samples/pageflow/src/server/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const config = {
55
port: '4000',
66
},
77
cadence: {
8-
domain: 'samples-domain',
8+
domain: 'default',
99
executionStartToCloseTimeoutSeconds: 10 * 60, // workflow open for 10 minutes
1010
retryDelay: 100,
1111
retryMax: 5,

cmd/samples/recipes/cancelactivity/workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func sampleCancelWorkflow(ctx workflow.Context) (retError error) {
6565

6666
func activityToBeCanceled(ctx context.Context) (string, error) {
6767
logger := activity.GetLogger(ctx)
68-
logger.Info("activity started, to cancel workflow, use ./cancelactivity -m cancel -w <WorkflowID> or CLI: 'cadence --do samples-domain wf cancel -w <WorkflowID>' to cancel")
68+
logger.Info("activity started, to cancel workflow, use ./cancelactivity -m cancel -w <WorkflowID> or CLI: 'cadence --do default wf cancel -w <WorkflowID>' to cancel")
6969
for {
7070
select {
7171
case <-time.After(1 * time.Second):

cmd/samples/recipes/greetings/replay_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// This replay test is the recommended way to make sure changing workflow code is backward compatible without non-deterministic errors.
1313
// "greetings.json" can be downloaded from cadence CLI:
1414
//
15-
// cadence --do samples-domain wf show -w greetings_5d5f8e5c-4807-444d-9dc5-80abea22a324 --output_filename ~/tmp/greetings.json
15+
// cadence --do default wf show -w greetings_5d5f8e5c-4807-444d-9dc5-80abea22a324 --output_filename ~/tmp/greetings.json
1616
//
1717
// Or from Cadence Web UI. And you may need to change workflowType in the first event.
1818
func TestReplayWorkflowHistoryFromFile(t *testing.T) {

cmd/samples/recipes/helloworld/replay_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import (
1111

1212
// This replay test is the recommended way to make sure changing workflow code is backward compatible without non-deterministic errors.
1313
// "helloworld.json" can be downloaded from cadence CLI:
14-
// cadence --do samples-domain wf show -w helloworld_d002cd3a-aeee-4a11-aa30-1c62385b4d87 --output_filename ~/tmp/helloworld.json
14+
//
15+
// cadence --do default wf show -w helloworld_d002cd3a-aeee-4a11-aa30-1c62385b4d87 --output_filename ~/tmp/helloworld.json
16+
//
1517
// Or from Cadence Web UI. And you may need to change workflowType in the first event.
1618
func TestReplayWorkflowHistoryFromFile(t *testing.T) {
1719
replayer := worker.NewWorkflowReplayer()

cmd/samples/recipes/searchattributes/searchattributes_workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type ClientKey int
2929

3030
const (
3131
// DomainName used for this sample
32-
DomainName = "samples-domain"
32+
DomainName = "default"
3333
// CadenceClientKey for retrieving cadence client from context
3434
CadenceClientKey ClientKey = iota
3535
)

0 commit comments

Comments
 (0)