Skip to content

Commit f898d61

Browse files
authored
Merge pull request #26 from cicoyle/feat-cross-app-wf
Feat cross app wf
2 parents 07b13de + e70f126 commit f898d61

File tree

11 files changed

+140
-66
lines changed

11 files changed

+140
-66
lines changed

CONTRIBUTING.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Contributing
2+
3+
## Cloning this repository
4+
5+
This repository contains submodules. Be sure to clone it with the option to include submodules. Otherwise, you will not be able to generate the protobuf code.
6+
7+
```bash
8+
git clone --recurse-submodules https://github.com/dapr/durabletask-go
9+
```
10+
11+
If you already cloned the repository without `--recurse-submodules`, you can initialize and update the submodules with:
12+
13+
```bash
14+
git submodule update --init --recursive
15+
```
16+
17+
To grab latest, do some variation of the following nuke your existing submodule folder then run:
18+
```bash
19+
rm -rf submodules/durabletask-protobuf
20+
git submodule add --force https://github.com/dapr/durabletask-protobuf.git submodules/durabletask-protobuf
21+
git submodule update --remote submodules/durabletask-protobuf
22+
```
23+
24+
This will initialize and update the submodules.
25+
26+
## Building the project
27+
28+
This project requires go v1.19.x or greater. You can build a standalone executable by simply running `go build` at the project root.
29+
30+
### Generating protobuf
31+
32+
Use the following command to regenerate the protobuf from the submodule. Use this whenever updating the submodule reference.
33+
34+
```bash
35+
# Run from the repo root and specify the output directory
36+
# This will place the generated files directly in api/protos/, matching the go_package and your repo structure.
37+
protoc --go_out=. --go-grpc_out=. \
38+
-I submodules/durabletask-protobuf/protos \
39+
submodules/durabletask-protobuf/protos/orchestrator_service.proto \
40+
submodules/durabletask-protobuf/protos/backend_service.proto \
41+
submodules/durabletask-protobuf/protos/runtime_state.proto
42+
```
43+
44+
For local development with protobuf changes:
45+
46+
1. If you have local changes to the proto files in a neighboring durabletask-protobuf directory:
47+
```bash
48+
# Point go.mod to your local durabletask-protobuf repo
49+
replace github.com/dapr/durabletask-protobuf => ../durabletask-protobuf
50+
51+
# Regenerate protobuf files using your local proto definitions
52+
protoc --go_out=. --go-grpc_out=. \
53+
-I ../durabletask-protobuf/protos \
54+
../durabletask-protobuf/protos/orchestrator_service.proto \
55+
../durabletask-protobuf/protos/backend_service.proto \
56+
../durabletask-protobuf/protos/runtime_state.proto
57+
```
58+
59+
This will use your local proto files instead of the ones in the submodule, which is useful when testing protobuf changes before submitting them upstream.
60+
61+
### Generating mocks for testing
62+
63+
Test mocks were generated using [mockery](https://github.com/vektra/mockery). Use the following command at the project root to regenerate the mocks.
64+
65+
```bash
66+
mockery --dir ./backend --name="^Backend|^Executor|^TaskWorker" --output ./tests/mocks --with-expecter
67+
```
68+
69+
## Running tests
70+
71+
All automated tests are under `./tests`. A separate test package hierarchy was chosen intentionally to prioritize [black box testing](https://en.wikipedia.org/wiki/Black-box_testing). This strategy also makes it easier to catch accidental breaking API changes.
72+
73+
Run tests with the following command.
74+
75+
```bash
76+
go test ./tests/... -coverpkg ./api,./task,./client,./backend/...,./api/helpers
77+
```

README.md

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -243,46 +243,6 @@ You can find this code in the [distributedtracing](./samples/distributedtracing)
243243

244244
Note that each orchestration is represented as a single span with activities, timers, and sub-orchestrations as child spans. The generated spans contain a variety of attributes that include information such as orchestration instance IDs, task names, task IDs, etc.
245245

246-
## Cloning this repository
247-
248-
This repository contains submodules. Be sure to clone it with the option to include submodules. Otherwise you will not be able to generate the protobuf code.
249-
250-
```bash
251-
git clone --recurse-submodules https://github.com/dapr/durabletask-go
252-
```
253-
254-
## Building the project
255-
256-
This project requires go v1.19.x or greater. You can build a standalone executable by simply running `go build` at the project root.
257-
258-
### Generating protobuf
259-
260-
Use the following command to regenerate the protobuf from the submodule. Use this whenever updating the submodule reference.
261-
262-
```bash
263-
# NOTE: assumes the .proto file defines: option go_package = "/api/protos"
264-
# NOTE: currently the .proto file actually defines: option go_package = "/internal/protos"; , we are manually changing that to be /api/protos
265-
protoc --go_out=. --go-grpc_out=. -I submodules/durabletask-protobuf/protos orchestrator_service.proto
266-
```
267-
268-
### Generating mocks for testing
269-
270-
Test mocks were generated using [mockery](https://github.com/vektra/mockery). Use the following command at the project root to regenerate the mocks.
271-
272-
```bash
273-
mockery --dir ./backend --name="^Backend|^Executor|^TaskWorker" --output ./tests/mocks --with-expecter
274-
```
275-
276-
## Running tests
277-
278-
All automated tests are under `./tests`. A separate test package hierarchy was chosen intentionally to prioritize [black box testing](https://en.wikipedia.org/wiki/Black-box_testing). This strategy also makes it easier to catch accidental breaking API changes.
279-
280-
Run tests with the following command.
281-
282-
```bash
283-
go test ./tests/... -coverpkg ./api,./task,./client,./backend/...,./api/helpers
284-
```
285-
286246
## Running integration tests
287247

288248
You can run pre-built container images to run full integration tests against the durable task host over gRPC.

api/protos/backend_service.pb.go

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protos/orchestrator_service.pb.go

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protos/orchestrator_service_grpc.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protos/runtime_state.pb.go

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/executor.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ func (executor *grpcExecutor) ExecuteActivity(ctx context.Context, iid api.Insta
217217
FailureDetails: failureDetails,
218218
},
219219
},
220+
Router: e.Router,
220221
}
221222
} else {
222223
responseEvent = &protos.HistoryEvent{
@@ -229,6 +230,7 @@ func (executor *grpcExecutor) ExecuteActivity(ctx context.Context, iid api.Insta
229230
TaskExecutionId: task.TaskExecutionId,
230231
},
231232
},
233+
Router: e.Router,
232234
}
233235
}
234236

backend/runtimestate/runtimestate.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func ApplyActions(s *protos.OrchestrationRuntimeState, customStatus *wrapperspb.
9292
EventType: &protos.HistoryEvent_OrchestratorStarted{
9393
OrchestratorStarted: &protos.OrchestratorStartedEvent{},
9494
},
95+
Router: action.Router,
9596
})
9697

9798
// Duplicate the start event info, updating just the input
@@ -111,6 +112,7 @@ func ApplyActions(s *protos.OrchestrationRuntimeState, customStatus *wrapperspb.
111112
ParentTraceContext: s.StartEvent.ParentTraceContext,
112113
},
113114
},
115+
Router: action.Router,
114116
},
115117
)
116118

@@ -135,6 +137,7 @@ func ApplyActions(s *protos.OrchestrationRuntimeState, customStatus *wrapperspb.
135137
FailureDetails: completedAction.FailureDetails,
136138
},
137139
},
140+
Router: action.Router,
138141
})
139142
if s.StartEvent.GetParentInstance() != nil {
140143
msg := &protos.OrchestrationRuntimeStateMessage{
@@ -170,6 +173,7 @@ func ApplyActions(s *protos.OrchestrationRuntimeState, customStatus *wrapperspb.
170173
Name: createtimer.Name,
171174
},
172175
},
176+
Router: action.Router,
173177
})
174178
// TODO cant pass trace context
175179
s.PendingTimers = append(s.PendingTimers, &protos.HistoryEvent{
@@ -195,6 +199,7 @@ func ApplyActions(s *protos.OrchestrationRuntimeState, customStatus *wrapperspb.
195199
ParentTraceContext: currentTraceContext,
196200
},
197201
},
202+
Router: action.Router,
198203
}
199204
AddEvent(s, scheduledEvent)
200205
s.PendingTasks = append(s.PendingTasks, scheduledEvent)
@@ -216,6 +221,7 @@ func ApplyActions(s *protos.OrchestrationRuntimeState, customStatus *wrapperspb.
216221
ParentTraceContext: currentTraceContext,
217222
},
218223
},
224+
Router: action.Router,
219225
})
220226
startEvent := &protos.HistoryEvent{
221227
EventId: -1,
@@ -236,6 +242,7 @@ func ApplyActions(s *protos.OrchestrationRuntimeState, customStatus *wrapperspb.
236242
ParentTraceContext: currentTraceContext,
237243
},
238244
},
245+
Router: action.Router,
239246
}
240247

241248
s.PendingMessages = append(s.PendingMessages, &protos.OrchestrationRuntimeStateMessage{HistoryEvent: startEvent, TargetInstanceID: createSO.InstanceId})
@@ -250,6 +257,7 @@ func ApplyActions(s *protos.OrchestrationRuntimeState, customStatus *wrapperspb.
250257
Input: sendEvent.Data,
251258
},
252259
},
260+
Router: action.Router,
253261
}
254262
AddEvent(s, e)
255263
s.PendingMessages = append(s.PendingMessages, &protos.OrchestrationRuntimeStateMessage{HistoryEvent: e, TargetInstanceID: sendEvent.Instance.InstanceId})
@@ -266,6 +274,7 @@ func ApplyActions(s *protos.OrchestrationRuntimeState, customStatus *wrapperspb.
266274
Recurse: terminate.Recurse,
267275
},
268276
},
277+
Router: action.Router,
269278
},
270279
}
271280
s.PendingMessages = append(s.PendingMessages, msg)

submodules/durabletask-protobuf

task/activity.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type callActivityOption func(*callActivityOptions) error
1616
type callActivityOptions struct {
1717
rawInput *wrapperspb.StringValue
1818
retryPolicy *RetryPolicy
19+
targetAppID *string
1920
}
2021

2122
type RetryPolicy struct {
@@ -58,6 +59,13 @@ func (policy *RetryPolicy) Validate() error {
5859
return nil
5960
}
6061

62+
func WithAppID(targetAppID string) callActivityOption {
63+
return func(opt *callActivityOptions) error {
64+
opt.targetAppID = &targetAppID
65+
return nil
66+
}
67+
}
68+
6169
// WithActivityInput configures an input for an activity invocation.
6270
// The specified input must be JSON serializable.
6371
func WithActivityInput(input any) callActivityOption {

0 commit comments

Comments
 (0)