Commit 101bb90
committed
feat(#2790): Add ChildWorkflowOptions support to WorkflowImplementationOptions
Fixes #2790
Allow predefining ChildWorkflowOptions on WorkflowImplementationOptions,
mirroring the existing ActivityOptions, LocalActivityOptions and
NexusServiceOptions support:
- Add setChildWorkflowOptions(Map) and setDefaultChildWorkflowOptions()
builder methods, matching getters, and equals/hashCode/toString/
toBuilder support on WorkflowImplementationOptions
- Expose the options through SyncWorkflowContext, served directly from
the immutable WorkflowImplementationOptions
- Add ChildWorkflowOptions.Builder#mergeChildWorkflowOptions(): non-null
override fields win, except contextPropagators lists are concatenated
(matching ActivityOptions.Builder#mergeActivityOptions), the mutually
exclusive searchAttributes/typedSearchAttributes are merged as one
logical field so the merged options never carry both flavors, and
VERSIONING_INTENT_UNSPECIFIED is treated as unset
- Resolve the predefined options for both typed and untyped child stubs
(WorkflowInternal.newChildWorkflowStub and newUntypedChildWorkflowStub,
so DynamicWorkflow parents are covered too) with the following
precedence, highest to lowest, merged field by field: options passed
to the stub creation method > per-type options (setChildWorkflowOptions)
> default options (setDefaultChildWorkflowOptions)
- Keep child stub creation cost unchanged: the interface metadata is
computed once and passed into ChildWorkflowInvocationHandler instead
of being reflectively re-derived
- Keep the previous public WorkflowImplementationOptions constructor as
a backward-compatible delegating overload
- Document the new behavior on the Workflow child stub factory methods
and warn against predefining workflowId, which would be applied to
every child of the matching scope
Fix child workflow options precedence: the predefined options were
merged in the wrong order, so when no options were passed to
newChildWorkflowStub the default options overrode the per-type options.
The default options have the lowest precedence and must never override
per-type options. The merge order is now correct, and the javadocs on
setChildWorkflowOptions and setDefaultChildWorkflowOptions describe the
actual precedence.
Tests:
- Verify the applied options through the child's memo in
DefaultChildWorkflowOptionsSetOnWorkflowTest (covering default,
per-type, explicit and field-level merge precedence for both typed
and untyped stubs), so a test only passes if the expected options
actually took effect
- Add an exhaustive unit test for
ChildWorkflowOptions#mergeChildWorkflowOptions that exercises every
field, plus dedicated tests for the search attribute flavors, context
propagator concatenation and unspecified versioning intent
Signed-off-by: Oleksandr Porunov <alexandr.porunov@gmail.com>1 parent f86c766 commit 101bb90
8 files changed
Lines changed: 795 additions & 11 deletions
File tree
- temporal-sdk/src
- main/java/io/temporal
- internal/sync
- worker
- workflow
- test/java/io/temporal/workflow
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
218 | 230 | | |
219 | 231 | | |
220 | 232 | | |
| |||
Lines changed: 36 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
394 | 401 | | |
395 | 402 | | |
396 | 403 | | |
397 | 404 | | |
398 | 405 | | |
399 | | - | |
| 406 | + | |
400 | 407 | | |
401 | | - | |
| 408 | + | |
402 | 409 | | |
403 | 410 | | |
404 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
405 | 436 | | |
406 | 437 | | |
407 | 438 | | |
| |||
434 | 465 | | |
435 | 466 | | |
436 | 467 | | |
| 468 | + | |
| 469 | + | |
437 | 470 | | |
438 | 471 | | |
439 | 472 | | |
440 | | - | |
| 473 | + | |
441 | 474 | | |
442 | 475 | | |
443 | 476 | | |
| |||
Lines changed: 100 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| 63 | + | |
| 64 | + | |
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
| |||
158 | 163 | | |
159 | 164 | | |
160 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
161 | 209 | | |
162 | 210 | | |
163 | 211 | | |
| |||
187 | 235 | | |
188 | 236 | | |
189 | 237 | | |
| 238 | + | |
| 239 | + | |
190 | 240 | | |
191 | 241 | | |
192 | 242 | | |
| |||
198 | 248 | | |
199 | 249 | | |
200 | 250 | | |
| 251 | + | |
| 252 | + | |
201 | 253 | | |
202 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
203 | 259 | | |
204 | 260 | | |
205 | 261 | | |
| |||
209 | 265 | | |
210 | 266 | | |
211 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
212 | 292 | | |
213 | 293 | | |
214 | 294 | | |
215 | 295 | | |
216 | 296 | | |
217 | 297 | | |
218 | 298 | | |
| 299 | + | |
| 300 | + | |
219 | 301 | | |
220 | 302 | | |
221 | 303 | | |
| |||
253 | 335 | | |
254 | 336 | | |
255 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
256 | 348 | | |
257 | 349 | | |
258 | 350 | | |
| |||
275 | 367 | | |
276 | 368 | | |
277 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
278 | 374 | | |
279 | 375 | | |
280 | 376 | | |
| |||
292 | 388 | | |
293 | 389 | | |
294 | 390 | | |
| 391 | + | |
| 392 | + | |
295 | 393 | | |
296 | 394 | | |
297 | 395 | | |
| |||
306 | 404 | | |
307 | 405 | | |
308 | 406 | | |
| 407 | + | |
| 408 | + | |
309 | 409 | | |
310 | 410 | | |
311 | 411 | | |
| |||
Lines changed: 84 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
341 | 425 | | |
342 | 426 | | |
343 | 427 | | |
| |||
0 commit comments