temporalio 0.0.0 → 0.0.2
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 +4 -4
- data/README.md +301 -0
- data/bridge/Cargo.lock +2888 -0
- data/bridge/Cargo.toml +27 -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 +104 -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/client/Cargo.toml +40 -0
- data/bridge/sdk-core/client/LICENSE.txt +23 -0
- data/bridge/sdk-core/client/src/lib.rs +1286 -0
- data/bridge/sdk-core/client/src/metrics.rs +165 -0
- data/bridge/sdk-core/client/src/raw.rs +932 -0
- data/bridge/sdk-core/client/src/retry.rs +751 -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 +76 -0
- data/bridge/sdk-core/core/src/abstractions.rs +166 -0
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +1014 -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 +925 -0
- data/bridge/sdk-core/core/src/core_tests/mod.rs +100 -0
- data/bridge/sdk-core/core/src/core_tests/queries.rs +894 -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 +2090 -0
- data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +515 -0
- data/bridge/sdk-core/core/src/lib.rs +282 -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 +215 -0
- data/bridge/sdk-core/core/src/retry_logic.rs +202 -0
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +190 -0
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +428 -0
- data/bridge/sdk-core/core/src/telemetry/mod.rs +407 -0
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +78 -0
- data/bridge/sdk-core/core/src/test_help/mod.rs +889 -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 +1048 -0
- data/bridge/sdk-core/core/src/worker/activities.rs +481 -0
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +87 -0
- data/bridge/sdk-core/core/src/worker/client.rs +373 -0
- data/bridge/sdk-core/core/src/worker/mod.rs +570 -0
- data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +37 -0
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +101 -0
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +532 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +907 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +294 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +167 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +858 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +136 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +157 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +129 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +1450 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +316 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +178 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +708 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +439 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +435 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +175 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +242 -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 +1200 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +272 -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 +655 -0
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +1200 -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 +985 -0
- data/bridge/sdk-core/core-api/Cargo.toml +32 -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 +109 -0
- data/bridge/sdk-core/core-api/src/telemetry.rs +147 -0
- data/bridge/sdk-core/core-api/src/worker.rs +148 -0
- data/bridge/sdk-core/etc/deps.svg +162 -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/etc/regen-depgraph.sh +5 -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/evict_while_la_running_no_interference-23_history.bin +0 -0
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-85_history.bin +0 -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 +9 -0
- data/bridge/sdk-core/protos/api_upstream/build/go.mod +7 -0
- data/bridge/sdk-core/protos/api_upstream/build/go.sum +5 -0
- data/bridge/sdk-core/protos/api_upstream/build/tools.go +29 -0
- data/bridge/sdk-core/protos/api_upstream/dependencies/gogoproto/gogo.proto +141 -0
- data/bridge/sdk-core/protos/api_upstream/go.mod +6 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +89 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +260 -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 +47 -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 +56 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +170 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +118 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/interaction_type.proto +39 -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 +40 -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 +758 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +87 -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 +121 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +80 -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 +379 -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/version/v1/message.proto +59 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +146 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +1168 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +415 -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/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 +263 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +304 -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/interceptors.rs +50 -0
- data/bridge/sdk-core/sdk/src/lib.rs +794 -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 +694 -0
- data/bridge/sdk-core/sdk/src/workflow_future.rs +499 -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 +107 -0
- data/bridge/sdk-core/sdk-core-protos/src/constants.rs +7 -0
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +544 -0
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +230 -0
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +1970 -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 +36 -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 +650 -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 +221 -0
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +37 -0
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +133 -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 +788 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +53 -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 +223 -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 +597 -0
- data/bridge/sdk-core/tests/load_tests.rs +191 -0
- data/bridge/sdk-core/tests/main.rs +113 -0
- data/bridge/sdk-core/tests/runner.rs +93 -0
- data/bridge/src/connection.rs +186 -0
- data/bridge/src/lib.rs +239 -0
- data/bridge/src/runtime.rs +54 -0
- data/bridge/src/worker.rs +124 -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 +50 -0
- data/lib/gen/temporal/api/command/v1/message_pb.rb +174 -0
- data/lib/gen/temporal/api/common/v1/message_pb.rb +69 -0
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +33 -0
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +39 -0
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +42 -0
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +68 -0
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +77 -0
- data/lib/gen/temporal/api/enums/v1/interaction_type_pb.rb +25 -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 +23 -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 +490 -0
- data/lib/gen/temporal/api/interaction/v1/message_pb.rb +49 -0
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +63 -0
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +85 -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 +149 -0
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +73 -0
- data/lib/gen/temporal/api/version/v1/message_pb.rb +41 -0
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +111 -0
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +788 -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 +165 -0
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +196 -0
- data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +34 -0
- data/lib/temporalio/activity/context.rb +97 -0
- data/lib/temporalio/activity/info.rb +67 -0
- data/lib/temporalio/activity.rb +85 -0
- data/lib/temporalio/bridge/error.rb +8 -0
- data/lib/temporalio/bridge.rb +14 -0
- data/lib/temporalio/client/implementation.rb +340 -0
- data/lib/temporalio/client/workflow_handle.rb +243 -0
- data/lib/temporalio/client.rb +131 -0
- data/lib/temporalio/connection.rb +751 -0
- data/lib/temporalio/data_converter.rb +191 -0
- data/lib/temporalio/error/failure.rb +194 -0
- data/lib/temporalio/error/workflow_failure.rb +19 -0
- data/lib/temporalio/errors.rb +40 -0
- data/lib/temporalio/failure_converter/base.rb +26 -0
- data/lib/temporalio/failure_converter/basic.rb +319 -0
- data/lib/temporalio/failure_converter.rb +7 -0
- data/lib/temporalio/interceptor/chain.rb +28 -0
- data/lib/temporalio/interceptor/client.rb +123 -0
- data/lib/temporalio/payload_codec/base.rb +32 -0
- data/lib/temporalio/payload_converter/base.rb +24 -0
- data/lib/temporalio/payload_converter/bytes.rb +27 -0
- data/lib/temporalio/payload_converter/composite.rb +49 -0
- data/lib/temporalio/payload_converter/encoding_base.rb +35 -0
- data/lib/temporalio/payload_converter/json.rb +26 -0
- data/lib/temporalio/payload_converter/nil.rb +26 -0
- data/lib/temporalio/payload_converter.rb +14 -0
- data/lib/temporalio/retry_policy.rb +82 -0
- data/lib/temporalio/retry_state.rb +35 -0
- data/lib/temporalio/runtime.rb +25 -0
- data/lib/temporalio/timeout_type.rb +29 -0
- data/lib/temporalio/version.rb +3 -0
- data/lib/temporalio/worker/activity_runner.rb +92 -0
- data/lib/temporalio/worker/activity_worker.rb +138 -0
- data/lib/temporalio/worker/reactor.rb +46 -0
- data/lib/temporalio/worker/runner.rb +63 -0
- data/lib/temporalio/worker/sync_worker.rb +88 -0
- data/lib/temporalio/worker/thread_pool_executor.rb +51 -0
- data/lib/temporalio/worker.rb +198 -0
- data/lib/temporalio/workflow/execution_info.rb +54 -0
- data/lib/temporalio/workflow/execution_status.rb +36 -0
- data/lib/temporalio/workflow/id_reuse_policy.rb +36 -0
- data/lib/temporalio/workflow/query_reject_condition.rb +33 -0
- data/lib/temporalio.rb +12 -1
- data/lib/thermite_patch.rb +23 -0
- data/temporalio.gemspec +45 -0
- metadata +566 -9
- data/lib/temporal/version.rb +0 -3
- data/lib/temporal.rb +0 -4
- data/temporal.gemspec +0 -20
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
mod workflow_machines;
|
|
2
|
+
|
|
3
|
+
mod activity_state_machine;
|
|
4
|
+
mod cancel_external_state_machine;
|
|
5
|
+
mod cancel_workflow_state_machine;
|
|
6
|
+
mod child_workflow_state_machine;
|
|
7
|
+
mod complete_workflow_state_machine;
|
|
8
|
+
mod continue_as_new_workflow_state_machine;
|
|
9
|
+
mod fail_workflow_state_machine;
|
|
10
|
+
mod local_activity_state_machine;
|
|
11
|
+
mod modify_workflow_properties_state_machine;
|
|
12
|
+
mod patch_state_machine;
|
|
13
|
+
mod signal_external_state_machine;
|
|
14
|
+
mod timer_state_machine;
|
|
15
|
+
mod upsert_search_attributes_state_machine;
|
|
16
|
+
mod workflow_task_state_machine;
|
|
17
|
+
|
|
18
|
+
#[cfg(test)]
|
|
19
|
+
mod transition_coverage;
|
|
20
|
+
|
|
21
|
+
pub(crate) use workflow_machines::{WFMachinesError, WorkflowMachines};
|
|
22
|
+
|
|
23
|
+
use crate::telemetry::VecDisplayer;
|
|
24
|
+
use activity_state_machine::ActivityMachine;
|
|
25
|
+
use cancel_external_state_machine::CancelExternalMachine;
|
|
26
|
+
use cancel_workflow_state_machine::CancelWorkflowMachine;
|
|
27
|
+
use child_workflow_state_machine::ChildWorkflowMachine;
|
|
28
|
+
use complete_workflow_state_machine::CompleteWorkflowMachine;
|
|
29
|
+
use continue_as_new_workflow_state_machine::ContinueAsNewWorkflowMachine;
|
|
30
|
+
use fail_workflow_state_machine::FailWorkflowMachine;
|
|
31
|
+
use local_activity_state_machine::LocalActivityMachine;
|
|
32
|
+
use modify_workflow_properties_state_machine::ModifyWorkflowPropertiesMachine;
|
|
33
|
+
use patch_state_machine::PatchMachine;
|
|
34
|
+
use rustfsm::{MachineError, StateMachine};
|
|
35
|
+
use signal_external_state_machine::SignalExternalMachine;
|
|
36
|
+
use std::{
|
|
37
|
+
convert::{TryFrom, TryInto},
|
|
38
|
+
fmt::{Debug, Display},
|
|
39
|
+
};
|
|
40
|
+
use temporal_sdk_core_protos::temporal::api::{
|
|
41
|
+
command::v1::Command as ProtoCommand,
|
|
42
|
+
enums::v1::{CommandType, EventType},
|
|
43
|
+
history::v1::HistoryEvent,
|
|
44
|
+
};
|
|
45
|
+
use timer_state_machine::TimerMachine;
|
|
46
|
+
use upsert_search_attributes_state_machine::UpsertSearchAttributesMachine;
|
|
47
|
+
use workflow_machines::MachineResponse;
|
|
48
|
+
use workflow_task_state_machine::WorkflowTaskMachine;
|
|
49
|
+
|
|
50
|
+
#[cfg(test)]
|
|
51
|
+
use transition_coverage::add_coverage;
|
|
52
|
+
|
|
53
|
+
#[enum_dispatch::enum_dispatch]
|
|
54
|
+
#[allow(clippy::enum_variant_names, clippy::large_enum_variant)]
|
|
55
|
+
enum Machines {
|
|
56
|
+
ActivityMachine,
|
|
57
|
+
CancelExternalMachine,
|
|
58
|
+
CancelWorkflowMachine,
|
|
59
|
+
ChildWorkflowMachine,
|
|
60
|
+
CompleteWorkflowMachine,
|
|
61
|
+
ContinueAsNewWorkflowMachine,
|
|
62
|
+
FailWorkflowMachine,
|
|
63
|
+
LocalActivityMachine,
|
|
64
|
+
PatchMachine,
|
|
65
|
+
SignalExternalMachine,
|
|
66
|
+
TimerMachine,
|
|
67
|
+
WorkflowTaskMachine,
|
|
68
|
+
UpsertSearchAttributesMachine,
|
|
69
|
+
ModifyWorkflowPropertiesMachine,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// Extends [rustfsm::StateMachine] with some functionality specific to the temporal SDK.
|
|
73
|
+
///
|
|
74
|
+
/// Formerly known as `EntityStateMachine` in Java.
|
|
75
|
+
#[enum_dispatch::enum_dispatch(Machines)]
|
|
76
|
+
trait TemporalStateMachine: Send {
|
|
77
|
+
fn handle_command(
|
|
78
|
+
&mut self,
|
|
79
|
+
command_type: CommandType,
|
|
80
|
+
) -> Result<Vec<MachineResponse>, WFMachinesError>;
|
|
81
|
+
|
|
82
|
+
/// Returns true if this machine is compatible with the provided event. Provides a way to know
|
|
83
|
+
/// ahead of time if it's worth trying to call [TemporalStateMachine::handle_event] without
|
|
84
|
+
/// requiring mutable access.
|
|
85
|
+
fn matches_event(&self, event: &HistoryEvent) -> bool;
|
|
86
|
+
|
|
87
|
+
/// Tell the state machine to handle some event. Returns a list of responses that can be used
|
|
88
|
+
/// to update the overall state of the workflow. EX: To issue outgoing WF activations.
|
|
89
|
+
fn handle_event(
|
|
90
|
+
&mut self,
|
|
91
|
+
event: HistoryEvent,
|
|
92
|
+
has_next_event: bool,
|
|
93
|
+
) -> Result<Vec<MachineResponse>, WFMachinesError>;
|
|
94
|
+
|
|
95
|
+
/// Attempt to cancel the command associated with this state machine, if it is cancellable
|
|
96
|
+
fn cancel(&mut self) -> Result<Vec<MachineResponse>, WFMachinesError>;
|
|
97
|
+
|
|
98
|
+
/// Should return true if the command was cancelled before we sent it to the server. Always
|
|
99
|
+
/// returns false for non-cancellable machines
|
|
100
|
+
fn was_cancelled_before_sent_to_server(&self) -> bool;
|
|
101
|
+
|
|
102
|
+
/// Returns true if the state machine is in a final state
|
|
103
|
+
fn is_final_state(&self) -> bool;
|
|
104
|
+
|
|
105
|
+
/// Returns a friendly name for the type of this machine
|
|
106
|
+
fn name(&self) -> &str;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
impl<SM> TemporalStateMachine for SM
|
|
110
|
+
where
|
|
111
|
+
SM: StateMachine + WFMachinesAdapter + Cancellable + OnEventWrapper + Clone + Send + 'static,
|
|
112
|
+
<SM as StateMachine>::Event: TryFrom<HistoryEvent> + TryFrom<CommandType> + Display,
|
|
113
|
+
WFMachinesError: From<<<SM as StateMachine>::Event as TryFrom<HistoryEvent>>::Error>,
|
|
114
|
+
<SM as StateMachine>::Command: Debug + Display,
|
|
115
|
+
<SM as StateMachine>::State: Display,
|
|
116
|
+
<SM as StateMachine>::Error: Into<WFMachinesError> + 'static + Send + Sync,
|
|
117
|
+
{
|
|
118
|
+
fn handle_command(
|
|
119
|
+
&mut self,
|
|
120
|
+
command_type: CommandType,
|
|
121
|
+
) -> Result<Vec<MachineResponse>, WFMachinesError> {
|
|
122
|
+
debug!(
|
|
123
|
+
command_type = ?command_type,
|
|
124
|
+
machine_name = %self.name(),
|
|
125
|
+
state = %self.state(),
|
|
126
|
+
"handling command"
|
|
127
|
+
);
|
|
128
|
+
if let Ok(converted_command) = command_type.try_into() {
|
|
129
|
+
match OnEventWrapper::on_event_mut(self, converted_command) {
|
|
130
|
+
Ok(c) => process_machine_commands(self, c, None),
|
|
131
|
+
Err(MachineError::InvalidTransition) => {
|
|
132
|
+
Err(WFMachinesError::Nondeterminism(format!(
|
|
133
|
+
"Unexpected command producing an invalid transition {:?} in state {}",
|
|
134
|
+
command_type,
|
|
135
|
+
self.state()
|
|
136
|
+
)))
|
|
137
|
+
}
|
|
138
|
+
Err(MachineError::Underlying(e)) => Err(e.into()),
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
Err(WFMachinesError::Nondeterminism(format!(
|
|
142
|
+
"Unexpected command {:?} generated by a {:?} machine",
|
|
143
|
+
command_type,
|
|
144
|
+
self.name()
|
|
145
|
+
)))
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
fn matches_event(&self, event: &HistoryEvent) -> bool {
|
|
150
|
+
self.matches_event(event)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
fn handle_event(
|
|
154
|
+
&mut self,
|
|
155
|
+
event: HistoryEvent,
|
|
156
|
+
has_next_event: bool,
|
|
157
|
+
) -> Result<Vec<MachineResponse>, WFMachinesError> {
|
|
158
|
+
trace!(
|
|
159
|
+
event = %event,
|
|
160
|
+
machine_name = %self.name(),
|
|
161
|
+
state = %self.state(),
|
|
162
|
+
"handling event"
|
|
163
|
+
);
|
|
164
|
+
let event_info = EventInfo {
|
|
165
|
+
event_id: event.event_id,
|
|
166
|
+
event_type: event.event_type(),
|
|
167
|
+
has_next_event,
|
|
168
|
+
};
|
|
169
|
+
let converted_event: <Self as StateMachine>::Event = event.try_into()?;
|
|
170
|
+
|
|
171
|
+
match OnEventWrapper::on_event_mut(self, converted_event) {
|
|
172
|
+
Ok(c) => process_machine_commands(self, c, Some(event_info)),
|
|
173
|
+
Err(MachineError::InvalidTransition) => Err(WFMachinesError::Fatal(format!(
|
|
174
|
+
"{} in state {} says the transition is invalid during event {:?}",
|
|
175
|
+
self.name(),
|
|
176
|
+
self.state(),
|
|
177
|
+
event_info
|
|
178
|
+
))),
|
|
179
|
+
Err(MachineError::Underlying(e)) => Err(e.into()),
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
fn cancel(&mut self) -> Result<Vec<MachineResponse>, WFMachinesError> {
|
|
184
|
+
let res = self.cancel();
|
|
185
|
+
res.map_err(|e| match e {
|
|
186
|
+
MachineError::InvalidTransition => WFMachinesError::Fatal(format!(
|
|
187
|
+
"Invalid transition while attempting to cancel {} in {}",
|
|
188
|
+
self.name(),
|
|
189
|
+
self.state(),
|
|
190
|
+
)),
|
|
191
|
+
MachineError::Underlying(e) => e.into(),
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
fn was_cancelled_before_sent_to_server(&self) -> bool {
|
|
196
|
+
self.was_cancelled_before_sent_to_server()
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
fn is_final_state(&self) -> bool {
|
|
200
|
+
self.has_reached_final_state()
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
fn name(&self) -> &str {
|
|
204
|
+
self.name()
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
fn process_machine_commands<SM>(
|
|
209
|
+
machine: &mut SM,
|
|
210
|
+
commands: Vec<SM::Command>,
|
|
211
|
+
event_info: Option<EventInfo>,
|
|
212
|
+
) -> Result<Vec<MachineResponse>, WFMachinesError>
|
|
213
|
+
where
|
|
214
|
+
SM: TemporalStateMachine + StateMachine + WFMachinesAdapter,
|
|
215
|
+
<SM as StateMachine>::Event: Display,
|
|
216
|
+
<SM as StateMachine>::Command: Debug + Display,
|
|
217
|
+
<SM as StateMachine>::State: Display,
|
|
218
|
+
{
|
|
219
|
+
if !commands.is_empty() {
|
|
220
|
+
debug!(commands=%commands.display(), state=%machine.state(),
|
|
221
|
+
machine_name=%TemporalStateMachine::name(machine), "Machine produced commands");
|
|
222
|
+
}
|
|
223
|
+
let mut machine_responses = vec![];
|
|
224
|
+
for cmd in commands {
|
|
225
|
+
machine_responses.extend(machine.adapt_response(cmd, event_info)?);
|
|
226
|
+
}
|
|
227
|
+
Ok(machine_responses)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/// This trait exists to bridge [StateMachine]s and the [WorkflowMachines] instance. It has access
|
|
231
|
+
/// to the machine's concrete types while hiding those details from [WorkflowMachines]
|
|
232
|
+
trait WFMachinesAdapter: StateMachine {
|
|
233
|
+
/// A command that this [StateMachine] instance just produced, and maybe the event being
|
|
234
|
+
/// processed, perform any handling that needs inform the [WorkflowMachines] instance of some
|
|
235
|
+
/// action to be taken in response to that command.
|
|
236
|
+
fn adapt_response(
|
|
237
|
+
&self,
|
|
238
|
+
my_command: Self::Command,
|
|
239
|
+
event_info: Option<EventInfo>,
|
|
240
|
+
) -> Result<Vec<MachineResponse>, WFMachinesError>;
|
|
241
|
+
|
|
242
|
+
/// Returns true if this machine is compatible with the provided event. Provides a way to know
|
|
243
|
+
/// ahead of time if it's worth trying to call [TemporalStateMachine::handle_event] without
|
|
244
|
+
/// requiring mutable access.
|
|
245
|
+
fn matches_event(&self, event: &HistoryEvent) -> bool;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
#[derive(Debug, Copy, Clone)]
|
|
249
|
+
struct EventInfo {
|
|
250
|
+
event_id: i64,
|
|
251
|
+
event_type: EventType,
|
|
252
|
+
has_next_event: bool,
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
trait Cancellable: StateMachine {
|
|
256
|
+
/// Cancel the machine / the command represented by the machine.
|
|
257
|
+
///
|
|
258
|
+
/// # Panics
|
|
259
|
+
/// * If the machine is not cancellable. It's a logic error on our part to call it on such
|
|
260
|
+
/// machines.
|
|
261
|
+
fn cancel(&mut self) -> Result<Vec<MachineResponse>, MachineError<Self::Error>> {
|
|
262
|
+
// It's a logic error on our part if this is ever called on a machine that can't actually
|
|
263
|
+
// be cancelled
|
|
264
|
+
panic!("Machine {} cannot be cancelled", self.name())
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/// Should return true if the command was cancelled before we sent it to the server
|
|
268
|
+
fn was_cancelled_before_sent_to_server(&self) -> bool {
|
|
269
|
+
false
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/// We need to wrap calls to [StateMachine::on_event_mut] to track coverage, or anything else
|
|
274
|
+
/// we'd like to do on every call.
|
|
275
|
+
pub(crate) trait OnEventWrapper: StateMachine
|
|
276
|
+
where
|
|
277
|
+
<Self as StateMachine>::State: Display,
|
|
278
|
+
<Self as StateMachine>::Event: Display,
|
|
279
|
+
Self: Clone,
|
|
280
|
+
{
|
|
281
|
+
fn on_event_mut(
|
|
282
|
+
&mut self,
|
|
283
|
+
event: Self::Event,
|
|
284
|
+
) -> Result<Vec<Self::Command>, MachineError<Self::Error>> {
|
|
285
|
+
#[cfg(test)]
|
|
286
|
+
let from_state = self.state().to_string();
|
|
287
|
+
#[cfg(test)]
|
|
288
|
+
let converted_event_str = event.to_string();
|
|
289
|
+
|
|
290
|
+
let res = StateMachine::on_event_mut(self, event);
|
|
291
|
+
if res.is_ok() {
|
|
292
|
+
#[cfg(test)]
|
|
293
|
+
add_coverage(
|
|
294
|
+
self.name().to_owned(),
|
|
295
|
+
from_state,
|
|
296
|
+
self.state().to_string(),
|
|
297
|
+
converted_event_str,
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
res
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
impl<SM> OnEventWrapper for SM
|
|
305
|
+
where
|
|
306
|
+
SM: StateMachine,
|
|
307
|
+
<Self as StateMachine>::State: Display,
|
|
308
|
+
<Self as StateMachine>::Event: Display,
|
|
309
|
+
Self: Clone,
|
|
310
|
+
{
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
struct NewMachineWithCommand {
|
|
314
|
+
command: ProtoCommand,
|
|
315
|
+
machine: Machines,
|
|
316
|
+
}
|
data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
use super::{
|
|
2
|
+
workflow_machines::{MachineResponse, WFMachinesError},
|
|
3
|
+
NewMachineWithCommand,
|
|
4
|
+
};
|
|
5
|
+
use crate::worker::workflow::machines::{Cancellable, EventInfo, WFMachinesAdapter};
|
|
6
|
+
use rustfsm::{fsm, TransitionResult};
|
|
7
|
+
use temporal_sdk_core_protos::{
|
|
8
|
+
coresdk::workflow_commands::ModifyWorkflowProperties,
|
|
9
|
+
temporal::api::{
|
|
10
|
+
command::v1::Command,
|
|
11
|
+
enums::v1::{CommandType, EventType},
|
|
12
|
+
history::v1::HistoryEvent,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
fsm! {
|
|
17
|
+
pub(super) name ModifyWorkflowPropertiesMachine;
|
|
18
|
+
command ModifyWorkflowPropertiesMachineCommand;
|
|
19
|
+
error WFMachinesError;
|
|
20
|
+
shared_state SharedState;
|
|
21
|
+
|
|
22
|
+
Created --(CommandScheduled) --> CommandIssued;
|
|
23
|
+
CommandIssued --(CommandRecorded) --> Done;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/// Instantiates an ModifyWorkflowPropertiesMachine and packs it together with the command to
|
|
27
|
+
/// be sent to server.
|
|
28
|
+
pub(super) fn modify_workflow_properties(
|
|
29
|
+
lang_cmd: ModifyWorkflowProperties,
|
|
30
|
+
) -> NewMachineWithCommand {
|
|
31
|
+
let sm = ModifyWorkflowPropertiesMachine {
|
|
32
|
+
state: Created {}.into(),
|
|
33
|
+
shared_state: (),
|
|
34
|
+
};
|
|
35
|
+
let cmd = Command {
|
|
36
|
+
command_type: CommandType::ModifyWorkflowProperties as i32,
|
|
37
|
+
attributes: Some(lang_cmd.into()),
|
|
38
|
+
};
|
|
39
|
+
NewMachineWithCommand {
|
|
40
|
+
command: cmd,
|
|
41
|
+
machine: sm.into(),
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type SharedState = ();
|
|
46
|
+
|
|
47
|
+
#[derive(Debug, derive_more::Display)]
|
|
48
|
+
pub(super) enum ModifyWorkflowPropertiesMachineCommand {}
|
|
49
|
+
|
|
50
|
+
#[derive(Debug, Default, Clone, derive_more::Display)]
|
|
51
|
+
pub(super) struct Created {}
|
|
52
|
+
|
|
53
|
+
#[derive(Debug, Default, Clone, derive_more::Display)]
|
|
54
|
+
pub(super) struct CommandIssued {}
|
|
55
|
+
|
|
56
|
+
#[derive(Debug, Default, Clone, derive_more::Display)]
|
|
57
|
+
pub(super) struct Done {}
|
|
58
|
+
|
|
59
|
+
impl WFMachinesAdapter for ModifyWorkflowPropertiesMachine {
|
|
60
|
+
fn adapt_response(
|
|
61
|
+
&self,
|
|
62
|
+
_my_command: Self::Command,
|
|
63
|
+
_event_info: Option<EventInfo>,
|
|
64
|
+
) -> Result<Vec<MachineResponse>, Self::Error> {
|
|
65
|
+
Err(Self::Error::Nondeterminism(
|
|
66
|
+
"ModifyWorkflowProperties does not use state machine commands".to_string(),
|
|
67
|
+
))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
fn matches_event(&self, event: &HistoryEvent) -> bool {
|
|
71
|
+
matches!(event.event_type(), EventType::WorkflowPropertiesModified)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
impl Cancellable for ModifyWorkflowPropertiesMachine {}
|
|
76
|
+
|
|
77
|
+
impl TryFrom<HistoryEvent> for ModifyWorkflowPropertiesMachineEvents {
|
|
78
|
+
type Error = WFMachinesError;
|
|
79
|
+
|
|
80
|
+
fn try_from(e: HistoryEvent) -> Result<Self, Self::Error> {
|
|
81
|
+
match e.event_type() {
|
|
82
|
+
EventType::WorkflowPropertiesModified => {
|
|
83
|
+
Ok(ModifyWorkflowPropertiesMachineEvents::CommandRecorded)
|
|
84
|
+
}
|
|
85
|
+
_ => Err(Self::Error::Nondeterminism(format!(
|
|
86
|
+
"ModifyWorkflowPropertiesMachine does not handle {e}"
|
|
87
|
+
))),
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
impl TryFrom<CommandType> for ModifyWorkflowPropertiesMachineEvents {
|
|
93
|
+
type Error = WFMachinesError;
|
|
94
|
+
|
|
95
|
+
fn try_from(c: CommandType) -> Result<Self, Self::Error> {
|
|
96
|
+
match c {
|
|
97
|
+
CommandType::ModifyWorkflowProperties => {
|
|
98
|
+
Ok(ModifyWorkflowPropertiesMachineEvents::CommandScheduled)
|
|
99
|
+
}
|
|
100
|
+
_ => Err(Self::Error::Nondeterminism(format!(
|
|
101
|
+
"ModifyWorkflowPropertiesMachine does not handle command type {c:?}"
|
|
102
|
+
))),
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
impl From<CommandIssued> for Done {
|
|
108
|
+
fn from(_: CommandIssued) -> Self {
|
|
109
|
+
Self {}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
impl From<Created> for CommandIssued {
|
|
114
|
+
fn from(_: Created) -> Self {
|
|
115
|
+
Self {}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
#[cfg(test)]
|
|
120
|
+
mod tests {
|
|
121
|
+
use super::*;
|
|
122
|
+
use crate::{replay::TestHistoryBuilder, worker::workflow::ManagedWFFunc};
|
|
123
|
+
use temporal_sdk::{WfContext, WorkflowFunction};
|
|
124
|
+
use temporal_sdk_core_protos::temporal::api::{
|
|
125
|
+
command::v1::command::Attributes, common::v1::Payload,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
#[tokio::test]
|
|
129
|
+
async fn workflow_modify_props() {
|
|
130
|
+
let mut t = TestHistoryBuilder::default();
|
|
131
|
+
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
132
|
+
t.add_full_wf_task();
|
|
133
|
+
t.add_workflow_execution_completed();
|
|
134
|
+
|
|
135
|
+
let (k1, k2) = ("foo", "bar");
|
|
136
|
+
|
|
137
|
+
let wff = WorkflowFunction::new(move |ctx: WfContext| async move {
|
|
138
|
+
ctx.upsert_memo([
|
|
139
|
+
(
|
|
140
|
+
String::from(k1),
|
|
141
|
+
Payload {
|
|
142
|
+
data: vec![0x01],
|
|
143
|
+
..Default::default()
|
|
144
|
+
},
|
|
145
|
+
),
|
|
146
|
+
(
|
|
147
|
+
String::from(k2),
|
|
148
|
+
Payload {
|
|
149
|
+
data: vec![0x02],
|
|
150
|
+
..Default::default()
|
|
151
|
+
},
|
|
152
|
+
),
|
|
153
|
+
]);
|
|
154
|
+
Ok(().into())
|
|
155
|
+
});
|
|
156
|
+
let mut wfm = ManagedWFFunc::new(t, wff, vec![]);
|
|
157
|
+
|
|
158
|
+
wfm.get_next_activation().await.unwrap();
|
|
159
|
+
let commands = wfm.get_server_commands().commands;
|
|
160
|
+
assert!(!commands.is_empty());
|
|
161
|
+
let cmd = commands[0].clone();
|
|
162
|
+
assert_eq!(
|
|
163
|
+
cmd.command_type,
|
|
164
|
+
CommandType::ModifyWorkflowProperties as i32
|
|
165
|
+
);
|
|
166
|
+
assert_matches!(
|
|
167
|
+
cmd.attributes.unwrap(),
|
|
168
|
+
Attributes::ModifyWorkflowPropertiesCommandAttributes(msg) => {
|
|
169
|
+
let fields = &msg.upserted_memo.unwrap().fields;
|
|
170
|
+
let payload1 = fields.get(k1).unwrap();
|
|
171
|
+
let payload2 = fields.get(k2).unwrap();
|
|
172
|
+
assert_eq!(payload1.data[0], 0x01);
|
|
173
|
+
assert_eq!(payload2.data[0], 0x02);
|
|
174
|
+
assert_eq!(fields.len(), 2);
|
|
175
|
+
});
|
|
176
|
+
wfm.shutdown().await.unwrap();
|
|
177
|
+
}
|
|
178
|
+
}
|