@temporalio/core-bridge 1.13.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +350 -436
- package/Cargo.toml +14 -13
- package/{sdk-core/fsm/rustfsm_procmacro/LICENSE.txt → LICENSE} +5 -5
- package/README.md +0 -1
- package/bridge-macros/Cargo.toml +16 -0
- package/bridge-macros/src/derive_js_function.rs +126 -0
- package/bridge-macros/src/derive_tryfromjs.rs +138 -0
- package/bridge-macros/src/derive_tryintojs.rs +151 -0
- package/bridge-macros/src/lib.rs +42 -0
- package/lib/native.d.ts +23 -9
- package/package.json +6 -5
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.cargo/config.toml +78 -12
- package/sdk-core/.clippy.toml +1 -0
- package/sdk-core/.github/workflows/heavy.yml +2 -0
- package/sdk-core/.github/workflows/per-pr.yml +90 -21
- package/sdk-core/AGENTS.md +17 -19
- package/sdk-core/ARCHITECTURE.md +44 -48
- package/sdk-core/Cargo.toml +25 -7
- package/sdk-core/README.md +16 -15
- package/sdk-core/arch_docs/diagrams/TimerMachine_Coverage.puml +14 -0
- package/sdk-core/arch_docs/diagrams/deps.svg +102 -0
- package/sdk-core/arch_docs/diagrams/initial_event_history.png +0 -0
- package/sdk-core/arch_docs/sdks_intro.md +299 -0
- package/sdk-core/{client → crates/client}/Cargo.toml +15 -16
- package/sdk-core/{client → crates/client}/src/callback_based.rs +1 -2
- package/sdk-core/{client → crates/client}/src/lib.rs +594 -457
- package/sdk-core/{client → crates/client}/src/metrics.rs +32 -8
- package/sdk-core/crates/client/src/proxy.rs +209 -0
- package/sdk-core/{client → crates/client}/src/raw.rs +648 -328
- package/sdk-core/crates/client/src/replaceable.rs +253 -0
- package/sdk-core/crates/client/src/request_extensions.rs +40 -0
- package/sdk-core/{client → crates/client}/src/retry.rs +32 -22
- package/sdk-core/crates/client/src/worker/mod.rs +1468 -0
- package/sdk-core/{client → crates/client}/src/workflow_handle/mod.rs +24 -21
- package/sdk-core/{core-api → crates/common}/Cargo.toml +21 -12
- package/sdk-core/{sdk-core-protos → crates/common}/build.rs +10 -23
- package/sdk-core/crates/common/protos/api_cloud_upstream/VERSION +1 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/account/v1/message.proto +18 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +38 -11
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +21 -4
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +6 -6
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/sink/v1/message.proto +22 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/create-release.yml +13 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv2.json +254 -5
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv3.yaml +234 -5
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/common/v1/message.proto +1 -1
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/deployment/v1/message.proto +6 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -2
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -2
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +30 -6
- package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
- package/sdk-core/{core-api → crates/common}/src/envconfig.rs +155 -56
- package/sdk-core/{core-api → crates/common}/src/errors.rs +8 -1
- package/sdk-core/{fsm/rustfsm_trait/src/lib.rs → crates/common/src/fsm_trait.rs} +1 -27
- package/sdk-core/{core-api → crates/common}/src/lib.rs +92 -9
- package/sdk-core/{test-utils/src → crates/common/src/protos}/canned_histories.rs +5 -5
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_builder.rs +3 -3
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_info.rs +2 -2
- package/sdk-core/{sdk-core-protos/src/lib.rs → crates/common/src/protos/mod.rs} +43 -26
- package/sdk-core/crates/common/src/protos/test_utils.rs +89 -0
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/utilities.rs +14 -5
- package/sdk-core/{core-api → crates/common}/src/telemetry/metrics.rs +449 -51
- package/sdk-core/{core-api → crates/common}/src/telemetry.rs +16 -1
- package/sdk-core/{core-api → crates/common}/src/worker.rs +112 -18
- package/sdk-core/crates/common/tests/worker_task_types_test.rs +129 -0
- package/sdk-core/crates/macros/Cargo.toml +23 -0
- package/sdk-core/{fsm/rustfsm_procmacro → crates/macros}/src/lib.rs +12 -12
- package/sdk-core/{sdk → crates/sdk}/Cargo.toml +18 -12
- package/sdk-core/{sdk → crates/sdk}/src/activity_context.rs +9 -7
- package/sdk-core/{sdk → crates/sdk}/src/app_data.rs +1 -1
- package/sdk-core/{sdk → crates/sdk}/src/interceptors.rs +2 -5
- package/sdk-core/{sdk → crates/sdk}/src/lib.rs +43 -42
- package/sdk-core/{sdk → crates/sdk}/src/workflow_context/options.rs +12 -3
- package/sdk-core/{sdk → crates/sdk}/src/workflow_context.rs +21 -19
- package/sdk-core/{sdk → crates/sdk}/src/workflow_future.rs +2 -2
- package/sdk-core/crates/sdk-core/Cargo.toml +222 -0
- package/sdk-core/{core/benches/workflow_replay.rs → crates/sdk-core/benches/workflow_replay_bench.rs} +15 -10
- package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +32 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CancelExternalMachine_Coverage.puml +9 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CancelWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ChildWorkflowMachine_Coverage.puml +27 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CompleteWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ContinueAsNewWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/FailWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/LocalActivityMachine_Coverage.puml +23 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ModifyWorkflowPropertiesMachine_Coverage.puml +5 -0
- package/sdk-core/crates/sdk-core/machine_coverage/PatchMachine_Coverage.puml +8 -0
- package/sdk-core/crates/sdk-core/machine_coverage/SignalExternalMachine_Coverage.puml +12 -0
- package/sdk-core/crates/sdk-core/machine_coverage/TimerMachine_Coverage.puml +13 -0
- package/sdk-core/crates/sdk-core/machine_coverage/UpdateMachine_Coverage.puml +19 -0
- package/sdk-core/crates/sdk-core/machine_coverage/UpsertSearchAttributesMachine_Coverage.puml +5 -0
- package/sdk-core/crates/sdk-core/machine_coverage/WorkflowTaskMachine_Coverage.puml +11 -0
- package/sdk-core/{core → crates/sdk-core}/src/abstractions.rs +62 -6
- package/sdk-core/crates/sdk-core/src/antithesis.rs +60 -0
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/activity_tasks.rs +85 -250
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/mod.rs +13 -16
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/queries.rs +25 -24
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/replay_flag.rs +11 -68
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/updates.rs +21 -20
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workers.rs +242 -16
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_cancels.rs +10 -7
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_tasks.rs +150 -326
- package/sdk-core/{core → crates/sdk-core}/src/debug_client.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/ephemeral_server/mod.rs +18 -6
- package/sdk-core/{test-utils → crates/sdk-core}/src/histfetch.rs +9 -4
- package/sdk-core/{core → crates/sdk-core}/src/internal_flags.rs +15 -4
- package/sdk-core/{core → crates/sdk-core}/src/lib.rs +128 -72
- package/sdk-core/{core → crates/sdk-core}/src/pollers/mod.rs +13 -11
- package/sdk-core/{core → crates/sdk-core}/src/pollers/poll_buffer.rs +53 -18
- package/sdk-core/{core → crates/sdk-core}/src/protosext/mod.rs +14 -6
- package/sdk-core/{core → crates/sdk-core}/src/protosext/protocol_messages.rs +5 -12
- package/sdk-core/{core → crates/sdk-core}/src/replay/mod.rs +14 -11
- package/sdk-core/crates/sdk-core/src/retry_logic.rs +390 -0
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/log_export.rs +2 -2
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/metrics.rs +80 -33
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/mod.rs +12 -6
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/otel.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_meter.rs +14 -14
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_server.rs +2 -2
- package/sdk-core/{core/src/test_help/mod.rs → crates/sdk-core/src/test_help/integ_helpers.rs} +284 -329
- package/sdk-core/crates/sdk-core/src/test_help/mod.rs +13 -0
- package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +220 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities/activity_heartbeat_manager.rs +44 -8
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities/local_activities.rs +33 -31
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities.rs +31 -15
- package/sdk-core/{core → crates/sdk-core}/src/worker/client/mocks.rs +28 -15
- package/sdk-core/{core → crates/sdk-core}/src/worker/client.rs +275 -145
- package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +246 -0
- package/sdk-core/crates/sdk-core/src/worker/mod.rs +1462 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/nexus.rs +24 -12
- package/sdk-core/{core → crates/sdk-core}/src/worker/slot_provider.rs +18 -10
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/fixed_size.rs +5 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/resource_based.rs +453 -57
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner.rs +179 -3
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/driven_workflow.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/history_update.rs +5 -267
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/activity_state_machine.rs +147 -90
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_external_state_machine.rs +8 -91
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_nexus_op_state_machine.rs +14 -12
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +97 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/child_workflow_state_machine.rs +32 -229
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/complete_workflow_state_machine.rs +13 -8
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +6 -50
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/fail_workflow_state_machine.rs +6 -7
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/local_activity_state_machine.rs +39 -584
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/mod.rs +22 -17
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +4 -74
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/nexus_operation_state_machine.rs +118 -21
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/patch_state_machine.rs +273 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/signal_external_state_machine.rs +9 -151
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/timer_state_machine.rs +27 -132
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/transition_coverage.rs +1 -2
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/update_state_machine.rs +19 -13
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +25 -80
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines/local_acts.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines.rs +68 -72
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_task_state_machine.rs +13 -15
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/managed_run.rs +55 -37
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/mod.rs +171 -61
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/run_cache.rs +10 -7
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_extraction.rs +4 -2
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_poller.rs +15 -4
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/workflow_stream.rs +38 -19
- package/sdk-core/crates/sdk-core/tests/c_bridge_smoke_test.c +10 -0
- package/sdk-core/crates/sdk-core/tests/cloud_tests.rs +25 -0
- package/sdk-core/crates/sdk-core/tests/common/fake_grpc_server.rs +106 -0
- package/sdk-core/crates/sdk-core/tests/common/http_proxy.rs +134 -0
- package/sdk-core/{test-utils/src/lib.rs → crates/sdk-core/tests/common/mod.rs} +286 -334
- package/sdk-core/{test-utils/src → crates/sdk-core/tests/common}/workflows.rs +6 -4
- package/sdk-core/crates/sdk-core/tests/fsm_procmacro.rs +6 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dupe_transitions_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/dupe_transitions_fail.stderr +12 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dynamic_dest_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.rs +1 -3
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.stderr +4 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_arg_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/medium_complex_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/no_handle_conversions_require_into_fail.rs +2 -4
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/no_handle_conversions_require_into_fail.stderr +15 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/simple_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/struct_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/struct_event_variant_fail.stderr +5 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_more_item_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_more_item_event_variant_fail.stderr +5 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_zero_item_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_zero_item_event_variant_fail.stderr +5 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/global_metric_tests.rs +22 -22
- package/sdk-core/{tests → crates/sdk-core/tests/heavy_tests}/fuzzy_workflow.rs +4 -4
- package/sdk-core/{tests → crates/sdk-core/tests}/heavy_tests.rs +25 -14
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/activity_functions.rs +1 -1
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/client_tests.rs +115 -123
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/ephemeral_server_tests.rs +19 -15
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/heartbeat_tests.rs +24 -20
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/metrics_tests.rs +241 -67
- package/sdk-core/crates/sdk-core/tests/integ_tests/pagination_tests.rs +273 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/polling_tests.rs +513 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/queries_tests.rs +13 -11
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/update_tests.rs +47 -29
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/visibility_tests.rs +49 -27
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +1061 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +920 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/worker_versioning_tests.rs +58 -40
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/activities.rs +268 -30
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/appdata_propagation.rs +4 -4
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +155 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +121 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +717 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +109 -0
- package/sdk-core/{core/src/core_tests → crates/sdk-core/tests/integ_tests/workflow_tests}/determinism.rs +108 -20
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/eager.rs +10 -5
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +2884 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +119 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/nexus.rs +174 -46
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +740 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/replay.rs +78 -27
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/resets.rs +46 -28
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +294 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/stickyness.rs +9 -8
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +249 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/upsert_search_attrs.rs +72 -7
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests.rs +97 -33
- package/sdk-core/{tests → crates/sdk-core/tests}/main.rs +40 -25
- package/sdk-core/{tests → crates/sdk-core/tests}/manual_tests.rs +25 -15
- package/sdk-core/{tests → crates/sdk-core/tests}/runner.rs +23 -41
- package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/mod.rs +11 -6
- package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/priority.rs +6 -6
- package/sdk-core/crates/sdk-core-c-bridge/Cargo.toml +59 -0
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/include/temporal-sdk-core-c-bridge.h +215 -44
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/client.rs +515 -214
- package/sdk-core/crates/sdk-core-c-bridge/src/envconfig.rs +314 -0
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/lib.rs +2 -1
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/metric.rs +1 -1
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/random.rs +4 -4
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/runtime.rs +42 -28
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/testing.rs +2 -5
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/context.rs +42 -41
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/mod.rs +38 -34
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/utils.rs +10 -11
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/worker.rs +427 -121
- package/sdk-core/docker-cgroup-tests.sh +24 -0
- package/sdk-core/{docker → etc/docker}/docker-compose-ci.yaml +9 -9
- package/sdk-core/{docker → etc/docker}/docker-compose-telem.yaml +11 -11
- package/sdk-core/{docker → etc/docker}/docker-compose.yaml +8 -8
- package/sdk-core/{integ-with-otel.sh → etc/integ-with-otel.sh} +1 -1
- package/sdk-core/etc/regen-depgraph.sh +2 -2
- package/src/client.rs +117 -49
- package/src/helpers/callbacks.rs +4 -4
- package/src/helpers/errors.rs +7 -1
- package/src/helpers/handles.rs +1 -0
- package/src/helpers/try_from_js.rs +5 -4
- package/src/lib.rs +3 -2
- package/src/logs.rs +1 -1
- package/src/metrics.rs +6 -3
- package/src/runtime.rs +41 -24
- package/src/testing.rs +3 -3
- package/src/worker.rs +77 -44
- package/ts/native.ts +26 -9
- package/LICENSE.md +0 -23
- package/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
- package/sdk-core/client/src/proxy.rs +0 -90
- package/sdk-core/client/src/worker_registry/mod.rs +0 -266
- package/sdk-core/core/Cargo.toml +0 -146
- package/sdk-core/core/src/core_tests/child_workflows.rs +0 -281
- package/sdk-core/core/src/core_tests/local_activities.rs +0 -1442
- package/sdk-core/core/src/retry_logic.rs +0 -224
- package/sdk-core/core/src/worker/heartbeat.rs +0 -231
- package/sdk-core/core/src/worker/mod.rs +0 -980
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -165
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +0 -801
- package/sdk-core/core-c-bridge/Cargo.toml +0 -51
- package/sdk-core/etc/deps.svg +0 -162
- package/sdk-core/fsm/Cargo.toml +0 -21
- package/sdk-core/fsm/README.md +0 -3
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +0 -27
- package/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +0 -8
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +0 -12
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +0 -15
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_trait/Cargo.toml +0 -14
- package/sdk-core/fsm/rustfsm_trait/LICENSE.txt +0 -21
- package/sdk-core/fsm/src/lib.rs +0 -2
- package/sdk-core/sdk-core-protos/Cargo.toml +0 -37
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +0 -1
- package/sdk-core/test-utils/Cargo.toml +0 -38
- package/sdk-core/test-utils/src/interceptors.rs +0 -46
- package/sdk-core/tests/cloud_tests.rs +0 -23
- package/sdk-core/tests/integ_tests/polling_tests.rs +0 -294
- package/sdk-core/tests/integ_tests/worker_tests.rs +0 -203
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +0 -74
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +0 -57
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +0 -246
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +0 -65
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +0 -85
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +0 -908
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +0 -51
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +0 -206
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +0 -164
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +0 -123
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/build.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/push-to-buf.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/CODEOWNERS +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/LICENSE +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/README.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.gen.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.lock +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/connectivityrule/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/resource/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/usage/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/CODEOWNERS +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/ci.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/publish-docs.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/push-to-buf.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-delete-release.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-publish-release.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/LICENSE +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/README.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/api-linter.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.gen.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.lock +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/annotations.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/http.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/any.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/descriptor.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/duration.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/empty.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/struct.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/timestamp.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/wrappers.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/payload_description.txt +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/activity/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/batch/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/command/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/command_type.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/common.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/deployment.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/event_type.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/namespace.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/nexus.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/query.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/reset.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/schedule.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/update.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/workflow.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/errordetails/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/export/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/failure/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/filter/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/history/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/nexus/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/protocol/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/query/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/replication/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/rules/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/schedule/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/enhanced_stack_trace.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/user_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/worker_config.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/update/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/version/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/worker/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflow/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/google/rpc/status.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/grpc/health/v1/health.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_result/activity_result.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_task/activity_task.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/common/common.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/core_interface.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/external_data/external_data.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/nexus/nexus.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/api-linter.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +0 -0
- /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/constants.rs +0 -0
- /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/task_token.rs +0 -0
- /package/sdk-core/{fsm → crates/macros}/LICENSE.txt +0 -0
- /package/sdk-core/{core → crates/sdk-core}/src/abstractions/take_cell.rs +0 -0
- /package/sdk-core/{core → crates/sdk-core}/src/worker/slot_supplier.rs +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/ends_empty_wft_complete.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-16_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-23_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-85_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/fail_wf_task.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-0_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-1_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-2_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-3_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/old_change_marker_format.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/timer_workflow_history.bin +0 -0
- /package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/priority.rs +0 -0
- /package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/build.rs +0 -0
- /package/sdk-core/{cargo-tokio-console.sh → etc/cargo-tokio-console.sh} +0 -0
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
use crate::common::{CoreWfStarter, build_fake_sdk, mock_sdk, mock_sdk_cfg};
|
|
2
|
+
use anyhow::anyhow;
|
|
3
|
+
use assert_matches::assert_matches;
|
|
4
|
+
use std::time::Duration;
|
|
5
|
+
use temporalio_client::{WorkflowClientTrait, WorkflowOptions};
|
|
6
|
+
use temporalio_common::{
|
|
7
|
+
Worker,
|
|
8
|
+
protos::{
|
|
9
|
+
TestHistoryBuilder, canned_histories,
|
|
10
|
+
coresdk::{
|
|
11
|
+
AsJsonPayloadExt,
|
|
12
|
+
child_workflow::{
|
|
13
|
+
ChildWorkflowCancellationType, StartChildWorkflowExecutionFailedCause, Success,
|
|
14
|
+
child_workflow_result,
|
|
15
|
+
},
|
|
16
|
+
workflow_activation::{
|
|
17
|
+
WorkflowActivationJob,
|
|
18
|
+
resolve_child_workflow_execution_start::Status as StartStatus,
|
|
19
|
+
workflow_activation_job,
|
|
20
|
+
},
|
|
21
|
+
workflow_commands::{
|
|
22
|
+
CancelChildWorkflowExecution, CompleteWorkflowExecution,
|
|
23
|
+
StartChildWorkflowExecution,
|
|
24
|
+
},
|
|
25
|
+
workflow_completion::WorkflowActivationCompletion,
|
|
26
|
+
},
|
|
27
|
+
temporal::api::{
|
|
28
|
+
common::v1::Payload,
|
|
29
|
+
enums::v1::{CommandType, EventType, ParentClosePolicy},
|
|
30
|
+
history::v1::{
|
|
31
|
+
StartChildWorkflowExecutionFailedEventAttributes,
|
|
32
|
+
StartChildWorkflowExecutionInitiatedEventAttributes,
|
|
33
|
+
},
|
|
34
|
+
sdk::v1::UserMetadata,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
worker::WorkerTaskTypes,
|
|
38
|
+
};
|
|
39
|
+
use temporalio_sdk::{
|
|
40
|
+
CancellableFuture, ChildWorkflowOptions, Signal, WfContext, WfExitValue, WorkflowResult,
|
|
41
|
+
};
|
|
42
|
+
use temporalio_sdk_core::{
|
|
43
|
+
replay::DEFAULT_WORKFLOW_TYPE,
|
|
44
|
+
test_help::{MockPollCfg, ResponseType, mock_worker, mock_worker_client, single_hist_mock_sg},
|
|
45
|
+
};
|
|
46
|
+
use tokio::{join, sync::Barrier};
|
|
47
|
+
|
|
48
|
+
static PARENT_WF_TYPE: &str = "parent_wf";
|
|
49
|
+
static CHILD_WF_TYPE: &str = "child_wf";
|
|
50
|
+
const SIGNAME: &str = "SIGNAME";
|
|
51
|
+
|
|
52
|
+
async fn child_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
53
|
+
assert_eq!(
|
|
54
|
+
ctx.workflow_initial_info()
|
|
55
|
+
.parent_workflow_info
|
|
56
|
+
.as_ref()
|
|
57
|
+
.unwrap()
|
|
58
|
+
.workflow_id,
|
|
59
|
+
ctx.workflow_initial_info()
|
|
60
|
+
.root_workflow
|
|
61
|
+
.as_ref()
|
|
62
|
+
.unwrap()
|
|
63
|
+
.workflow_id
|
|
64
|
+
);
|
|
65
|
+
Ok(().into())
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async fn happy_parent(ctx: WfContext) -> WorkflowResult<()> {
|
|
69
|
+
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
70
|
+
workflow_id: "child-1".to_owned(),
|
|
71
|
+
workflow_type: CHILD_WF_TYPE.to_owned(),
|
|
72
|
+
..Default::default()
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
let started = child
|
|
76
|
+
.start(&ctx)
|
|
77
|
+
.await
|
|
78
|
+
.into_started()
|
|
79
|
+
.expect("Child chould start OK");
|
|
80
|
+
match started.result().await.status {
|
|
81
|
+
Some(child_workflow_result::Status::Completed(Success { .. })) => Ok(().into()),
|
|
82
|
+
_ => Err(anyhow!("Unexpected child WF status")),
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#[tokio::test]
|
|
87
|
+
async fn child_workflow_happy_path() {
|
|
88
|
+
let mut starter = CoreWfStarter::new("child-workflows");
|
|
89
|
+
starter
|
|
90
|
+
.worker_config
|
|
91
|
+
.task_types(WorkerTaskTypes::workflow_only());
|
|
92
|
+
let mut worker = starter.worker().await;
|
|
93
|
+
|
|
94
|
+
worker.register_wf(PARENT_WF_TYPE.to_string(), happy_parent);
|
|
95
|
+
worker.register_wf(CHILD_WF_TYPE.to_string(), child_wf);
|
|
96
|
+
|
|
97
|
+
worker
|
|
98
|
+
.submit_wf(
|
|
99
|
+
"parent".to_string(),
|
|
100
|
+
PARENT_WF_TYPE.to_owned(),
|
|
101
|
+
vec![],
|
|
102
|
+
WorkflowOptions::default(),
|
|
103
|
+
)
|
|
104
|
+
.await
|
|
105
|
+
.unwrap();
|
|
106
|
+
worker.run_until_done().await.unwrap();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
#[tokio::test]
|
|
110
|
+
async fn abandoned_child_bug_repro() {
|
|
111
|
+
let mut starter = CoreWfStarter::new("child-workflow-abandon-bug");
|
|
112
|
+
starter
|
|
113
|
+
.worker_config
|
|
114
|
+
.task_types(WorkerTaskTypes::workflow_only());
|
|
115
|
+
let mut worker = starter.worker().await;
|
|
116
|
+
let barr: &'static Barrier = Box::leak(Box::new(Barrier::new(2)));
|
|
117
|
+
|
|
118
|
+
worker.register_wf(
|
|
119
|
+
PARENT_WF_TYPE.to_string(),
|
|
120
|
+
move |ctx: WfContext| async move {
|
|
121
|
+
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
122
|
+
workflow_id: "abandoned-child".to_owned(),
|
|
123
|
+
workflow_type: CHILD_WF_TYPE.to_owned(),
|
|
124
|
+
parent_close_policy: ParentClosePolicy::Abandon,
|
|
125
|
+
cancel_type: ChildWorkflowCancellationType::Abandon,
|
|
126
|
+
..Default::default()
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
let started = child
|
|
130
|
+
.start(&ctx)
|
|
131
|
+
.await
|
|
132
|
+
.into_started()
|
|
133
|
+
.expect("Child chould start OK");
|
|
134
|
+
barr.wait().await;
|
|
135
|
+
// Wait for cancel signal
|
|
136
|
+
ctx.cancelled().await;
|
|
137
|
+
// Cancel the child immediately
|
|
138
|
+
started.cancel(&ctx, "Die reason!".to_string());
|
|
139
|
+
// Need to do something else, so we'll see the ChildWorkflowExecutionCanceled event
|
|
140
|
+
ctx.timer(Duration::from_secs(1)).await;
|
|
141
|
+
started.result().await;
|
|
142
|
+
Ok(().into())
|
|
143
|
+
},
|
|
144
|
+
);
|
|
145
|
+
worker.register_wf(CHILD_WF_TYPE.to_string(), |ctx: WfContext| async move {
|
|
146
|
+
ctx.cancelled().await;
|
|
147
|
+
Ok(WfExitValue::<()>::Cancelled)
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
worker
|
|
151
|
+
.submit_wf(
|
|
152
|
+
"parent-abandoner".to_string(),
|
|
153
|
+
PARENT_WF_TYPE.to_owned(),
|
|
154
|
+
vec![],
|
|
155
|
+
WorkflowOptions::default(),
|
|
156
|
+
)
|
|
157
|
+
.await
|
|
158
|
+
.unwrap();
|
|
159
|
+
let client = starter.get_client().await;
|
|
160
|
+
let canceller = async {
|
|
161
|
+
barr.wait().await;
|
|
162
|
+
client
|
|
163
|
+
.cancel_workflow_execution(
|
|
164
|
+
"parent-abandoner".to_string(),
|
|
165
|
+
None,
|
|
166
|
+
"die".to_string(),
|
|
167
|
+
None,
|
|
168
|
+
)
|
|
169
|
+
.await
|
|
170
|
+
.unwrap();
|
|
171
|
+
client
|
|
172
|
+
.cancel_workflow_execution("abandoned-child".to_string(), None, "die".to_string(), None)
|
|
173
|
+
.await
|
|
174
|
+
.unwrap();
|
|
175
|
+
};
|
|
176
|
+
let runner = async move {
|
|
177
|
+
worker.run_until_done().await.unwrap();
|
|
178
|
+
};
|
|
179
|
+
tokio::join!(canceller, runner);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
#[tokio::test]
|
|
183
|
+
async fn abandoned_child_resolves_post_cancel() {
|
|
184
|
+
let mut starter = CoreWfStarter::new("child-workflow-resolves-post-cancel");
|
|
185
|
+
starter
|
|
186
|
+
.worker_config
|
|
187
|
+
.task_types(WorkerTaskTypes::workflow_only());
|
|
188
|
+
let mut worker = starter.worker().await;
|
|
189
|
+
let barr: &'static Barrier = Box::leak(Box::new(Barrier::new(2)));
|
|
190
|
+
|
|
191
|
+
worker.register_wf(
|
|
192
|
+
PARENT_WF_TYPE.to_string(),
|
|
193
|
+
move |ctx: WfContext| async move {
|
|
194
|
+
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
195
|
+
workflow_id: "abandoned-child-resolve-post-cancel".to_owned(),
|
|
196
|
+
workflow_type: CHILD_WF_TYPE.to_owned(),
|
|
197
|
+
parent_close_policy: ParentClosePolicy::Abandon,
|
|
198
|
+
cancel_type: ChildWorkflowCancellationType::Abandon,
|
|
199
|
+
..Default::default()
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
let started = child
|
|
203
|
+
.start(&ctx)
|
|
204
|
+
.await
|
|
205
|
+
.into_started()
|
|
206
|
+
.expect("Child chould start OK");
|
|
207
|
+
barr.wait().await;
|
|
208
|
+
// Wait for cancel signal
|
|
209
|
+
ctx.cancelled().await;
|
|
210
|
+
// Cancel the child immediately
|
|
211
|
+
started.cancel(&ctx, "Die reason".to_string());
|
|
212
|
+
// Need to do something else, so we will see the child completing
|
|
213
|
+
ctx.timer(Duration::from_secs(1)).await;
|
|
214
|
+
started.result().await;
|
|
215
|
+
Ok(().into())
|
|
216
|
+
},
|
|
217
|
+
);
|
|
218
|
+
worker.register_wf(CHILD_WF_TYPE.to_string(), |_: WfContext| async move {
|
|
219
|
+
Ok("I'm done".into())
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
worker
|
|
223
|
+
.submit_wf(
|
|
224
|
+
"parent-abandoner-resolving".to_string(),
|
|
225
|
+
PARENT_WF_TYPE.to_owned(),
|
|
226
|
+
vec![],
|
|
227
|
+
WorkflowOptions::default(),
|
|
228
|
+
)
|
|
229
|
+
.await
|
|
230
|
+
.unwrap();
|
|
231
|
+
let client = starter.get_client().await;
|
|
232
|
+
let canceller = async {
|
|
233
|
+
barr.wait().await;
|
|
234
|
+
client
|
|
235
|
+
.cancel_workflow_execution(
|
|
236
|
+
"parent-abandoner-resolving".to_string(),
|
|
237
|
+
None,
|
|
238
|
+
"die".to_string(),
|
|
239
|
+
None,
|
|
240
|
+
)
|
|
241
|
+
.await
|
|
242
|
+
.unwrap();
|
|
243
|
+
};
|
|
244
|
+
let runner = async move {
|
|
245
|
+
worker.run_until_done().await.unwrap();
|
|
246
|
+
};
|
|
247
|
+
tokio::join!(canceller, runner);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
#[tokio::test]
|
|
251
|
+
async fn cancelled_child_gets_reason() {
|
|
252
|
+
let wf_name = "cancelled-child-gets-reason";
|
|
253
|
+
let mut starter = CoreWfStarter::new(wf_name);
|
|
254
|
+
starter
|
|
255
|
+
.worker_config
|
|
256
|
+
.task_types(WorkerTaskTypes::workflow_only());
|
|
257
|
+
let mut worker = starter.worker().await;
|
|
258
|
+
|
|
259
|
+
worker.register_wf(wf_name.to_string(), move |ctx: WfContext| async move {
|
|
260
|
+
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
261
|
+
workflow_id: format!("{}-child", ctx.task_queue()),
|
|
262
|
+
workflow_type: CHILD_WF_TYPE.to_owned(),
|
|
263
|
+
cancel_type: ChildWorkflowCancellationType::WaitCancellationRequested,
|
|
264
|
+
..Default::default()
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
let started = child
|
|
268
|
+
.start(&ctx)
|
|
269
|
+
.await
|
|
270
|
+
.into_started()
|
|
271
|
+
.expect("Child chould start OK");
|
|
272
|
+
// Cancel the child after start
|
|
273
|
+
started.cancel(&ctx, "Die reason".to_string());
|
|
274
|
+
let r = started.result().await;
|
|
275
|
+
let out = assert_matches!(r.status,
|
|
276
|
+
Some(child_workflow_result::Status::Completed(reason)) => reason);
|
|
277
|
+
assert_eq!(out.result.unwrap(), "Die reason".as_json_payload().unwrap());
|
|
278
|
+
Ok(().into())
|
|
279
|
+
});
|
|
280
|
+
worker.register_wf(CHILD_WF_TYPE.to_string(), |c: WfContext| async move {
|
|
281
|
+
let r = c.cancelled().await;
|
|
282
|
+
Ok(r.into())
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
starter.start_with_worker(wf_name, &mut worker).await;
|
|
286
|
+
worker.run_until_done().await.unwrap();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
#[rstest::rstest]
|
|
290
|
+
#[case::signal_then_result(true)]
|
|
291
|
+
#[case::signal_and_result_concurrent(false)]
|
|
292
|
+
#[tokio::test]
|
|
293
|
+
async fn signal_child_workflow(#[case] serial: bool) {
|
|
294
|
+
let wf_id = "fakeid";
|
|
295
|
+
let wf_type = DEFAULT_WORKFLOW_TYPE;
|
|
296
|
+
let t = canned_histories::single_child_workflow_signaled("child-id-1", SIGNAME);
|
|
297
|
+
let mock = mock_worker_client();
|
|
298
|
+
let mut worker = mock_sdk(MockPollCfg::from_resp_batches(
|
|
299
|
+
wf_id,
|
|
300
|
+
t,
|
|
301
|
+
[ResponseType::AllHistory],
|
|
302
|
+
mock,
|
|
303
|
+
));
|
|
304
|
+
|
|
305
|
+
let wf = move |ctx: WfContext| async move {
|
|
306
|
+
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
307
|
+
workflow_id: "child-id-1".to_string(),
|
|
308
|
+
workflow_type: "child".to_string(),
|
|
309
|
+
..Default::default()
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
let start_res = child
|
|
313
|
+
.start(&ctx)
|
|
314
|
+
.await
|
|
315
|
+
.into_started()
|
|
316
|
+
.expect("Child should get started");
|
|
317
|
+
let (sigres, res) = if serial {
|
|
318
|
+
let sigres = start_res.signal(&ctx, Signal::new(SIGNAME, [b"Hi!"])).await;
|
|
319
|
+
let res = start_res.result().await;
|
|
320
|
+
(sigres, res)
|
|
321
|
+
} else {
|
|
322
|
+
let sigfut = start_res.signal(&ctx, Signal::new(SIGNAME, [b"Hi!"]));
|
|
323
|
+
let resfut = start_res.result();
|
|
324
|
+
join!(sigfut, resfut)
|
|
325
|
+
};
|
|
326
|
+
sigres.expect("signal result is ok");
|
|
327
|
+
res.status.expect("child wf result is ok");
|
|
328
|
+
Ok(().into())
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
worker.register_wf(wf_type.to_owned(), wf);
|
|
332
|
+
worker
|
|
333
|
+
.submit_wf(
|
|
334
|
+
wf_id.to_owned(),
|
|
335
|
+
wf_type.to_owned(),
|
|
336
|
+
vec![],
|
|
337
|
+
WorkflowOptions::default(),
|
|
338
|
+
)
|
|
339
|
+
.await
|
|
340
|
+
.unwrap();
|
|
341
|
+
worker.run_until_done().await.unwrap();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
async fn parent_cancels_child_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
345
|
+
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
346
|
+
workflow_id: "child-id-1".to_string(),
|
|
347
|
+
workflow_type: "child".to_string(),
|
|
348
|
+
cancel_type: ChildWorkflowCancellationType::WaitCancellationCompleted,
|
|
349
|
+
..Default::default()
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
let start_res = child
|
|
353
|
+
.start(&ctx)
|
|
354
|
+
.await
|
|
355
|
+
.into_started()
|
|
356
|
+
.expect("Child should get started");
|
|
357
|
+
start_res.cancel(&ctx, "cancel reason".to_string());
|
|
358
|
+
let stat = start_res
|
|
359
|
+
.result()
|
|
360
|
+
.await
|
|
361
|
+
.status
|
|
362
|
+
.expect("child wf result is ok");
|
|
363
|
+
assert_matches!(stat, child_workflow_result::Status::Cancelled(_));
|
|
364
|
+
Ok(().into())
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
#[tokio::test]
|
|
368
|
+
async fn cancel_child_workflow() {
|
|
369
|
+
let t = canned_histories::single_child_workflow_cancelled("child-id-1");
|
|
370
|
+
let mut worker = build_fake_sdk(MockPollCfg::from_resps(t, [ResponseType::AllHistory]));
|
|
371
|
+
worker.register_wf(DEFAULT_WORKFLOW_TYPE, parent_cancels_child_wf);
|
|
372
|
+
worker.run().await.unwrap();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
#[rstest::rstest]
|
|
376
|
+
#[case::abandon(ChildWorkflowCancellationType::Abandon)]
|
|
377
|
+
#[case::try_cancel(ChildWorkflowCancellationType::TryCancel)]
|
|
378
|
+
#[case::wait_cancel_completed(ChildWorkflowCancellationType::WaitCancellationCompleted)]
|
|
379
|
+
#[tokio::test]
|
|
380
|
+
async fn cancel_child_workflow_lang_thinks_not_started_but_is(
|
|
381
|
+
#[case] cancellation_type: ChildWorkflowCancellationType,
|
|
382
|
+
) {
|
|
383
|
+
// Since signal handlers always run first, it's possible lang might try to cancel
|
|
384
|
+
// a child workflow it thinks isn't started, but we've told it is in the same activation.
|
|
385
|
+
// It would be annoying for lang to have to peek ahead at jobs to be consistent in that case.
|
|
386
|
+
let t = match cancellation_type {
|
|
387
|
+
ChildWorkflowCancellationType::Abandon => {
|
|
388
|
+
canned_histories::single_child_workflow_abandon_cancelled("child-id-1")
|
|
389
|
+
}
|
|
390
|
+
ChildWorkflowCancellationType::TryCancel => {
|
|
391
|
+
canned_histories::single_child_workflow_try_cancelled("child-id-1")
|
|
392
|
+
}
|
|
393
|
+
_ => canned_histories::single_child_workflow_cancelled("child-id-1"),
|
|
394
|
+
};
|
|
395
|
+
let mock = mock_worker_client();
|
|
396
|
+
let mock = single_hist_mock_sg("fakeid", t, [ResponseType::AllHistory], mock, true);
|
|
397
|
+
let core = mock_worker(mock);
|
|
398
|
+
let act = core.poll_workflow_activation().await.unwrap();
|
|
399
|
+
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmd(
|
|
400
|
+
act.run_id,
|
|
401
|
+
StartChildWorkflowExecution {
|
|
402
|
+
seq: 1,
|
|
403
|
+
cancellation_type: cancellation_type as i32,
|
|
404
|
+
..Default::default()
|
|
405
|
+
}
|
|
406
|
+
.into(),
|
|
407
|
+
))
|
|
408
|
+
.await
|
|
409
|
+
.unwrap();
|
|
410
|
+
let act = core.poll_workflow_activation().await.unwrap();
|
|
411
|
+
assert_matches!(
|
|
412
|
+
act.jobs.as_slice(),
|
|
413
|
+
[WorkflowActivationJob {
|
|
414
|
+
variant: Some(workflow_activation_job::Variant::ResolveChildWorkflowExecutionStart(_)),
|
|
415
|
+
}]
|
|
416
|
+
);
|
|
417
|
+
// Issue the cancel command
|
|
418
|
+
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmd(
|
|
419
|
+
act.run_id,
|
|
420
|
+
CancelChildWorkflowExecution {
|
|
421
|
+
child_workflow_seq: 1,
|
|
422
|
+
reason: "dieee".to_string(),
|
|
423
|
+
}
|
|
424
|
+
.into(),
|
|
425
|
+
))
|
|
426
|
+
.await
|
|
427
|
+
.unwrap();
|
|
428
|
+
let act = core.poll_workflow_activation().await.unwrap();
|
|
429
|
+
// Make sure that a resolve for the "request cancel external workflow" command does *not* appear
|
|
430
|
+
// since lang didn't actually issue one. The only job should be resolving the child workflow.
|
|
431
|
+
assert_matches!(
|
|
432
|
+
act.jobs.as_slice(),
|
|
433
|
+
[WorkflowActivationJob {
|
|
434
|
+
variant: Some(workflow_activation_job::Variant::ResolveChildWorkflowExecution(_)),
|
|
435
|
+
}]
|
|
436
|
+
);
|
|
437
|
+
// Request cancel external is technically fallible, but the only reasons relate to targeting
|
|
438
|
+
// a not-found workflow, which couldn't happen in this case.
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
#[tokio::test]
|
|
442
|
+
async fn cancel_already_complete_child_ignored() {
|
|
443
|
+
let t = canned_histories::single_child_workflow("child-id-1");
|
|
444
|
+
let mock = mock_worker_client();
|
|
445
|
+
let mock = single_hist_mock_sg("fakeid", t, [ResponseType::AllHistory], mock, true);
|
|
446
|
+
let core = mock_worker(mock);
|
|
447
|
+
let act = core.poll_workflow_activation().await.unwrap();
|
|
448
|
+
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmd(
|
|
449
|
+
act.run_id,
|
|
450
|
+
StartChildWorkflowExecution {
|
|
451
|
+
seq: 1,
|
|
452
|
+
..Default::default()
|
|
453
|
+
}
|
|
454
|
+
.into(),
|
|
455
|
+
))
|
|
456
|
+
.await
|
|
457
|
+
.unwrap();
|
|
458
|
+
let act = core.poll_workflow_activation().await.unwrap();
|
|
459
|
+
assert_matches!(
|
|
460
|
+
act.jobs.as_slice(),
|
|
461
|
+
[WorkflowActivationJob {
|
|
462
|
+
variant: Some(workflow_activation_job::Variant::ResolveChildWorkflowExecutionStart(_)),
|
|
463
|
+
}]
|
|
464
|
+
);
|
|
465
|
+
core.complete_workflow_activation(WorkflowActivationCompletion::empty(act.run_id))
|
|
466
|
+
.await
|
|
467
|
+
.unwrap();
|
|
468
|
+
let act = core.poll_workflow_activation().await.unwrap();
|
|
469
|
+
assert_matches!(
|
|
470
|
+
act.jobs.as_slice(),
|
|
471
|
+
[WorkflowActivationJob {
|
|
472
|
+
variant: Some(workflow_activation_job::Variant::ResolveChildWorkflowExecution(_)),
|
|
473
|
+
}]
|
|
474
|
+
);
|
|
475
|
+
// Try to cancel post-completion, it should be ignored. Also complete the wf.
|
|
476
|
+
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmds(
|
|
477
|
+
act.run_id,
|
|
478
|
+
vec![
|
|
479
|
+
CancelChildWorkflowExecution {
|
|
480
|
+
child_workflow_seq: 1,
|
|
481
|
+
reason: "go away!".to_string(),
|
|
482
|
+
}
|
|
483
|
+
.into(),
|
|
484
|
+
CompleteWorkflowExecution { result: None }.into(),
|
|
485
|
+
],
|
|
486
|
+
))
|
|
487
|
+
.await
|
|
488
|
+
.unwrap();
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
#[tokio::test]
|
|
492
|
+
async fn pass_child_workflow_summary_to_metadata() {
|
|
493
|
+
let wf_id = "1";
|
|
494
|
+
let wf_type = DEFAULT_WORKFLOW_TYPE;
|
|
495
|
+
let t = canned_histories::single_child_workflow(wf_id);
|
|
496
|
+
let mut mock_cfg = MockPollCfg::from_hist_builder(t);
|
|
497
|
+
let expected_user_metadata = Some(UserMetadata {
|
|
498
|
+
summary: Some(b"child summary".into()),
|
|
499
|
+
details: Some(b"child details".into()),
|
|
500
|
+
});
|
|
501
|
+
mock_cfg.completion_asserts_from_expectations(|mut asserts| {
|
|
502
|
+
asserts
|
|
503
|
+
.then(move |wft| {
|
|
504
|
+
assert_eq!(wft.commands.len(), 1);
|
|
505
|
+
assert_eq!(
|
|
506
|
+
wft.commands[0].command_type(),
|
|
507
|
+
CommandType::StartChildWorkflowExecution
|
|
508
|
+
);
|
|
509
|
+
assert_eq!(wft.commands[0].user_metadata, expected_user_metadata)
|
|
510
|
+
})
|
|
511
|
+
.then(move |wft| {
|
|
512
|
+
assert_eq!(wft.commands.len(), 1);
|
|
513
|
+
assert_eq!(
|
|
514
|
+
wft.commands[0].command_type(),
|
|
515
|
+
CommandType::CompleteWorkflowExecution
|
|
516
|
+
);
|
|
517
|
+
});
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
let mut worker = mock_sdk_cfg(mock_cfg, |_| {});
|
|
521
|
+
worker.register_wf(wf_type, move |ctx: WfContext| async move {
|
|
522
|
+
ctx.child_workflow(ChildWorkflowOptions {
|
|
523
|
+
workflow_id: wf_id.to_string(),
|
|
524
|
+
workflow_type: "child".to_string(),
|
|
525
|
+
static_summary: Some("child summary".to_string()),
|
|
526
|
+
static_details: Some("child details".to_string()),
|
|
527
|
+
..Default::default()
|
|
528
|
+
})
|
|
529
|
+
.start(&ctx)
|
|
530
|
+
.await;
|
|
531
|
+
Ok(().into())
|
|
532
|
+
});
|
|
533
|
+
worker
|
|
534
|
+
.submit_wf(
|
|
535
|
+
wf_id.to_owned(),
|
|
536
|
+
wf_type.to_owned(),
|
|
537
|
+
vec![],
|
|
538
|
+
WorkflowOptions::default(),
|
|
539
|
+
)
|
|
540
|
+
.await
|
|
541
|
+
.unwrap();
|
|
542
|
+
worker.run_until_done().await.unwrap();
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
#[derive(Clone, Copy)]
|
|
546
|
+
enum Expectation {
|
|
547
|
+
Success,
|
|
548
|
+
Failure,
|
|
549
|
+
StartFailure,
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
impl Expectation {
|
|
553
|
+
const fn try_from_u8(x: u8) -> Option<Self> {
|
|
554
|
+
Some(match x {
|
|
555
|
+
0 => Self::Success,
|
|
556
|
+
1 => Self::Failure,
|
|
557
|
+
2 => Self::StartFailure,
|
|
558
|
+
_ => return None,
|
|
559
|
+
})
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
#[fixture]
|
|
564
|
+
fn child_workflow_happy_hist() -> MockPollCfg {
|
|
565
|
+
let mut t = canned_histories::single_child_workflow("child-id-1");
|
|
566
|
+
t.set_wf_input(Payload::from([Expectation::Success as u8]));
|
|
567
|
+
MockPollCfg::from_hist_builder(t)
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
#[fixture]
|
|
571
|
+
fn child_workflow_fail_hist() -> MockPollCfg {
|
|
572
|
+
let mut t = canned_histories::single_child_workflow_fail("child-id-1");
|
|
573
|
+
t.set_wf_input(Payload::from([Expectation::Failure as u8]));
|
|
574
|
+
MockPollCfg::from_hist_builder(t)
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
async fn parent_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
578
|
+
let expectation = Expectation::try_from_u8(ctx.get_args()[0].data[0]).unwrap();
|
|
579
|
+
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
580
|
+
workflow_id: "child-id-1".to_string(),
|
|
581
|
+
workflow_type: "child".to_string(),
|
|
582
|
+
..Default::default()
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
let start_res = child.start(&ctx).await;
|
|
586
|
+
match (expectation, &start_res.status) {
|
|
587
|
+
(Expectation::Success | Expectation::Failure, StartStatus::Succeeded(_)) => {}
|
|
588
|
+
(Expectation::StartFailure, StartStatus::Failed(_)) => return Ok(().into()),
|
|
589
|
+
_ => return Err(anyhow!("Unexpected start status")),
|
|
590
|
+
};
|
|
591
|
+
match (
|
|
592
|
+
expectation,
|
|
593
|
+
start_res.into_started().unwrap().result().await.status,
|
|
594
|
+
) {
|
|
595
|
+
(Expectation::Success, Some(child_workflow_result::Status::Completed(_))) => Ok(().into()),
|
|
596
|
+
(Expectation::Failure, _) => Ok(().into()),
|
|
597
|
+
_ => Err(anyhow!("Unexpected child WF status")),
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
#[rstest(
|
|
602
|
+
mock_cfg,
|
|
603
|
+
case::success(child_workflow_happy_hist()),
|
|
604
|
+
case::failure(child_workflow_fail_hist())
|
|
605
|
+
)]
|
|
606
|
+
#[tokio::test]
|
|
607
|
+
async fn single_child_workflow_until_completion(mut mock_cfg: MockPollCfg) {
|
|
608
|
+
mock_cfg.completion_asserts_from_expectations(|mut asserts| {
|
|
609
|
+
asserts
|
|
610
|
+
.then(|wft| {
|
|
611
|
+
assert_eq!(wft.commands.len(), 1);
|
|
612
|
+
assert_matches!(
|
|
613
|
+
wft.commands[0].command_type(),
|
|
614
|
+
CommandType::StartChildWorkflowExecution
|
|
615
|
+
);
|
|
616
|
+
})
|
|
617
|
+
.then(move |wft| {
|
|
618
|
+
assert_eq!(wft.commands.len(), 0);
|
|
619
|
+
})
|
|
620
|
+
.then(move |wft| {
|
|
621
|
+
assert_eq!(wft.commands.len(), 1);
|
|
622
|
+
assert_matches!(
|
|
623
|
+
wft.commands[0].command_type(),
|
|
624
|
+
CommandType::CompleteWorkflowExecution
|
|
625
|
+
);
|
|
626
|
+
});
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
let mut worker = build_fake_sdk(mock_cfg);
|
|
630
|
+
worker.register_wf(DEFAULT_WORKFLOW_TYPE, parent_wf);
|
|
631
|
+
worker.run().await.unwrap();
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
#[tokio::test]
|
|
635
|
+
async fn single_child_workflow_start_fail() {
|
|
636
|
+
let child_wf_id = "child-id-1";
|
|
637
|
+
let mut t = TestHistoryBuilder::default();
|
|
638
|
+
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
639
|
+
t.set_wf_input(Payload::from([Expectation::StartFailure as u8]));
|
|
640
|
+
t.add_full_wf_task();
|
|
641
|
+
let initiated_event_id = t.add(StartChildWorkflowExecutionInitiatedEventAttributes {
|
|
642
|
+
workflow_id: child_wf_id.to_owned(),
|
|
643
|
+
workflow_type: Some("child".into()),
|
|
644
|
+
..Default::default()
|
|
645
|
+
});
|
|
646
|
+
t.add(StartChildWorkflowExecutionFailedEventAttributes {
|
|
647
|
+
workflow_id: child_wf_id.to_owned(),
|
|
648
|
+
initiated_event_id,
|
|
649
|
+
cause: StartChildWorkflowExecutionFailedCause::WorkflowAlreadyExists as i32,
|
|
650
|
+
..Default::default()
|
|
651
|
+
});
|
|
652
|
+
t.add_full_wf_task();
|
|
653
|
+
t.add_workflow_execution_completed();
|
|
654
|
+
|
|
655
|
+
let mut mock_cfg = MockPollCfg::from_hist_builder(t);
|
|
656
|
+
mock_cfg.completion_asserts_from_expectations(|mut asserts| {
|
|
657
|
+
asserts
|
|
658
|
+
.then(|wft| {
|
|
659
|
+
assert_eq!(wft.commands.len(), 1);
|
|
660
|
+
assert_matches!(
|
|
661
|
+
wft.commands[0].command_type(),
|
|
662
|
+
CommandType::StartChildWorkflowExecution
|
|
663
|
+
);
|
|
664
|
+
})
|
|
665
|
+
.then(move |wft| {
|
|
666
|
+
assert_eq!(wft.commands.len(), 1);
|
|
667
|
+
assert_matches!(
|
|
668
|
+
wft.commands[0].command_type(),
|
|
669
|
+
CommandType::CompleteWorkflowExecution
|
|
670
|
+
);
|
|
671
|
+
});
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
let mut worker = build_fake_sdk(mock_cfg);
|
|
675
|
+
worker.register_wf(DEFAULT_WORKFLOW_TYPE, parent_wf);
|
|
676
|
+
worker.run().await.unwrap();
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
async fn cancel_before_send_wf(ctx: WfContext) -> WorkflowResult<()> {
|
|
680
|
+
let workflow_id = "child-id-1";
|
|
681
|
+
let child = ctx.child_workflow(ChildWorkflowOptions {
|
|
682
|
+
workflow_id: workflow_id.to_string(),
|
|
683
|
+
workflow_type: "child".to_string(),
|
|
684
|
+
..Default::default()
|
|
685
|
+
});
|
|
686
|
+
let start = child.start(&ctx);
|
|
687
|
+
start.cancel(&ctx);
|
|
688
|
+
match start.await.status {
|
|
689
|
+
StartStatus::Cancelled(_) => Ok(().into()),
|
|
690
|
+
_ => Err(anyhow!("Unexpected start status")),
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
#[tokio::test]
|
|
695
|
+
async fn single_child_workflow_cancel_before_sent() {
|
|
696
|
+
let mut t = TestHistoryBuilder::default();
|
|
697
|
+
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
698
|
+
t.add_full_wf_task();
|
|
699
|
+
t.add_workflow_execution_completed();
|
|
700
|
+
|
|
701
|
+
let mut mock_cfg = MockPollCfg::from_hist_builder(t);
|
|
702
|
+
mock_cfg.completion_asserts_from_expectations(|mut asserts| {
|
|
703
|
+
asserts.then(move |wft| {
|
|
704
|
+
// Workflow starts and cancels the child workflow, no commands should be sent besides
|
|
705
|
+
// workflow completion
|
|
706
|
+
assert_eq!(wft.commands.len(), 1);
|
|
707
|
+
assert_matches!(
|
|
708
|
+
wft.commands[0].command_type(),
|
|
709
|
+
CommandType::CompleteWorkflowExecution
|
|
710
|
+
);
|
|
711
|
+
});
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
let mut worker = build_fake_sdk(mock_cfg);
|
|
715
|
+
worker.register_wf(DEFAULT_WORKFLOW_TYPE, cancel_before_send_wf);
|
|
716
|
+
worker.run().await.unwrap();
|
|
717
|
+
}
|