temporalio 0.0.1
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.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +130 -0
- data/bridge/Cargo.lock +2865 -0
- data/bridge/Cargo.toml +26 -0
- data/bridge/sdk-core/ARCHITECTURE.md +76 -0
- data/bridge/sdk-core/Cargo.lock +2606 -0
- data/bridge/sdk-core/Cargo.toml +2 -0
- data/bridge/sdk-core/LICENSE.txt +23 -0
- data/bridge/sdk-core/README.md +107 -0
- data/bridge/sdk-core/arch_docs/diagrams/README.md +10 -0
- data/bridge/sdk-core/arch_docs/diagrams/sticky_queues.puml +40 -0
- data/bridge/sdk-core/arch_docs/diagrams/workflow_internals.svg +1 -0
- data/bridge/sdk-core/arch_docs/sticky_queues.md +51 -0
- data/bridge/sdk-core/bridge-ffi/Cargo.toml +24 -0
- data/bridge/sdk-core/bridge-ffi/LICENSE.txt +23 -0
- data/bridge/sdk-core/bridge-ffi/build.rs +25 -0
- data/bridge/sdk-core/bridge-ffi/include/sdk-core-bridge.h +249 -0
- data/bridge/sdk-core/bridge-ffi/src/lib.rs +825 -0
- data/bridge/sdk-core/bridge-ffi/src/wrappers.rs +211 -0
- data/bridge/sdk-core/client/Cargo.toml +40 -0
- data/bridge/sdk-core/client/LICENSE.txt +23 -0
- data/bridge/sdk-core/client/src/lib.rs +1294 -0
- data/bridge/sdk-core/client/src/metrics.rs +165 -0
- data/bridge/sdk-core/client/src/raw.rs +931 -0
- data/bridge/sdk-core/client/src/retry.rs +674 -0
- data/bridge/sdk-core/client/src/workflow_handle/mod.rs +185 -0
- data/bridge/sdk-core/core/Cargo.toml +116 -0
- data/bridge/sdk-core/core/LICENSE.txt +23 -0
- data/bridge/sdk-core/core/benches/workflow_replay.rs +73 -0
- data/bridge/sdk-core/core/src/abstractions.rs +166 -0
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +911 -0
- data/bridge/sdk-core/core/src/core_tests/child_workflows.rs +221 -0
- data/bridge/sdk-core/core/src/core_tests/determinism.rs +107 -0
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +515 -0
- data/bridge/sdk-core/core/src/core_tests/mod.rs +100 -0
- data/bridge/sdk-core/core/src/core_tests/queries.rs +736 -0
- data/bridge/sdk-core/core/src/core_tests/replay_flag.rs +65 -0
- data/bridge/sdk-core/core/src/core_tests/workers.rs +259 -0
- data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +124 -0
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +2070 -0
- data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +515 -0
- data/bridge/sdk-core/core/src/lib.rs +175 -0
- data/bridge/sdk-core/core/src/log_export.rs +62 -0
- data/bridge/sdk-core/core/src/pollers/mod.rs +54 -0
- data/bridge/sdk-core/core/src/pollers/poll_buffer.rs +297 -0
- data/bridge/sdk-core/core/src/protosext/mod.rs +428 -0
- data/bridge/sdk-core/core/src/replay/mod.rs +71 -0
- data/bridge/sdk-core/core/src/retry_logic.rs +202 -0
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +383 -0
- data/bridge/sdk-core/core/src/telemetry/mod.rs +412 -0
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +77 -0
- data/bridge/sdk-core/core/src/test_help/mod.rs +875 -0
- data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +580 -0
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +1042 -0
- data/bridge/sdk-core/core/src/worker/activities.rs +464 -0
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +87 -0
- data/bridge/sdk-core/core/src/worker/client.rs +347 -0
- data/bridge/sdk-core/core/src/worker/mod.rs +566 -0
- data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +37 -0
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +110 -0
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +458 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +911 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +298 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +171 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +860 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +140 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +161 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +133 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +1448 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +342 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/mutable_side_effect_state_machine.rs +127 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +712 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/side_effect_state_machine.rs +71 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +443 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +439 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +169 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +246 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +96 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +1184 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +277 -0
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +198 -0
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +647 -0
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +1143 -0
- data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +145 -0
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +88 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +940 -0
- data/bridge/sdk-core/core-api/Cargo.toml +31 -0
- data/bridge/sdk-core/core-api/LICENSE.txt +23 -0
- data/bridge/sdk-core/core-api/src/errors.rs +95 -0
- data/bridge/sdk-core/core-api/src/lib.rs +151 -0
- data/bridge/sdk-core/core-api/src/worker.rs +135 -0
- data/bridge/sdk-core/etc/deps.svg +187 -0
- data/bridge/sdk-core/etc/dynamic-config.yaml +2 -0
- data/bridge/sdk-core/etc/otel-collector-config.yaml +36 -0
- data/bridge/sdk-core/etc/prometheus.yaml +6 -0
- data/bridge/sdk-core/fsm/Cargo.toml +18 -0
- data/bridge/sdk-core/fsm/LICENSE.txt +23 -0
- data/bridge/sdk-core/fsm/README.md +3 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +27 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/LICENSE.txt +23 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +647 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +8 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.rs +18 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +12 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dynamic_dest_pass.rs +41 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.rs +14 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.stderr +11 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_arg_pass.rs +32 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_pass.rs +31 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/medium_complex_pass.rs +46 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.rs +29 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +12 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/simple_pass.rs +32 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.rs +18 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.rs +11 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.rs +11 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +5 -0
- data/bridge/sdk-core/fsm/rustfsm_trait/Cargo.toml +14 -0
- data/bridge/sdk-core/fsm/rustfsm_trait/LICENSE.txt +23 -0
- data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +249 -0
- data/bridge/sdk-core/fsm/src/lib.rs +2 -0
- data/bridge/sdk-core/histories/fail_wf_task.bin +0 -0
- data/bridge/sdk-core/histories/timer_workflow_history.bin +0 -0
- data/bridge/sdk-core/integ-with-otel.sh +7 -0
- data/bridge/sdk-core/protos/api_upstream/README.md +9 -0
- data/bridge/sdk-core/protos/api_upstream/api-linter.yaml +40 -0
- data/bridge/sdk-core/protos/api_upstream/buf.yaml +12 -0
- data/bridge/sdk-core/protos/api_upstream/dependencies/gogoproto/gogo.proto +141 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +86 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/cluster/v1/message.proto +83 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +259 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +112 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +46 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/cluster.proto +40 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +57 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +55 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +168 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +97 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +51 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +50 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +41 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +60 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +59 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +51 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +122 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +108 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +114 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +56 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +751 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +97 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +161 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +99 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +61 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +55 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +300 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +108 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +46 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +59 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +145 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +1124 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +401 -0
- data/bridge/sdk-core/protos/grpc/health/v1/health.proto +63 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +78 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +79 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +210 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +77 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +15 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +30 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +30 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +261 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +297 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +29 -0
- data/bridge/sdk-core/protos/testsrv_upstream/api-linter.yaml +38 -0
- data/bridge/sdk-core/protos/testsrv_upstream/buf.yaml +13 -0
- data/bridge/sdk-core/protos/testsrv_upstream/dependencies/gogoproto/gogo.proto +141 -0
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +63 -0
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +90 -0
- data/bridge/sdk-core/rustfmt.toml +1 -0
- data/bridge/sdk-core/sdk/Cargo.toml +47 -0
- data/bridge/sdk-core/sdk/LICENSE.txt +23 -0
- data/bridge/sdk-core/sdk/src/activity_context.rs +230 -0
- data/bridge/sdk-core/sdk/src/app_data.rs +37 -0
- data/bridge/sdk-core/sdk/src/conversions.rs +8 -0
- data/bridge/sdk-core/sdk/src/interceptors.rs +17 -0
- data/bridge/sdk-core/sdk/src/lib.rs +792 -0
- data/bridge/sdk-core/sdk/src/payload_converter.rs +11 -0
- data/bridge/sdk-core/sdk/src/workflow_context/options.rs +295 -0
- data/bridge/sdk-core/sdk/src/workflow_context.rs +683 -0
- data/bridge/sdk-core/sdk/src/workflow_future.rs +503 -0
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +30 -0
- data/bridge/sdk-core/sdk-core-protos/LICENSE.txt +23 -0
- data/bridge/sdk-core/sdk-core-protos/build.rs +108 -0
- data/bridge/sdk-core/sdk-core-protos/src/constants.rs +7 -0
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +497 -0
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +230 -0
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +1910 -0
- data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +38 -0
- data/bridge/sdk-core/sdk-core-protos/src/utilities.rs +14 -0
- data/bridge/sdk-core/test-utils/Cargo.toml +35 -0
- data/bridge/sdk-core/test-utils/src/canned_histories.rs +1579 -0
- data/bridge/sdk-core/test-utils/src/histfetch.rs +28 -0
- data/bridge/sdk-core/test-utils/src/lib.rs +598 -0
- data/bridge/sdk-core/tests/integ_tests/client_tests.rs +36 -0
- data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +128 -0
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +218 -0
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +146 -0
- data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +437 -0
- data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +93 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +878 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +61 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +59 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +58 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +50 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +60 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +54 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +634 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +113 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +137 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +93 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +167 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +99 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +131 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +75 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +587 -0
- data/bridge/sdk-core/tests/load_tests.rs +191 -0
- data/bridge/sdk-core/tests/main.rs +111 -0
- data/bridge/sdk-core/tests/runner.rs +93 -0
- data/bridge/src/connection.rs +167 -0
- data/bridge/src/lib.rs +180 -0
- data/bridge/src/runtime.rs +47 -0
- data/bridge/src/worker.rs +73 -0
- data/ext/Rakefile +9 -0
- data/lib/bridge.so +0 -0
- data/lib/gen/dependencies/gogoproto/gogo_pb.rb +14 -0
- data/lib/gen/temporal/api/batch/v1/message_pb.rb +48 -0
- data/lib/gen/temporal/api/cluster/v1/message_pb.rb +67 -0
- data/lib/gen/temporal/api/command/v1/message_pb.rb +166 -0
- data/lib/gen/temporal/api/common/v1/message_pb.rb +69 -0
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +32 -0
- data/lib/gen/temporal/api/enums/v1/cluster_pb.rb +26 -0
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +37 -0
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +41 -0
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +67 -0
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +71 -0
- data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +37 -0
- data/lib/gen/temporal/api/enums/v1/query_pb.rb +31 -0
- data/lib/gen/temporal/api/enums/v1/reset_pb.rb +24 -0
- data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +28 -0
- data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +30 -0
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +28 -0
- data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +89 -0
- data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +84 -0
- data/lib/gen/temporal/api/failure/v1/message_pb.rb +83 -0
- data/lib/gen/temporal/api/filter/v1/message_pb.rb +40 -0
- data/lib/gen/temporal/api/history/v1/message_pb.rb +489 -0
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +63 -0
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +125 -0
- data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +20 -0
- data/lib/gen/temporal/api/query/v1/message_pb.rb +38 -0
- data/lib/gen/temporal/api/replication/v1/message_pb.rb +37 -0
- data/lib/gen/temporal/api/schedule/v1/message_pb.rb +128 -0
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +73 -0
- data/lib/gen/temporal/api/update/v1/message_pb.rb +26 -0
- data/lib/gen/temporal/api/version/v1/message_pb.rb +41 -0
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +110 -0
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +771 -0
- data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +20 -0
- data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +58 -0
- data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +57 -0
- data/lib/gen/temporal/sdk/core/bridge/bridge_pb.rb +222 -0
- data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +57 -0
- data/lib/gen/temporal/sdk/core/common/common_pb.rb +22 -0
- data/lib/gen/temporal/sdk/core/core_interface_pb.rb +34 -0
- data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +27 -0
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +164 -0
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +192 -0
- data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +34 -0
- data/lib/temporal/bridge.rb +14 -0
- data/lib/temporal/client/implementation.rb +339 -0
- data/lib/temporal/client/workflow_handle.rb +243 -0
- data/lib/temporal/client.rb +144 -0
- data/lib/temporal/connection.rb +736 -0
- data/lib/temporal/data_converter.rb +150 -0
- data/lib/temporal/error/failure.rb +194 -0
- data/lib/temporal/error/workflow_failure.rb +17 -0
- data/lib/temporal/errors.rb +22 -0
- data/lib/temporal/failure_converter/base.rb +26 -0
- data/lib/temporal/failure_converter/basic.rb +313 -0
- data/lib/temporal/failure_converter.rb +8 -0
- data/lib/temporal/interceptor/chain.rb +27 -0
- data/lib/temporal/interceptor/client.rb +102 -0
- data/lib/temporal/payload_codec/base.rb +32 -0
- data/lib/temporal/payload_converter/base.rb +24 -0
- data/lib/temporal/payload_converter/bytes.rb +26 -0
- data/lib/temporal/payload_converter/composite.rb +47 -0
- data/lib/temporal/payload_converter/encoding_base.rb +35 -0
- data/lib/temporal/payload_converter/json.rb +25 -0
- data/lib/temporal/payload_converter/nil.rb +25 -0
- data/lib/temporal/payload_converter.rb +14 -0
- data/lib/temporal/retry_policy.rb +82 -0
- data/lib/temporal/retry_state.rb +35 -0
- data/lib/temporal/runtime.rb +22 -0
- data/lib/temporal/timeout_type.rb +29 -0
- data/lib/temporal/version.rb +3 -0
- data/lib/temporal/workflow/execution_info.rb +54 -0
- data/lib/temporal/workflow/execution_status.rb +36 -0
- data/lib/temporal/workflow/id_reuse_policy.rb +36 -0
- data/lib/temporal/workflow/query_reject_condition.rb +33 -0
- data/lib/temporal.rb +8 -0
- data/lib/temporalio.rb +3 -0
- data/lib/thermite_patch.rb +23 -0
- data/temporalio.gemspec +41 -0
- metadata +583 -0
@@ -0,0 +1,911 @@
|
|
1
|
+
#![allow(clippy::large_enum_variant)]
|
2
|
+
|
3
|
+
use super::{
|
4
|
+
workflow_machines::MachineResponse, Cancellable, EventInfo, MachineKind, NewMachineWithCommand,
|
5
|
+
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
6
|
+
};
|
7
|
+
use rustfsm::{fsm, MachineError, StateMachine, TransitionResult};
|
8
|
+
use std::convert::{TryFrom, TryInto};
|
9
|
+
use temporal_sdk_core_protos::{
|
10
|
+
coresdk::{
|
11
|
+
activity_result::{self as ar, activity_resolution, ActivityResolution, Cancellation},
|
12
|
+
workflow_activation::ResolveActivity,
|
13
|
+
workflow_commands::{ActivityCancellationType, ScheduleActivity},
|
14
|
+
},
|
15
|
+
temporal::api::{
|
16
|
+
command::v1::{command, Command, RequestCancelActivityTaskCommandAttributes},
|
17
|
+
common::v1::{ActivityType, Payload, Payloads},
|
18
|
+
enums::v1::{CommandType, EventType, RetryState},
|
19
|
+
failure::v1::{
|
20
|
+
self as failure, failure::FailureInfo, ActivityFailureInfo, CanceledFailureInfo,
|
21
|
+
Failure,
|
22
|
+
},
|
23
|
+
history::v1::{
|
24
|
+
history_event, ActivityTaskCanceledEventAttributes,
|
25
|
+
ActivityTaskCompletedEventAttributes, ActivityTaskFailedEventAttributes,
|
26
|
+
ActivityTaskTimedOutEventAttributes, HistoryEvent,
|
27
|
+
},
|
28
|
+
},
|
29
|
+
};
|
30
|
+
|
31
|
+
fsm! {
|
32
|
+
pub(super) name ActivityMachine;
|
33
|
+
command ActivityMachineCommand;
|
34
|
+
error WFMachinesError;
|
35
|
+
shared_state SharedState;
|
36
|
+
|
37
|
+
Created --(Schedule, on_schedule)--> ScheduleCommandCreated;
|
38
|
+
|
39
|
+
ScheduleCommandCreated --(CommandScheduleActivityTask) --> ScheduleCommandCreated;
|
40
|
+
ScheduleCommandCreated --(ActivityTaskScheduled(i64),
|
41
|
+
shared on_activity_task_scheduled) --> ScheduledEventRecorded;
|
42
|
+
ScheduleCommandCreated --(Cancel, shared on_canceled) --> Canceled;
|
43
|
+
|
44
|
+
ScheduledEventRecorded --(ActivityTaskStarted(i64), shared on_task_started) --> Started;
|
45
|
+
ScheduledEventRecorded --(ActivityTaskTimedOut(ActivityTaskTimedOutEventAttributes),
|
46
|
+
shared on_task_timed_out) --> TimedOut;
|
47
|
+
ScheduledEventRecorded --(Cancel, shared on_canceled) --> ScheduledActivityCancelCommandCreated;
|
48
|
+
ScheduledEventRecorded --(Abandon, shared on_abandoned) --> Canceled;
|
49
|
+
|
50
|
+
Started --(ActivityTaskCompleted(ActivityTaskCompletedEventAttributes),
|
51
|
+
on_activity_task_completed) --> Completed;
|
52
|
+
Started --(ActivityTaskFailed(ActivityTaskFailedEventAttributes),
|
53
|
+
shared on_activity_task_failed) --> Failed;
|
54
|
+
Started --(ActivityTaskTimedOut(ActivityTaskTimedOutEventAttributes),
|
55
|
+
shared on_activity_task_timed_out) --> TimedOut;
|
56
|
+
Started --(Cancel, shared on_canceled) --> StartedActivityCancelCommandCreated;
|
57
|
+
Started --(Abandon, shared on_abandoned) --> Canceled;
|
58
|
+
|
59
|
+
ScheduledActivityCancelCommandCreated --(CommandRequestCancelActivityTask) --> ScheduledActivityCancelCommandCreated;
|
60
|
+
ScheduledActivityCancelCommandCreated --(ActivityTaskCancelRequested) --> ScheduledActivityCancelEventRecorded;
|
61
|
+
|
62
|
+
ScheduledActivityCancelEventRecorded --(ActivityTaskCanceled(ActivityTaskCanceledEventAttributes),
|
63
|
+
shared on_activity_task_canceled) --> Canceled;
|
64
|
+
ScheduledActivityCancelEventRecorded --(ActivityTaskStarted(i64)) --> StartedActivityCancelEventRecorded;
|
65
|
+
ScheduledActivityCancelEventRecorded --(ActivityTaskTimedOut(ActivityTaskTimedOutEventAttributes),
|
66
|
+
shared on_activity_task_timed_out) --> TimedOut;
|
67
|
+
|
68
|
+
StartedActivityCancelCommandCreated --(CommandRequestCancelActivityTask) --> StartedActivityCancelCommandCreated;
|
69
|
+
StartedActivityCancelCommandCreated --(ActivityTaskCancelRequested) --> StartedActivityCancelEventRecorded;
|
70
|
+
|
71
|
+
StartedActivityCancelEventRecorded --(ActivityTaskFailed(ActivityTaskFailedEventAttributes),
|
72
|
+
shared on_activity_task_failed) --> Failed;
|
73
|
+
StartedActivityCancelEventRecorded --(ActivityTaskCompleted(ActivityTaskCompletedEventAttributes),
|
74
|
+
shared on_activity_task_completed) --> Completed;
|
75
|
+
StartedActivityCancelEventRecorded --(ActivityTaskTimedOut(ActivityTaskTimedOutEventAttributes),
|
76
|
+
shared on_activity_task_timed_out) --> TimedOut;
|
77
|
+
StartedActivityCancelEventRecorded --(ActivityTaskCanceled(ActivityTaskCanceledEventAttributes),
|
78
|
+
shared on_activity_task_canceled) --> Canceled;
|
79
|
+
|
80
|
+
Canceled --(ActivityTaskStarted(i64), shared on_activity_task_started) --> Canceled;
|
81
|
+
Canceled --(ActivityTaskCompleted(ActivityTaskCompletedEventAttributes),
|
82
|
+
shared on_activity_task_completed) --> Canceled;
|
83
|
+
}
|
84
|
+
|
85
|
+
#[derive(Debug, derive_more::Display)]
|
86
|
+
pub(super) enum ActivityMachineCommand {
|
87
|
+
#[display(fmt = "Complete")]
|
88
|
+
Complete(Option<Payloads>),
|
89
|
+
#[display(fmt = "Fail")]
|
90
|
+
Fail(Failure),
|
91
|
+
#[display(fmt = "Cancel")]
|
92
|
+
Cancel(Option<Payloads>),
|
93
|
+
#[display(fmt = "RequestCancellation")]
|
94
|
+
RequestCancellation(Command),
|
95
|
+
}
|
96
|
+
|
97
|
+
/// Creates a new activity state machine and a command to schedule it on the server.
|
98
|
+
pub(super) fn new_activity(attribs: ScheduleActivity) -> NewMachineWithCommand {
|
99
|
+
let (activity, add_cmd) = ActivityMachine::new_scheduled(attribs);
|
100
|
+
NewMachineWithCommand {
|
101
|
+
command: add_cmd,
|
102
|
+
machine: activity.into(),
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
impl ActivityMachine {
|
107
|
+
/// Create a new activity and immediately schedule it.
|
108
|
+
fn new_scheduled(attribs: ScheduleActivity) -> (Self, Command) {
|
109
|
+
let mut s = Self {
|
110
|
+
state: Created {}.into(),
|
111
|
+
shared_state: SharedState {
|
112
|
+
cancellation_type: ActivityCancellationType::from_i32(attribs.cancellation_type)
|
113
|
+
.unwrap(),
|
114
|
+
attrs: attribs,
|
115
|
+
..Default::default()
|
116
|
+
},
|
117
|
+
};
|
118
|
+
OnEventWrapper::on_event_mut(&mut s, ActivityMachineEvents::Schedule)
|
119
|
+
.expect("Scheduling activities doesn't fail");
|
120
|
+
let cmd = Command {
|
121
|
+
command_type: CommandType::ScheduleActivityTask as i32,
|
122
|
+
attributes: Some(s.shared_state().attrs.clone().into()),
|
123
|
+
};
|
124
|
+
(s, cmd)
|
125
|
+
}
|
126
|
+
|
127
|
+
fn machine_responses_from_cancel_request(&self, cancel_cmd: Command) -> Vec<MachineResponse> {
|
128
|
+
let mut r = vec![MachineResponse::IssueNewCommand(cancel_cmd)];
|
129
|
+
if self.shared_state.cancellation_type
|
130
|
+
!= ActivityCancellationType::WaitCancellationCompleted
|
131
|
+
{
|
132
|
+
r.push(MachineResponse::PushWFJob(
|
133
|
+
self.create_cancelation_resolve(None).into(),
|
134
|
+
));
|
135
|
+
}
|
136
|
+
r
|
137
|
+
}
|
138
|
+
|
139
|
+
fn create_cancelation_resolve(&self, details: Option<Payload>) -> ResolveActivity {
|
140
|
+
ResolveActivity {
|
141
|
+
seq: self.shared_state.attrs.seq,
|
142
|
+
result: Some(ActivityResolution {
|
143
|
+
status: Some(activity_resolution::Status::Cancelled(Cancellation {
|
144
|
+
failure: Some(Failure {
|
145
|
+
message: "Activity cancelled".to_string(),
|
146
|
+
cause: Some(Box::from(Failure {
|
147
|
+
failure_info: Some(FailureInfo::CanceledFailureInfo(
|
148
|
+
CanceledFailureInfo {
|
149
|
+
details: details.map(Into::into),
|
150
|
+
},
|
151
|
+
)),
|
152
|
+
..Default::default()
|
153
|
+
})),
|
154
|
+
failure_info: Some(FailureInfo::ActivityFailureInfo(ActivityFailureInfo {
|
155
|
+
scheduled_event_id: self.shared_state.scheduled_event_id,
|
156
|
+
started_event_id: self.shared_state.started_event_id,
|
157
|
+
activity_type: Some(ActivityType {
|
158
|
+
name: self.shared_state.attrs.activity_type.clone(),
|
159
|
+
}),
|
160
|
+
activity_id: self.shared_state.attrs.activity_id.clone(),
|
161
|
+
retry_state: RetryState::CancelRequested as i32,
|
162
|
+
..Default::default()
|
163
|
+
})),
|
164
|
+
..Default::default()
|
165
|
+
}),
|
166
|
+
})),
|
167
|
+
}),
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
impl TryFrom<HistoryEvent> for ActivityMachineEvents {
|
173
|
+
type Error = WFMachinesError;
|
174
|
+
|
175
|
+
fn try_from(e: HistoryEvent) -> Result<Self, Self::Error> {
|
176
|
+
Ok(match e.event_type() {
|
177
|
+
EventType::ActivityTaskScheduled => Self::ActivityTaskScheduled(e.event_id),
|
178
|
+
EventType::ActivityTaskStarted => Self::ActivityTaskStarted(e.event_id),
|
179
|
+
EventType::ActivityTaskCompleted => {
|
180
|
+
if let Some(history_event::Attributes::ActivityTaskCompletedEventAttributes(
|
181
|
+
attrs,
|
182
|
+
)) = e.attributes
|
183
|
+
{
|
184
|
+
Self::ActivityTaskCompleted(attrs)
|
185
|
+
} else {
|
186
|
+
return Err(WFMachinesError::Fatal(format!(
|
187
|
+
"Activity completion attributes were unset: {}",
|
188
|
+
e
|
189
|
+
)));
|
190
|
+
}
|
191
|
+
}
|
192
|
+
EventType::ActivityTaskFailed => {
|
193
|
+
if let Some(history_event::Attributes::ActivityTaskFailedEventAttributes(attrs)) =
|
194
|
+
e.attributes
|
195
|
+
{
|
196
|
+
Self::ActivityTaskFailed(attrs)
|
197
|
+
} else {
|
198
|
+
return Err(WFMachinesError::Fatal(format!(
|
199
|
+
"Activity failure attributes were unset: {}",
|
200
|
+
e
|
201
|
+
)));
|
202
|
+
}
|
203
|
+
}
|
204
|
+
EventType::ActivityTaskTimedOut => {
|
205
|
+
if let Some(history_event::Attributes::ActivityTaskTimedOutEventAttributes(attrs)) =
|
206
|
+
e.attributes
|
207
|
+
{
|
208
|
+
Self::ActivityTaskTimedOut(attrs)
|
209
|
+
} else {
|
210
|
+
return Err(WFMachinesError::Fatal(format!(
|
211
|
+
"Activity timeout attributes were unset: {}",
|
212
|
+
e
|
213
|
+
)));
|
214
|
+
}
|
215
|
+
}
|
216
|
+
EventType::ActivityTaskCancelRequested => Self::ActivityTaskCancelRequested,
|
217
|
+
EventType::ActivityTaskCanceled => {
|
218
|
+
if let Some(history_event::Attributes::ActivityTaskCanceledEventAttributes(attrs)) =
|
219
|
+
e.attributes
|
220
|
+
{
|
221
|
+
Self::ActivityTaskCanceled(attrs)
|
222
|
+
} else {
|
223
|
+
return Err(WFMachinesError::Fatal(format!(
|
224
|
+
"Activity cancellation attributes were unset: {}",
|
225
|
+
e
|
226
|
+
)));
|
227
|
+
}
|
228
|
+
}
|
229
|
+
_ => {
|
230
|
+
return Err(WFMachinesError::Nondeterminism(format!(
|
231
|
+
"Activity machine does not handle this event: {}",
|
232
|
+
e
|
233
|
+
)))
|
234
|
+
}
|
235
|
+
})
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
239
|
+
impl WFMachinesAdapter for ActivityMachine {
|
240
|
+
fn adapt_response(
|
241
|
+
&self,
|
242
|
+
my_command: ActivityMachineCommand,
|
243
|
+
event_info: Option<EventInfo>,
|
244
|
+
) -> Result<Vec<MachineResponse>, WFMachinesError> {
|
245
|
+
Ok(match my_command {
|
246
|
+
ActivityMachineCommand::Complete(result) => {
|
247
|
+
vec![ResolveActivity {
|
248
|
+
seq: self.shared_state.attrs.seq,
|
249
|
+
result: Some(ActivityResolution {
|
250
|
+
status: Some(activity_resolution::Status::Completed(ar::Success {
|
251
|
+
result: convert_payloads(event_info, result)?,
|
252
|
+
})),
|
253
|
+
}),
|
254
|
+
}
|
255
|
+
.into()]
|
256
|
+
}
|
257
|
+
ActivityMachineCommand::Fail(failure) => {
|
258
|
+
vec![ResolveActivity {
|
259
|
+
seq: self.shared_state.attrs.seq,
|
260
|
+
result: Some(ActivityResolution {
|
261
|
+
status: Some(activity_resolution::Status::Failed(ar::Failure {
|
262
|
+
failure: Some(failure),
|
263
|
+
})),
|
264
|
+
}),
|
265
|
+
}
|
266
|
+
.into()]
|
267
|
+
}
|
268
|
+
ActivityMachineCommand::RequestCancellation(c) => {
|
269
|
+
self.machine_responses_from_cancel_request(c)
|
270
|
+
}
|
271
|
+
ActivityMachineCommand::Cancel(details) => {
|
272
|
+
vec![self
|
273
|
+
.create_cancelation_resolve(convert_payloads(event_info, details)?)
|
274
|
+
.into()]
|
275
|
+
}
|
276
|
+
})
|
277
|
+
}
|
278
|
+
|
279
|
+
fn matches_event(&self, event: &HistoryEvent) -> bool {
|
280
|
+
matches!(
|
281
|
+
event.event_type(),
|
282
|
+
EventType::ActivityTaskScheduled
|
283
|
+
| EventType::ActivityTaskStarted
|
284
|
+
| EventType::ActivityTaskCompleted
|
285
|
+
| EventType::ActivityTaskFailed
|
286
|
+
| EventType::ActivityTaskTimedOut
|
287
|
+
| EventType::ActivityTaskCancelRequested
|
288
|
+
| EventType::ActivityTaskCanceled
|
289
|
+
)
|
290
|
+
}
|
291
|
+
|
292
|
+
fn kind(&self) -> MachineKind {
|
293
|
+
MachineKind::Activity
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
impl TryFrom<CommandType> for ActivityMachineEvents {
|
298
|
+
type Error = ();
|
299
|
+
|
300
|
+
fn try_from(c: CommandType) -> Result<Self, Self::Error> {
|
301
|
+
Ok(match c {
|
302
|
+
CommandType::ScheduleActivityTask => Self::CommandScheduleActivityTask,
|
303
|
+
CommandType::RequestCancelActivityTask => Self::CommandRequestCancelActivityTask,
|
304
|
+
_ => return Err(()),
|
305
|
+
})
|
306
|
+
}
|
307
|
+
}
|
308
|
+
|
309
|
+
impl Cancellable for ActivityMachine {
|
310
|
+
fn cancel(&mut self) -> Result<Vec<MachineResponse>, MachineError<Self::Error>> {
|
311
|
+
if matches!(
|
312
|
+
self.state(),
|
313
|
+
ActivityMachineState::Completed(_)
|
314
|
+
| ActivityMachineState::Canceled(_)
|
315
|
+
| ActivityMachineState::Failed(_)
|
316
|
+
| ActivityMachineState::TimedOut(_)
|
317
|
+
) {
|
318
|
+
// Ignore attempted cancels in terminal states
|
319
|
+
debug!(
|
320
|
+
"Attempted to cancel already resolved activity (seq {})",
|
321
|
+
self.shared_state.attrs.seq
|
322
|
+
);
|
323
|
+
return Ok(vec![]);
|
324
|
+
}
|
325
|
+
let event = match self.shared_state.cancellation_type {
|
326
|
+
ActivityCancellationType::Abandon => ActivityMachineEvents::Abandon,
|
327
|
+
_ => ActivityMachineEvents::Cancel,
|
328
|
+
};
|
329
|
+
let vec = OnEventWrapper::on_event_mut(self, event)?;
|
330
|
+
let res = vec
|
331
|
+
.into_iter()
|
332
|
+
.flat_map(|amc| match amc {
|
333
|
+
ActivityMachineCommand::RequestCancellation(cmd) => {
|
334
|
+
self.machine_responses_from_cancel_request(cmd)
|
335
|
+
}
|
336
|
+
ActivityMachineCommand::Cancel(details) => {
|
337
|
+
vec![self
|
338
|
+
.create_cancelation_resolve(
|
339
|
+
details
|
340
|
+
.map(TryInto::try_into)
|
341
|
+
.transpose()
|
342
|
+
.unwrap_or_default(),
|
343
|
+
)
|
344
|
+
.into()]
|
345
|
+
}
|
346
|
+
x => panic!("Invalid cancel event response {:?}", x),
|
347
|
+
})
|
348
|
+
.collect();
|
349
|
+
Ok(res)
|
350
|
+
}
|
351
|
+
|
352
|
+
fn was_cancelled_before_sent_to_server(&self) -> bool {
|
353
|
+
self.shared_state().cancelled_before_sent
|
354
|
+
}
|
355
|
+
}
|
356
|
+
|
357
|
+
#[derive(Default, Clone)]
|
358
|
+
pub(super) struct SharedState {
|
359
|
+
scheduled_event_id: i64,
|
360
|
+
started_event_id: i64,
|
361
|
+
attrs: ScheduleActivity,
|
362
|
+
cancellation_type: ActivityCancellationType,
|
363
|
+
cancelled_before_sent: bool,
|
364
|
+
}
|
365
|
+
|
366
|
+
#[derive(Default, Clone)]
|
367
|
+
pub(super) struct Created {}
|
368
|
+
|
369
|
+
impl Created {
|
370
|
+
pub(super) fn on_schedule(self) -> ActivityMachineTransition<ScheduleCommandCreated> {
|
371
|
+
// would add command here
|
372
|
+
TransitionResult::default()
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
#[derive(Default, Clone)]
|
377
|
+
pub(super) struct ScheduleCommandCreated {}
|
378
|
+
|
379
|
+
impl ScheduleCommandCreated {
|
380
|
+
pub(super) fn on_activity_task_scheduled(
|
381
|
+
self,
|
382
|
+
dat: SharedState,
|
383
|
+
scheduled_event_id: i64,
|
384
|
+
) -> ActivityMachineTransition<ScheduledEventRecorded> {
|
385
|
+
ActivityMachineTransition::ok_shared(
|
386
|
+
vec![],
|
387
|
+
ScheduledEventRecorded::default(),
|
388
|
+
SharedState {
|
389
|
+
scheduled_event_id,
|
390
|
+
..dat
|
391
|
+
},
|
392
|
+
)
|
393
|
+
}
|
394
|
+
pub(super) fn on_canceled(self, dat: SharedState) -> ActivityMachineTransition<Canceled> {
|
395
|
+
let canceled_state = SharedState {
|
396
|
+
cancelled_before_sent: true,
|
397
|
+
..dat
|
398
|
+
};
|
399
|
+
match dat.cancellation_type {
|
400
|
+
ActivityCancellationType::Abandon => {
|
401
|
+
ActivityMachineTransition::ok_shared(vec![], Canceled::default(), canceled_state)
|
402
|
+
}
|
403
|
+
_ => notify_lang_activity_cancelled(canceled_state, None),
|
404
|
+
}
|
405
|
+
}
|
406
|
+
}
|
407
|
+
|
408
|
+
#[derive(Default, Clone)]
|
409
|
+
pub(super) struct ScheduledEventRecorded {}
|
410
|
+
|
411
|
+
impl ScheduledEventRecorded {
|
412
|
+
pub(super) fn on_task_started(
|
413
|
+
self,
|
414
|
+
dat: SharedState,
|
415
|
+
started_event_id: i64,
|
416
|
+
) -> ActivityMachineTransition<Started> {
|
417
|
+
ActivityMachineTransition::ok_shared(
|
418
|
+
vec![],
|
419
|
+
Started::default(),
|
420
|
+
SharedState {
|
421
|
+
started_event_id,
|
422
|
+
..dat
|
423
|
+
},
|
424
|
+
)
|
425
|
+
}
|
426
|
+
pub(super) fn on_task_timed_out(
|
427
|
+
self,
|
428
|
+
dat: SharedState,
|
429
|
+
attrs: ActivityTaskTimedOutEventAttributes,
|
430
|
+
) -> ActivityMachineTransition<TimedOut> {
|
431
|
+
notify_lang_activity_timed_out(dat, attrs)
|
432
|
+
}
|
433
|
+
|
434
|
+
pub(super) fn on_canceled(
|
435
|
+
self,
|
436
|
+
dat: SharedState,
|
437
|
+
) -> ActivityMachineTransition<ScheduledActivityCancelCommandCreated> {
|
438
|
+
create_request_cancel_activity_task_command(
|
439
|
+
dat,
|
440
|
+
ScheduledActivityCancelCommandCreated::default(),
|
441
|
+
)
|
442
|
+
}
|
443
|
+
pub(super) fn on_abandoned(self, dat: SharedState) -> ActivityMachineTransition<Canceled> {
|
444
|
+
notify_lang_activity_cancelled(dat, None)
|
445
|
+
}
|
446
|
+
}
|
447
|
+
|
448
|
+
#[derive(Default, Clone)]
|
449
|
+
pub(super) struct Started {}
|
450
|
+
|
451
|
+
impl Started {
|
452
|
+
pub(super) fn on_activity_task_completed(
|
453
|
+
self,
|
454
|
+
attrs: ActivityTaskCompletedEventAttributes,
|
455
|
+
) -> ActivityMachineTransition<Completed> {
|
456
|
+
ActivityMachineTransition::ok(
|
457
|
+
vec![ActivityMachineCommand::Complete(attrs.result)],
|
458
|
+
Completed::default(),
|
459
|
+
)
|
460
|
+
}
|
461
|
+
pub(super) fn on_activity_task_failed(
|
462
|
+
self,
|
463
|
+
dat: SharedState,
|
464
|
+
attrs: ActivityTaskFailedEventAttributes,
|
465
|
+
) -> ActivityMachineTransition<Failed> {
|
466
|
+
ActivityMachineTransition::ok(
|
467
|
+
vec![ActivityMachineCommand::Fail(new_failure(dat, attrs))],
|
468
|
+
Failed::default(),
|
469
|
+
)
|
470
|
+
}
|
471
|
+
|
472
|
+
pub(super) fn on_activity_task_timed_out(
|
473
|
+
self,
|
474
|
+
dat: SharedState,
|
475
|
+
attrs: ActivityTaskTimedOutEventAttributes,
|
476
|
+
) -> ActivityMachineTransition<TimedOut> {
|
477
|
+
notify_lang_activity_timed_out(dat, attrs)
|
478
|
+
}
|
479
|
+
|
480
|
+
pub(super) fn on_canceled(
|
481
|
+
self,
|
482
|
+
dat: SharedState,
|
483
|
+
) -> ActivityMachineTransition<StartedActivityCancelCommandCreated> {
|
484
|
+
create_request_cancel_activity_task_command(
|
485
|
+
dat,
|
486
|
+
StartedActivityCancelCommandCreated::default(),
|
487
|
+
)
|
488
|
+
}
|
489
|
+
pub(super) fn on_abandoned(self, dat: SharedState) -> ActivityMachineTransition<Canceled> {
|
490
|
+
notify_lang_activity_cancelled(dat, None)
|
491
|
+
}
|
492
|
+
}
|
493
|
+
|
494
|
+
#[derive(Default, Clone)]
|
495
|
+
pub(super) struct ScheduledActivityCancelCommandCreated {}
|
496
|
+
|
497
|
+
#[derive(Default, Clone)]
|
498
|
+
pub(super) struct ScheduledActivityCancelEventRecorded {}
|
499
|
+
|
500
|
+
impl ScheduledActivityCancelEventRecorded {
|
501
|
+
pub(super) fn on_activity_task_canceled(
|
502
|
+
self,
|
503
|
+
dat: SharedState,
|
504
|
+
attrs: ActivityTaskCanceledEventAttributes,
|
505
|
+
) -> ActivityMachineTransition<Canceled> {
|
506
|
+
notify_if_not_already_cancelled(dat, |dat| notify_lang_activity_cancelled(dat, Some(attrs)))
|
507
|
+
}
|
508
|
+
|
509
|
+
pub(super) fn on_activity_task_timed_out(
|
510
|
+
self,
|
511
|
+
dat: SharedState,
|
512
|
+
attrs: ActivityTaskTimedOutEventAttributes,
|
513
|
+
) -> ActivityMachineTransition<TimedOut> {
|
514
|
+
notify_if_not_already_cancelled(dat, |dat| notify_lang_activity_timed_out(dat, attrs))
|
515
|
+
}
|
516
|
+
}
|
517
|
+
|
518
|
+
impl From<ScheduledActivityCancelCommandCreated> for ScheduledActivityCancelEventRecorded {
|
519
|
+
fn from(_: ScheduledActivityCancelCommandCreated) -> Self {
|
520
|
+
Self::default()
|
521
|
+
}
|
522
|
+
}
|
523
|
+
|
524
|
+
#[derive(Default, Clone)]
|
525
|
+
pub(super) struct StartedActivityCancelCommandCreated {}
|
526
|
+
|
527
|
+
#[derive(Default, Clone)]
|
528
|
+
pub(super) struct StartedActivityCancelEventRecorded {}
|
529
|
+
|
530
|
+
impl StartedActivityCancelEventRecorded {
|
531
|
+
pub(super) fn on_activity_task_completed(
|
532
|
+
self,
|
533
|
+
dat: SharedState,
|
534
|
+
attrs: ActivityTaskCompletedEventAttributes,
|
535
|
+
) -> ActivityMachineTransition<Completed> {
|
536
|
+
notify_if_not_already_cancelled(dat, |_| {
|
537
|
+
TransitionResult::commands(vec![ActivityMachineCommand::Complete(attrs.result)])
|
538
|
+
})
|
539
|
+
}
|
540
|
+
pub(super) fn on_activity_task_failed(
|
541
|
+
self,
|
542
|
+
dat: SharedState,
|
543
|
+
attrs: ActivityTaskFailedEventAttributes,
|
544
|
+
) -> ActivityMachineTransition<Failed> {
|
545
|
+
notify_if_not_already_cancelled(dat, |dat| {
|
546
|
+
TransitionResult::commands(vec![ActivityMachineCommand::Fail(new_failure(dat, attrs))])
|
547
|
+
})
|
548
|
+
}
|
549
|
+
pub(super) fn on_activity_task_timed_out(
|
550
|
+
self,
|
551
|
+
dat: SharedState,
|
552
|
+
attrs: ActivityTaskTimedOutEventAttributes,
|
553
|
+
) -> ActivityMachineTransition<TimedOut> {
|
554
|
+
notify_if_not_already_cancelled(dat, |dat| notify_lang_activity_timed_out(dat, attrs))
|
555
|
+
}
|
556
|
+
pub(super) fn on_activity_task_canceled(
|
557
|
+
self,
|
558
|
+
dat: SharedState,
|
559
|
+
attrs: ActivityTaskCanceledEventAttributes,
|
560
|
+
) -> ActivityMachineTransition<Canceled> {
|
561
|
+
notify_if_not_already_cancelled(dat, |dat| notify_lang_activity_cancelled(dat, Some(attrs)))
|
562
|
+
}
|
563
|
+
}
|
564
|
+
|
565
|
+
fn notify_if_not_already_cancelled<S>(
|
566
|
+
dat: SharedState,
|
567
|
+
notifier: impl FnOnce(SharedState) -> ActivityMachineTransition<S>,
|
568
|
+
) -> ActivityMachineTransition<S>
|
569
|
+
where
|
570
|
+
S: Into<ActivityMachineState> + Default,
|
571
|
+
{
|
572
|
+
match &dat.cancellation_type {
|
573
|
+
// At this point if we are in TryCancel mode, we've already sent a cancellation failure
|
574
|
+
// to lang unblocking it, so there is no need to send another activation.
|
575
|
+
ActivityCancellationType::TryCancel => ActivityMachineTransition::default(),
|
576
|
+
ActivityCancellationType::WaitCancellationCompleted => notifier(dat),
|
577
|
+
// Abandon results in going into Cancelled immediately, so we should never reach this state
|
578
|
+
ActivityCancellationType::Abandon => unreachable!(
|
579
|
+
"Cancellations with type Abandon should go into terminal state immediately."
|
580
|
+
),
|
581
|
+
}
|
582
|
+
}
|
583
|
+
|
584
|
+
impl From<ScheduledActivityCancelEventRecorded> for StartedActivityCancelEventRecorded {
|
585
|
+
fn from(_: ScheduledActivityCancelEventRecorded) -> Self {
|
586
|
+
Self::default()
|
587
|
+
}
|
588
|
+
}
|
589
|
+
|
590
|
+
impl From<ScheduledEventRecorded> for Canceled {
|
591
|
+
fn from(_: ScheduledEventRecorded) -> Self {
|
592
|
+
Self::default()
|
593
|
+
}
|
594
|
+
}
|
595
|
+
|
596
|
+
impl From<Started> for Canceled {
|
597
|
+
fn from(_: Started) -> Self {
|
598
|
+
Self::default()
|
599
|
+
}
|
600
|
+
}
|
601
|
+
|
602
|
+
#[derive(Default, Clone)]
|
603
|
+
pub(super) struct Completed {}
|
604
|
+
|
605
|
+
#[derive(Default, Clone)]
|
606
|
+
pub(super) struct Failed {}
|
607
|
+
|
608
|
+
impl From<ScheduledEventRecorded> for TimedOut {
|
609
|
+
fn from(_: ScheduledEventRecorded) -> Self {
|
610
|
+
Self::default()
|
611
|
+
}
|
612
|
+
}
|
613
|
+
|
614
|
+
impl From<Started> for TimedOut {
|
615
|
+
fn from(_: Started) -> Self {
|
616
|
+
Self::default()
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
620
|
+
impl From<ScheduledActivityCancelEventRecorded> for TimedOut {
|
621
|
+
fn from(_: ScheduledActivityCancelEventRecorded) -> Self {
|
622
|
+
Self::default()
|
623
|
+
}
|
624
|
+
}
|
625
|
+
|
626
|
+
impl From<StartedActivityCancelEventRecorded> for TimedOut {
|
627
|
+
fn from(_: StartedActivityCancelEventRecorded) -> Self {
|
628
|
+
Self::default()
|
629
|
+
}
|
630
|
+
}
|
631
|
+
|
632
|
+
impl From<StartedActivityCancelCommandCreated> for StartedActivityCancelEventRecorded {
|
633
|
+
fn from(_: StartedActivityCancelCommandCreated) -> Self {
|
634
|
+
Self::default()
|
635
|
+
}
|
636
|
+
}
|
637
|
+
|
638
|
+
#[derive(Default, Clone)]
|
639
|
+
pub(super) struct TimedOut {}
|
640
|
+
|
641
|
+
#[derive(Default, Clone)]
|
642
|
+
pub(super) struct Canceled {}
|
643
|
+
impl Canceled {
|
644
|
+
pub(super) fn on_activity_task_started(
|
645
|
+
self,
|
646
|
+
dat: SharedState,
|
647
|
+
seq_num: i64,
|
648
|
+
) -> ActivityMachineTransition<Canceled> {
|
649
|
+
// Abandoned activities might start anyway. Ignore the result.
|
650
|
+
if dat.cancellation_type == ActivityCancellationType::Abandon {
|
651
|
+
TransitionResult::default()
|
652
|
+
} else {
|
653
|
+
TransitionResult::Err(WFMachinesError::Nondeterminism(format!(
|
654
|
+
"Non-Abandon cancel mode activities cannot be started after being cancelled. \
|
655
|
+
Seq: {:?}",
|
656
|
+
seq_num
|
657
|
+
)))
|
658
|
+
}
|
659
|
+
}
|
660
|
+
pub(super) fn on_activity_task_completed(
|
661
|
+
self,
|
662
|
+
dat: SharedState,
|
663
|
+
attrs: ActivityTaskCompletedEventAttributes,
|
664
|
+
) -> ActivityMachineTransition<Canceled> {
|
665
|
+
// Abandoned activities might complete anyway. Ignore the result.
|
666
|
+
if dat.cancellation_type == ActivityCancellationType::Abandon {
|
667
|
+
TransitionResult::default()
|
668
|
+
} else {
|
669
|
+
TransitionResult::Err(WFMachinesError::Nondeterminism(format!(
|
670
|
+
"Non-Abandon cancel mode activities cannot be completed after being cancelled: {:?}",
|
671
|
+
attrs
|
672
|
+
)))
|
673
|
+
}
|
674
|
+
}
|
675
|
+
}
|
676
|
+
|
677
|
+
fn create_request_cancel_activity_task_command<S>(
|
678
|
+
dat: SharedState,
|
679
|
+
next_state: S,
|
680
|
+
) -> ActivityMachineTransition<S>
|
681
|
+
where
|
682
|
+
S: Into<ActivityMachineState>,
|
683
|
+
{
|
684
|
+
let cmd = Command {
|
685
|
+
command_type: CommandType::RequestCancelActivityTask as i32,
|
686
|
+
attributes: Some(
|
687
|
+
command::Attributes::RequestCancelActivityTaskCommandAttributes(
|
688
|
+
RequestCancelActivityTaskCommandAttributes {
|
689
|
+
scheduled_event_id: dat.scheduled_event_id,
|
690
|
+
},
|
691
|
+
),
|
692
|
+
),
|
693
|
+
};
|
694
|
+
ActivityMachineTransition::ok(
|
695
|
+
vec![ActivityMachineCommand::RequestCancellation(cmd)],
|
696
|
+
next_state,
|
697
|
+
)
|
698
|
+
}
|
699
|
+
|
700
|
+
/// Notifies lang side that activity has timed out by sending a failure with timeout error as a cause.
|
701
|
+
/// State machine will transition into the TimedOut state.
|
702
|
+
fn notify_lang_activity_timed_out(
|
703
|
+
dat: SharedState,
|
704
|
+
attrs: ActivityTaskTimedOutEventAttributes,
|
705
|
+
) -> TransitionResult<ActivityMachine, TimedOut> {
|
706
|
+
ActivityMachineTransition::ok_shared(
|
707
|
+
vec![ActivityMachineCommand::Fail(new_timeout_failure(
|
708
|
+
&dat, attrs,
|
709
|
+
))],
|
710
|
+
TimedOut::default(),
|
711
|
+
dat,
|
712
|
+
)
|
713
|
+
}
|
714
|
+
|
715
|
+
/// Notifies lang side that activity has been cancelled by sending a failure with cancelled failure
|
716
|
+
/// as a cause. Optional cancelled_event, if passed, is used to supply event IDs. State machine will
|
717
|
+
/// transition into the `next_state` provided as a parameter.
|
718
|
+
fn notify_lang_activity_cancelled(
|
719
|
+
dat: SharedState,
|
720
|
+
canceled_event: Option<ActivityTaskCanceledEventAttributes>,
|
721
|
+
) -> ActivityMachineTransition<Canceled> {
|
722
|
+
ActivityMachineTransition::ok_shared(
|
723
|
+
vec![ActivityMachineCommand::Cancel(
|
724
|
+
canceled_event.and_then(|e| e.details),
|
725
|
+
)],
|
726
|
+
Canceled::default(),
|
727
|
+
dat,
|
728
|
+
)
|
729
|
+
}
|
730
|
+
|
731
|
+
fn new_failure(dat: SharedState, attrs: ActivityTaskFailedEventAttributes) -> Failure {
|
732
|
+
Failure {
|
733
|
+
message: "Activity task failed".to_owned(),
|
734
|
+
cause: attrs.failure.map(Box::new),
|
735
|
+
failure_info: Some(FailureInfo::ActivityFailureInfo(
|
736
|
+
failure::ActivityFailureInfo {
|
737
|
+
identity: attrs.identity,
|
738
|
+
activity_type: Some(ActivityType {
|
739
|
+
name: dat.attrs.activity_type,
|
740
|
+
}),
|
741
|
+
activity_id: dat.attrs.activity_id,
|
742
|
+
retry_state: attrs.retry_state,
|
743
|
+
started_event_id: attrs.started_event_id,
|
744
|
+
scheduled_event_id: attrs.scheduled_event_id,
|
745
|
+
},
|
746
|
+
)),
|
747
|
+
..Default::default()
|
748
|
+
}
|
749
|
+
}
|
750
|
+
|
751
|
+
fn new_timeout_failure(dat: &SharedState, attrs: ActivityTaskTimedOutEventAttributes) -> Failure {
|
752
|
+
let failure_info = ActivityFailureInfo {
|
753
|
+
activity_id: dat.attrs.activity_id.to_string(),
|
754
|
+
activity_type: Some(ActivityType {
|
755
|
+
name: dat.attrs.activity_type.to_string(),
|
756
|
+
}),
|
757
|
+
scheduled_event_id: attrs.scheduled_event_id,
|
758
|
+
started_event_id: attrs.started_event_id,
|
759
|
+
retry_state: attrs.retry_state,
|
760
|
+
..Default::default()
|
761
|
+
};
|
762
|
+
Failure {
|
763
|
+
message: "Activity task timed out".to_string(),
|
764
|
+
cause: attrs.failure.map(Box::new),
|
765
|
+
failure_info: Some(FailureInfo::ActivityFailureInfo(failure_info)),
|
766
|
+
..Default::default()
|
767
|
+
}
|
768
|
+
}
|
769
|
+
|
770
|
+
fn convert_payloads(
|
771
|
+
event_info: Option<EventInfo>,
|
772
|
+
result: Option<Payloads>,
|
773
|
+
) -> Result<Option<Payload>, WFMachinesError> {
|
774
|
+
result.map(TryInto::try_into).transpose().map_err(|pe| {
|
775
|
+
WFMachinesError::Fatal(format!(
|
776
|
+
"Not exactly one payload in activity result ({}) for event: {:?}",
|
777
|
+
pe, event_info
|
778
|
+
))
|
779
|
+
})
|
780
|
+
}
|
781
|
+
|
782
|
+
#[cfg(test)]
|
783
|
+
mod test {
|
784
|
+
use super::*;
|
785
|
+
use crate::{
|
786
|
+
replay::TestHistoryBuilder, test_help::canned_histories, worker::workflow::ManagedWFFunc,
|
787
|
+
};
|
788
|
+
use rstest::{fixture, rstest};
|
789
|
+
use std::mem::discriminant;
|
790
|
+
use temporal_sdk::{
|
791
|
+
ActivityOptions, CancellableFuture, WfContext, WorkflowFunction, WorkflowResult,
|
792
|
+
};
|
793
|
+
use temporal_sdk_core_protos::coresdk::workflow_activation::{
|
794
|
+
workflow_activation_job, WorkflowActivationJob,
|
795
|
+
};
|
796
|
+
|
797
|
+
#[fixture]
|
798
|
+
fn activity_happy_hist() -> ManagedWFFunc {
|
799
|
+
let func = WorkflowFunction::new(activity_wf);
|
800
|
+
let t = canned_histories::single_activity("activity-id-1");
|
801
|
+
assert_eq!(2, t.get_full_history_info().unwrap().wf_task_count());
|
802
|
+
ManagedWFFunc::new(t, func, vec![])
|
803
|
+
}
|
804
|
+
|
805
|
+
#[fixture]
|
806
|
+
fn activity_failure_hist() -> ManagedWFFunc {
|
807
|
+
let func = WorkflowFunction::new(activity_wf);
|
808
|
+
let t = canned_histories::single_failed_activity("activity-id-1");
|
809
|
+
assert_eq!(2, t.get_full_history_info().unwrap().wf_task_count());
|
810
|
+
ManagedWFFunc::new(t, func, vec![])
|
811
|
+
}
|
812
|
+
|
813
|
+
async fn activity_wf(command_sink: WfContext) -> WorkflowResult<()> {
|
814
|
+
command_sink.activity(ActivityOptions::default()).await;
|
815
|
+
Ok(().into())
|
816
|
+
}
|
817
|
+
|
818
|
+
#[rstest(
|
819
|
+
wfm,
|
820
|
+
case::success(activity_happy_hist()),
|
821
|
+
case::failure(activity_failure_hist())
|
822
|
+
)]
|
823
|
+
#[tokio::test]
|
824
|
+
async fn single_activity_inc(mut wfm: ManagedWFFunc) {
|
825
|
+
wfm.get_next_activation().await.unwrap();
|
826
|
+
let commands = wfm.get_server_commands().commands;
|
827
|
+
assert_eq!(commands.len(), 1);
|
828
|
+
assert_eq!(
|
829
|
+
commands[0].command_type,
|
830
|
+
CommandType::ScheduleActivityTask as i32
|
831
|
+
);
|
832
|
+
|
833
|
+
wfm.get_next_activation().await.unwrap();
|
834
|
+
let commands = wfm.get_server_commands().commands;
|
835
|
+
assert_eq!(commands.len(), 1);
|
836
|
+
assert_eq!(
|
837
|
+
commands[0].command_type,
|
838
|
+
CommandType::CompleteWorkflowExecution as i32
|
839
|
+
);
|
840
|
+
wfm.shutdown().await.unwrap();
|
841
|
+
}
|
842
|
+
|
843
|
+
#[rstest(
|
844
|
+
wfm,
|
845
|
+
case::success(activity_happy_hist()),
|
846
|
+
case::failure(activity_failure_hist())
|
847
|
+
)]
|
848
|
+
#[tokio::test]
|
849
|
+
async fn single_activity_full(mut wfm: ManagedWFFunc) {
|
850
|
+
wfm.process_all_activations().await.unwrap();
|
851
|
+
let commands = wfm.get_server_commands().commands;
|
852
|
+
assert_eq!(commands.len(), 1);
|
853
|
+
assert_eq!(
|
854
|
+
commands[0].command_type,
|
855
|
+
CommandType::CompleteWorkflowExecution as i32
|
856
|
+
);
|
857
|
+
wfm.shutdown().await.unwrap();
|
858
|
+
}
|
859
|
+
|
860
|
+
#[tokio::test]
|
861
|
+
async fn immediate_activity_cancelation() {
|
862
|
+
let func = WorkflowFunction::new(|ctx: WfContext| async move {
|
863
|
+
let cancel_activity_future = ctx.activity(ActivityOptions::default());
|
864
|
+
// Immediately cancel the activity
|
865
|
+
cancel_activity_future.cancel(&ctx);
|
866
|
+
cancel_activity_future.await;
|
867
|
+
Ok(().into())
|
868
|
+
});
|
869
|
+
|
870
|
+
let mut t = TestHistoryBuilder::default();
|
871
|
+
t.add_by_type(EventType::WorkflowExecutionStarted);
|
872
|
+
t.add_full_wf_task();
|
873
|
+
t.add_workflow_execution_completed();
|
874
|
+
let mut wfm = ManagedWFFunc::new(t, func, vec![]);
|
875
|
+
|
876
|
+
let activation = wfm.process_all_activations().await.unwrap();
|
877
|
+
wfm.get_server_commands();
|
878
|
+
assert_matches!(
|
879
|
+
activation.jobs.as_slice(),
|
880
|
+
[WorkflowActivationJob {
|
881
|
+
variant: Some(workflow_activation_job::Variant::ResolveActivity(
|
882
|
+
ResolveActivity {
|
883
|
+
result: Some(ActivityResolution {
|
884
|
+
status: Some(activity_resolution::Status::Cancelled(_))
|
885
|
+
}),
|
886
|
+
..
|
887
|
+
}
|
888
|
+
)),
|
889
|
+
},]
|
890
|
+
);
|
891
|
+
wfm.shutdown().await.unwrap();
|
892
|
+
}
|
893
|
+
|
894
|
+
#[test]
|
895
|
+
fn cancels_ignored_terminal() {
|
896
|
+
for state in [
|
897
|
+
ActivityMachineState::Canceled(Canceled {}),
|
898
|
+
Failed {}.into(),
|
899
|
+
TimedOut {}.into(),
|
900
|
+
Completed {}.into(),
|
901
|
+
] {
|
902
|
+
let mut s = ActivityMachine {
|
903
|
+
state: state.clone(),
|
904
|
+
shared_state: Default::default(),
|
905
|
+
};
|
906
|
+
let cmds = s.cancel().unwrap();
|
907
|
+
assert_eq!(cmds.len(), 0);
|
908
|
+
assert_eq!(discriminant(&state), discriminant(&s.state));
|
909
|
+
}
|
910
|
+
}
|
911
|
+
}
|