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,634 @@
|
|
1
|
+
use anyhow::anyhow;
|
2
|
+
use futures::future::join_all;
|
3
|
+
use std::time::Duration;
|
4
|
+
use temporal_client::WorkflowOptions;
|
5
|
+
use temporal_sdk::{
|
6
|
+
interceptors::WorkerInterceptor, ActContext, ActivityCancelledError, CancellableFuture,
|
7
|
+
LocalActivityOptions, WfContext, WorkflowResult,
|
8
|
+
};
|
9
|
+
use temporal_sdk_core_protos::{
|
10
|
+
coresdk::{
|
11
|
+
workflow_commands::ActivityCancellationType,
|
12
|
+
workflow_completion::WorkflowActivationCompletion, AsJsonPayloadExt,
|
13
|
+
},
|
14
|
+
temporal::api::common::v1::RetryPolicy,
|
15
|
+
};
|
16
|
+
use temporal_sdk_core_test_utils::CoreWfStarter;
|
17
|
+
use tokio_util::sync::CancellationToken;
|
18
|
+
|
19
|
+
pub async fn echo(_ctx: ActContext, e: String) -> anyhow::Result<String> {
|
20
|
+
Ok(e)
|
21
|
+
}
|
22
|
+
|
23
|
+
pub async fn one_local_activity_wf(ctx: WfContext) -> WorkflowResult<()> {
|
24
|
+
let initial_workflow_time = ctx.workflow_time().expect("Workflow time should be set");
|
25
|
+
ctx.local_activity(LocalActivityOptions {
|
26
|
+
activity_type: "echo_activity".to_string(),
|
27
|
+
input: "hi!".as_json_payload().expect("serializes fine"),
|
28
|
+
..Default::default()
|
29
|
+
})
|
30
|
+
.await;
|
31
|
+
// Verify LA execution advances the clock
|
32
|
+
assert!(initial_workflow_time < ctx.workflow_time().unwrap());
|
33
|
+
Ok(().into())
|
34
|
+
}
|
35
|
+
|
36
|
+
#[tokio::test]
|
37
|
+
async fn one_local_activity() {
|
38
|
+
let wf_name = "one_local_activity";
|
39
|
+
let mut starter = CoreWfStarter::new(wf_name);
|
40
|
+
let mut worker = starter.worker().await;
|
41
|
+
worker.register_wf(wf_name.to_owned(), one_local_activity_wf);
|
42
|
+
worker.register_activity("echo_activity", echo);
|
43
|
+
|
44
|
+
worker
|
45
|
+
.submit_wf(
|
46
|
+
wf_name.to_owned(),
|
47
|
+
wf_name.to_owned(),
|
48
|
+
vec![],
|
49
|
+
WorkflowOptions::default(),
|
50
|
+
)
|
51
|
+
.await
|
52
|
+
.unwrap();
|
53
|
+
worker.run_until_done().await.unwrap();
|
54
|
+
}
|
55
|
+
|
56
|
+
pub async fn local_act_concurrent_with_timer_wf(ctx: WfContext) -> WorkflowResult<()> {
|
57
|
+
let la = ctx.local_activity(LocalActivityOptions {
|
58
|
+
activity_type: "echo_activity".to_string(),
|
59
|
+
input: "hi!".as_json_payload().expect("serializes fine"),
|
60
|
+
..Default::default()
|
61
|
+
});
|
62
|
+
let timer = ctx.timer(Duration::from_secs(1));
|
63
|
+
tokio::join!(la, timer);
|
64
|
+
Ok(().into())
|
65
|
+
}
|
66
|
+
|
67
|
+
#[tokio::test]
|
68
|
+
async fn local_act_concurrent_with_timer() {
|
69
|
+
let wf_name = "local_act_concurrent_with_timer";
|
70
|
+
let mut starter = CoreWfStarter::new(wf_name);
|
71
|
+
let mut worker = starter.worker().await;
|
72
|
+
worker.register_wf(wf_name.to_owned(), local_act_concurrent_with_timer_wf);
|
73
|
+
worker.register_activity("echo_activity", echo);
|
74
|
+
|
75
|
+
worker
|
76
|
+
.submit_wf(
|
77
|
+
wf_name.to_owned(),
|
78
|
+
wf_name.to_owned(),
|
79
|
+
vec![],
|
80
|
+
WorkflowOptions::default(),
|
81
|
+
)
|
82
|
+
.await
|
83
|
+
.unwrap();
|
84
|
+
worker.run_until_done().await.unwrap();
|
85
|
+
}
|
86
|
+
|
87
|
+
pub async fn local_act_then_timer_then_wait(ctx: WfContext) -> WorkflowResult<()> {
|
88
|
+
let la = ctx.local_activity(LocalActivityOptions {
|
89
|
+
activity_type: "echo_activity".to_string(),
|
90
|
+
input: "hi!".as_json_payload().expect("serializes fine"),
|
91
|
+
..Default::default()
|
92
|
+
});
|
93
|
+
ctx.timer(Duration::from_secs(1)).await;
|
94
|
+
let res = la.await;
|
95
|
+
assert!(res.completed_ok());
|
96
|
+
Ok(().into())
|
97
|
+
}
|
98
|
+
|
99
|
+
#[tokio::test]
|
100
|
+
async fn local_act_then_timer_then_wait_result() {
|
101
|
+
let wf_name = "local_act_then_timer_then_wait_result";
|
102
|
+
let mut starter = CoreWfStarter::new(wf_name);
|
103
|
+
let mut worker = starter.worker().await;
|
104
|
+
worker.register_wf(wf_name.to_owned(), local_act_then_timer_then_wait);
|
105
|
+
worker.register_activity("echo_activity", echo);
|
106
|
+
|
107
|
+
worker
|
108
|
+
.submit_wf(
|
109
|
+
wf_name.to_owned(),
|
110
|
+
wf_name.to_owned(),
|
111
|
+
vec![],
|
112
|
+
WorkflowOptions::default(),
|
113
|
+
)
|
114
|
+
.await
|
115
|
+
.unwrap();
|
116
|
+
worker.run_until_done().await.unwrap();
|
117
|
+
}
|
118
|
+
|
119
|
+
#[tokio::test]
|
120
|
+
async fn long_running_local_act_with_timer() {
|
121
|
+
let wf_name = "long_running_local_act_with_timer";
|
122
|
+
let mut starter = CoreWfStarter::new(wf_name);
|
123
|
+
starter.wft_timeout(Duration::from_secs(1));
|
124
|
+
let mut worker = starter.worker().await;
|
125
|
+
worker.register_wf(wf_name.to_owned(), local_act_then_timer_then_wait);
|
126
|
+
worker.register_activity("echo_activity", |_ctx: ActContext, str: String| async {
|
127
|
+
tokio::time::sleep(Duration::from_secs(4)).await;
|
128
|
+
Ok(str)
|
129
|
+
});
|
130
|
+
|
131
|
+
worker
|
132
|
+
.submit_wf(
|
133
|
+
wf_name.to_owned(),
|
134
|
+
wf_name.to_owned(),
|
135
|
+
vec![],
|
136
|
+
WorkflowOptions::default(),
|
137
|
+
)
|
138
|
+
.await
|
139
|
+
.unwrap();
|
140
|
+
worker.run_until_done().await.unwrap();
|
141
|
+
}
|
142
|
+
|
143
|
+
pub async fn local_act_fanout_wf(ctx: WfContext) -> WorkflowResult<()> {
|
144
|
+
let las: Vec<_> = (1..=50)
|
145
|
+
.map(|i| {
|
146
|
+
ctx.local_activity(LocalActivityOptions {
|
147
|
+
activity_type: "echo_activity".to_string(),
|
148
|
+
input: format!("Hi {}", i)
|
149
|
+
.as_json_payload()
|
150
|
+
.expect("serializes fine"),
|
151
|
+
..Default::default()
|
152
|
+
})
|
153
|
+
})
|
154
|
+
.collect();
|
155
|
+
ctx.timer(Duration::from_secs(1)).await;
|
156
|
+
join_all(las).await;
|
157
|
+
Ok(().into())
|
158
|
+
}
|
159
|
+
|
160
|
+
#[tokio::test]
|
161
|
+
async fn local_act_fanout() {
|
162
|
+
let wf_name = "local_act_fanout";
|
163
|
+
let mut starter = CoreWfStarter::new(wf_name);
|
164
|
+
starter.max_local_at(1);
|
165
|
+
let mut worker = starter.worker().await;
|
166
|
+
worker.register_wf(wf_name.to_owned(), local_act_fanout_wf);
|
167
|
+
worker.register_activity("echo_activity", echo);
|
168
|
+
|
169
|
+
worker
|
170
|
+
.submit_wf(
|
171
|
+
wf_name.to_owned(),
|
172
|
+
wf_name.to_owned(),
|
173
|
+
vec![],
|
174
|
+
WorkflowOptions::default(),
|
175
|
+
)
|
176
|
+
.await
|
177
|
+
.unwrap();
|
178
|
+
worker.run_until_done().await.unwrap();
|
179
|
+
}
|
180
|
+
|
181
|
+
#[tokio::test]
|
182
|
+
async fn local_act_retry_timer_backoff() {
|
183
|
+
let wf_name = "local_act_retry_timer_backoff";
|
184
|
+
let mut starter = CoreWfStarter::new(wf_name);
|
185
|
+
let mut worker = starter.worker().await;
|
186
|
+
worker.register_wf(wf_name.to_owned(), |ctx: WfContext| async move {
|
187
|
+
let res = ctx
|
188
|
+
.local_activity(LocalActivityOptions {
|
189
|
+
activity_type: "echo".to_string(),
|
190
|
+
input: "hi".as_json_payload().expect("serializes fine"),
|
191
|
+
retry_policy: RetryPolicy {
|
192
|
+
initial_interval: Some(prost_dur!(from_micros(15))),
|
193
|
+
// We want two local backoffs that are short. Third backoff will use timer
|
194
|
+
backoff_coefficient: 1_000.,
|
195
|
+
maximum_interval: Some(prost_dur!(from_millis(1500))),
|
196
|
+
maximum_attempts: 4,
|
197
|
+
non_retryable_error_types: vec![],
|
198
|
+
},
|
199
|
+
timer_backoff_threshold: Some(Duration::from_secs(1)),
|
200
|
+
..Default::default()
|
201
|
+
})
|
202
|
+
.await;
|
203
|
+
assert!(res.failed());
|
204
|
+
Ok(().into())
|
205
|
+
});
|
206
|
+
worker.register_activity("echo", |_: ActContext, _: String| async {
|
207
|
+
Result::<(), _>::Err(anyhow!("Oh no I failed!"))
|
208
|
+
});
|
209
|
+
|
210
|
+
let run_id = worker
|
211
|
+
.submit_wf(
|
212
|
+
wf_name.to_owned(),
|
213
|
+
wf_name.to_owned(),
|
214
|
+
vec![],
|
215
|
+
WorkflowOptions::default(),
|
216
|
+
)
|
217
|
+
.await
|
218
|
+
.unwrap();
|
219
|
+
worker.run_until_done().await.unwrap();
|
220
|
+
starter
|
221
|
+
.fetch_history_and_replay(wf_name, run_id, worker.inner_mut())
|
222
|
+
.await
|
223
|
+
.unwrap();
|
224
|
+
}
|
225
|
+
|
226
|
+
#[rstest::rstest]
|
227
|
+
#[case::wait(ActivityCancellationType::WaitCancellationCompleted)]
|
228
|
+
#[case::try_cancel(ActivityCancellationType::TryCancel)]
|
229
|
+
#[case::abandon(ActivityCancellationType::Abandon)]
|
230
|
+
#[tokio::test]
|
231
|
+
async fn cancel_immediate(#[case] cancel_type: ActivityCancellationType) {
|
232
|
+
let wf_name = format!("cancel_immediate_{:?}", cancel_type);
|
233
|
+
let mut starter = CoreWfStarter::new(&wf_name);
|
234
|
+
let mut worker = starter.worker().await;
|
235
|
+
worker.register_wf(&wf_name, move |ctx: WfContext| async move {
|
236
|
+
let la = ctx.local_activity(LocalActivityOptions {
|
237
|
+
activity_type: "echo".to_string(),
|
238
|
+
input: "hi".as_json_payload().expect("serializes fine"),
|
239
|
+
cancel_type,
|
240
|
+
..Default::default()
|
241
|
+
});
|
242
|
+
la.cancel(&ctx);
|
243
|
+
let resolution = la.await;
|
244
|
+
assert!(resolution.cancelled());
|
245
|
+
Ok(().into())
|
246
|
+
});
|
247
|
+
|
248
|
+
// If we don't use this, we'd hang on shutdown for abandon cancel modes.
|
249
|
+
let manual_cancel = CancellationToken::new();
|
250
|
+
let manual_cancel_act = manual_cancel.clone();
|
251
|
+
|
252
|
+
worker.register_activity("echo", move |ctx: ActContext, _: String| {
|
253
|
+
let manual_cancel_act = manual_cancel_act.clone();
|
254
|
+
async move {
|
255
|
+
tokio::select! {
|
256
|
+
_ = tokio::time::sleep(Duration::from_secs(10)) => {},
|
257
|
+
_ = ctx.cancelled() => {
|
258
|
+
return Err(anyhow!(ActivityCancelledError::default()))
|
259
|
+
}
|
260
|
+
_ = manual_cancel_act.cancelled() => {}
|
261
|
+
}
|
262
|
+
Ok(())
|
263
|
+
}
|
264
|
+
});
|
265
|
+
|
266
|
+
worker
|
267
|
+
.submit_wf(
|
268
|
+
wf_name.to_owned(),
|
269
|
+
wf_name.to_owned(),
|
270
|
+
vec![],
|
271
|
+
WorkflowOptions::default(),
|
272
|
+
)
|
273
|
+
.await
|
274
|
+
.unwrap();
|
275
|
+
worker
|
276
|
+
.run_until_done_intercepted(Some(LACancellerInterceptor {
|
277
|
+
token: manual_cancel,
|
278
|
+
}))
|
279
|
+
.await
|
280
|
+
.unwrap();
|
281
|
+
}
|
282
|
+
|
283
|
+
struct LACancellerInterceptor {
|
284
|
+
token: CancellationToken,
|
285
|
+
}
|
286
|
+
#[async_trait::async_trait(?Send)]
|
287
|
+
impl WorkerInterceptor for LACancellerInterceptor {
|
288
|
+
async fn on_workflow_activation_completion(&self, _: &WorkflowActivationCompletion) {}
|
289
|
+
fn on_shutdown(&self, _: &temporal_sdk::Worker) {
|
290
|
+
self.token.cancel()
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
#[rstest::rstest]
|
295
|
+
#[case::while_running(None)]
|
296
|
+
#[case::while_backing_off(Some(Duration::from_millis(1500)))]
|
297
|
+
#[case::while_backing_off_locally(Some(Duration::from_millis(150)))]
|
298
|
+
#[tokio::test]
|
299
|
+
async fn cancel_after_act_starts(
|
300
|
+
#[case] cancel_on_backoff: Option<Duration>,
|
301
|
+
#[values(
|
302
|
+
ActivityCancellationType::WaitCancellationCompleted,
|
303
|
+
ActivityCancellationType::TryCancel,
|
304
|
+
ActivityCancellationType::Abandon
|
305
|
+
)]
|
306
|
+
cancel_type: ActivityCancellationType,
|
307
|
+
) {
|
308
|
+
let wf_name = format!(
|
309
|
+
"cancel_after_act_starts_timer_{:?}_{:?}",
|
310
|
+
cancel_on_backoff, cancel_type
|
311
|
+
);
|
312
|
+
let mut starter = CoreWfStarter::new(&wf_name);
|
313
|
+
starter.wft_timeout(Duration::from_secs(1));
|
314
|
+
let mut worker = starter.worker().await;
|
315
|
+
let bo_dur = cancel_on_backoff.unwrap_or_else(|| Duration::from_secs(1));
|
316
|
+
worker.register_wf(&wf_name, move |ctx: WfContext| async move {
|
317
|
+
let la = ctx.local_activity(LocalActivityOptions {
|
318
|
+
activity_type: "echo".to_string(),
|
319
|
+
input: "hi".as_json_payload().expect("serializes fine"),
|
320
|
+
retry_policy: RetryPolicy {
|
321
|
+
initial_interval: Some(bo_dur.try_into().unwrap()),
|
322
|
+
backoff_coefficient: 1.,
|
323
|
+
maximum_interval: Some(bo_dur.try_into().unwrap()),
|
324
|
+
// Retry forever until cancelled
|
325
|
+
..Default::default()
|
326
|
+
},
|
327
|
+
timer_backoff_threshold: Some(Duration::from_secs(1)),
|
328
|
+
cancel_type,
|
329
|
+
..Default::default()
|
330
|
+
});
|
331
|
+
ctx.timer(Duration::from_secs(1)).await;
|
332
|
+
// Note that this cancel can't go through for *two* WF tasks, because we do a full heartbeat
|
333
|
+
// before the timer (LA hasn't resolved), and then the timer fired event won't appear in
|
334
|
+
// history until *after* the next WFT because we force generated it when we sent the timer
|
335
|
+
// command.
|
336
|
+
la.cancel(&ctx);
|
337
|
+
// This extra timer is here to ensure the presence of another WF task doesn't mess up
|
338
|
+
// resolving the LA with cancel on replay
|
339
|
+
ctx.timer(Duration::from_secs(1)).await;
|
340
|
+
let resolution = la.await;
|
341
|
+
assert!(resolution.cancelled());
|
342
|
+
Ok(().into())
|
343
|
+
});
|
344
|
+
|
345
|
+
// If we don't use this, we'd hang on shutdown for abandon cancel modes.
|
346
|
+
let manual_cancel = CancellationToken::new();
|
347
|
+
let manual_cancel_act = manual_cancel.clone();
|
348
|
+
|
349
|
+
worker.register_activity("echo", move |ctx: ActContext, _: String| {
|
350
|
+
let manual_cancel_act = manual_cancel_act.clone();
|
351
|
+
async move {
|
352
|
+
if cancel_on_backoff.is_some() {
|
353
|
+
if ctx.is_cancelled() {
|
354
|
+
return Err(anyhow!(ActivityCancelledError::default()));
|
355
|
+
}
|
356
|
+
// Just fail constantly so we get stuck on the backoff timer
|
357
|
+
return Err(anyhow!("Oh no I failed!"));
|
358
|
+
} else {
|
359
|
+
tokio::select! {
|
360
|
+
_ = tokio::time::sleep(Duration::from_secs(100)) => {},
|
361
|
+
_ = ctx.cancelled() => {
|
362
|
+
return Err(anyhow!(ActivityCancelledError::default()))
|
363
|
+
}
|
364
|
+
_ = manual_cancel_act.cancelled() => {
|
365
|
+
return Ok(())
|
366
|
+
}
|
367
|
+
}
|
368
|
+
}
|
369
|
+
Err(anyhow!("Oh no I failed!"))
|
370
|
+
}
|
371
|
+
});
|
372
|
+
|
373
|
+
worker
|
374
|
+
.submit_wf(
|
375
|
+
wf_name.to_owned(),
|
376
|
+
wf_name.to_owned(),
|
377
|
+
vec![],
|
378
|
+
WorkflowOptions::default(),
|
379
|
+
)
|
380
|
+
.await
|
381
|
+
.unwrap();
|
382
|
+
worker
|
383
|
+
.run_until_done_intercepted(Some(LACancellerInterceptor {
|
384
|
+
token: manual_cancel,
|
385
|
+
}))
|
386
|
+
.await
|
387
|
+
.unwrap();
|
388
|
+
}
|
389
|
+
|
390
|
+
#[rstest::rstest]
|
391
|
+
#[case::schedule(true)]
|
392
|
+
#[case::start(false)]
|
393
|
+
#[tokio::test]
|
394
|
+
async fn x_to_close_timeout(#[case] is_schedule: bool) {
|
395
|
+
let wf_name = format!(
|
396
|
+
"{}_to_close_timeout",
|
397
|
+
if is_schedule { "schedule" } else { "start" }
|
398
|
+
);
|
399
|
+
let mut starter = CoreWfStarter::new(&wf_name);
|
400
|
+
let mut worker = starter.worker().await;
|
401
|
+
let (sched, start) = if is_schedule {
|
402
|
+
(Some(Duration::from_secs(2)), None)
|
403
|
+
} else {
|
404
|
+
(None, Some(Duration::from_secs(2)))
|
405
|
+
};
|
406
|
+
|
407
|
+
worker.register_wf(wf_name.to_owned(), move |ctx: WfContext| async move {
|
408
|
+
let res = ctx
|
409
|
+
.local_activity(LocalActivityOptions {
|
410
|
+
activity_type: "echo".to_string(),
|
411
|
+
input: "hi".as_json_payload().expect("serializes fine"),
|
412
|
+
retry_policy: RetryPolicy {
|
413
|
+
initial_interval: Some(prost_dur!(from_micros(15))),
|
414
|
+
backoff_coefficient: 1_000.,
|
415
|
+
maximum_interval: Some(prost_dur!(from_millis(1500))),
|
416
|
+
maximum_attempts: 4,
|
417
|
+
non_retryable_error_types: vec![],
|
418
|
+
},
|
419
|
+
timer_backoff_threshold: Some(Duration::from_secs(1)),
|
420
|
+
schedule_to_close_timeout: sched,
|
421
|
+
start_to_close_timeout: start,
|
422
|
+
..Default::default()
|
423
|
+
})
|
424
|
+
.await;
|
425
|
+
assert!(res.timed_out());
|
426
|
+
Ok(().into())
|
427
|
+
});
|
428
|
+
worker.register_activity("echo", |ctx: ActContext, _: String| async move {
|
429
|
+
tokio::select! {
|
430
|
+
_ = tokio::time::sleep(Duration::from_secs(100)) => {},
|
431
|
+
_ = ctx.cancelled() => {
|
432
|
+
return Err(anyhow!(ActivityCancelledError::default()))
|
433
|
+
}
|
434
|
+
};
|
435
|
+
Ok(())
|
436
|
+
});
|
437
|
+
|
438
|
+
worker
|
439
|
+
.submit_wf(
|
440
|
+
wf_name.to_owned(),
|
441
|
+
wf_name.to_owned(),
|
442
|
+
vec![],
|
443
|
+
WorkflowOptions::default(),
|
444
|
+
)
|
445
|
+
.await
|
446
|
+
.unwrap();
|
447
|
+
worker.run_until_done().await.unwrap();
|
448
|
+
}
|
449
|
+
|
450
|
+
#[rstest::rstest]
|
451
|
+
#[case::cached(true)]
|
452
|
+
#[case::not_cached(false)]
|
453
|
+
#[tokio::test]
|
454
|
+
async fn schedule_to_close_timeout_across_timer_backoff(#[case] cached: bool) {
|
455
|
+
let wf_name = format!(
|
456
|
+
"schedule_to_close_timeout_across_timer_backoff_{}",
|
457
|
+
if cached { "cached" } else { "not_cached" }
|
458
|
+
);
|
459
|
+
let mut starter = CoreWfStarter::new(&wf_name);
|
460
|
+
if !cached {
|
461
|
+
starter.max_cached_workflows(0);
|
462
|
+
}
|
463
|
+
let mut worker = starter.worker().await;
|
464
|
+
worker.register_wf(wf_name.to_owned(), |ctx: WfContext| async move {
|
465
|
+
let res = ctx
|
466
|
+
.local_activity(LocalActivityOptions {
|
467
|
+
activity_type: "echo".to_string(),
|
468
|
+
input: "hi".as_json_payload().expect("serializes fine"),
|
469
|
+
retry_policy: RetryPolicy {
|
470
|
+
initial_interval: Some(prost_dur!(from_micros(15))),
|
471
|
+
backoff_coefficient: 1_000.,
|
472
|
+
maximum_interval: Some(prost_dur!(from_millis(1500))),
|
473
|
+
maximum_attempts: 40,
|
474
|
+
non_retryable_error_types: vec![],
|
475
|
+
},
|
476
|
+
timer_backoff_threshold: Some(Duration::from_secs(1)),
|
477
|
+
schedule_to_close_timeout: Some(Duration::from_secs(3)),
|
478
|
+
..Default::default()
|
479
|
+
})
|
480
|
+
.await;
|
481
|
+
assert!(res.timed_out());
|
482
|
+
Ok(().into())
|
483
|
+
});
|
484
|
+
worker.register_activity("echo", |_: ActContext, _: String| async {
|
485
|
+
Result::<(), _>::Err(anyhow!("Oh no I failed!"))
|
486
|
+
});
|
487
|
+
|
488
|
+
worker
|
489
|
+
.submit_wf(
|
490
|
+
wf_name.to_owned(),
|
491
|
+
wf_name.to_owned(),
|
492
|
+
vec![],
|
493
|
+
WorkflowOptions::default(),
|
494
|
+
)
|
495
|
+
.await
|
496
|
+
.unwrap();
|
497
|
+
worker.run_until_done().await.unwrap();
|
498
|
+
}
|
499
|
+
|
500
|
+
#[rstest::rstest]
|
501
|
+
#[tokio::test]
|
502
|
+
async fn eviction_wont_make_local_act_get_dropped(#[values(true, false)] short_wft_timeout: bool) {
|
503
|
+
let wf_name = format!(
|
504
|
+
"eviction_wont_make_local_act_get_dropped_{}",
|
505
|
+
short_wft_timeout
|
506
|
+
);
|
507
|
+
let mut starter = CoreWfStarter::new(&wf_name);
|
508
|
+
starter.max_cached_workflows(0);
|
509
|
+
let mut worker = starter.worker().await;
|
510
|
+
worker.register_wf(wf_name.to_owned(), local_act_then_timer_then_wait);
|
511
|
+
worker.register_activity("echo_activity", |_ctx: ActContext, str: String| async {
|
512
|
+
tokio::time::sleep(Duration::from_secs(4)).await;
|
513
|
+
Ok(str)
|
514
|
+
});
|
515
|
+
|
516
|
+
let opts = if short_wft_timeout {
|
517
|
+
WorkflowOptions {
|
518
|
+
task_timeout: Some(Duration::from_secs(1)),
|
519
|
+
..Default::default()
|
520
|
+
}
|
521
|
+
} else {
|
522
|
+
Default::default()
|
523
|
+
};
|
524
|
+
worker
|
525
|
+
.submit_wf(wf_name.to_owned(), wf_name.to_owned(), vec![], opts)
|
526
|
+
.await
|
527
|
+
.unwrap();
|
528
|
+
worker.run_until_done().await.unwrap();
|
529
|
+
}
|
530
|
+
|
531
|
+
#[tokio::test]
|
532
|
+
async fn timer_backoff_concurrent_with_non_timer_backoff() {
|
533
|
+
let wf_name = "timer_backoff_concurrent_with_non_timer_backoff";
|
534
|
+
let mut starter = CoreWfStarter::new(wf_name);
|
535
|
+
let mut worker = starter.worker().await;
|
536
|
+
worker.register_wf(wf_name.to_owned(), |ctx: WfContext| async move {
|
537
|
+
let r1 = ctx.local_activity(LocalActivityOptions {
|
538
|
+
activity_type: "echo".to_string(),
|
539
|
+
input: "hi".as_json_payload().expect("serializes fine"),
|
540
|
+
retry_policy: RetryPolicy {
|
541
|
+
initial_interval: Some(prost_dur!(from_micros(15))),
|
542
|
+
backoff_coefficient: 1_000.,
|
543
|
+
maximum_interval: Some(prost_dur!(from_millis(1500))),
|
544
|
+
maximum_attempts: 4,
|
545
|
+
non_retryable_error_types: vec![],
|
546
|
+
},
|
547
|
+
timer_backoff_threshold: Some(Duration::from_secs(1)),
|
548
|
+
..Default::default()
|
549
|
+
});
|
550
|
+
let r2 = ctx.local_activity(LocalActivityOptions {
|
551
|
+
activity_type: "echo".to_string(),
|
552
|
+
input: "hi".as_json_payload().expect("serializes fine"),
|
553
|
+
retry_policy: RetryPolicy {
|
554
|
+
initial_interval: Some(prost_dur!(from_millis(15))),
|
555
|
+
backoff_coefficient: 10.,
|
556
|
+
maximum_interval: Some(prost_dur!(from_millis(1500))),
|
557
|
+
maximum_attempts: 4,
|
558
|
+
non_retryable_error_types: vec![],
|
559
|
+
},
|
560
|
+
timer_backoff_threshold: Some(Duration::from_secs(10)),
|
561
|
+
..Default::default()
|
562
|
+
});
|
563
|
+
let (r1, r2) = tokio::join!(r1, r2);
|
564
|
+
assert!(r1.failed());
|
565
|
+
assert!(r2.failed());
|
566
|
+
Ok(().into())
|
567
|
+
});
|
568
|
+
worker.register_activity("echo", |_: ActContext, _: String| async {
|
569
|
+
Result::<(), _>::Err(anyhow!("Oh no I failed!"))
|
570
|
+
});
|
571
|
+
|
572
|
+
worker
|
573
|
+
.submit_wf(
|
574
|
+
wf_name.to_owned(),
|
575
|
+
wf_name.to_owned(),
|
576
|
+
vec![],
|
577
|
+
WorkflowOptions::default(),
|
578
|
+
)
|
579
|
+
.await
|
580
|
+
.unwrap();
|
581
|
+
worker.run_until_done().await.unwrap();
|
582
|
+
}
|
583
|
+
|
584
|
+
#[tokio::test]
|
585
|
+
async fn repro_nondeterminism_with_timer_bug() {
|
586
|
+
let wf_name = "repro_nondeterminism_with_timer_bug";
|
587
|
+
let mut starter = CoreWfStarter::new(wf_name);
|
588
|
+
let mut worker = starter.worker().await;
|
589
|
+
|
590
|
+
worker.register_wf(wf_name.to_owned(), |ctx: WfContext| async move {
|
591
|
+
let t1 = ctx.timer(Duration::from_secs(30));
|
592
|
+
let r1 = ctx.local_activity(LocalActivityOptions {
|
593
|
+
activity_type: "delay".to_string(),
|
594
|
+
input: "hi".as_json_payload().expect("serializes fine"),
|
595
|
+
retry_policy: RetryPolicy {
|
596
|
+
initial_interval: Some(prost_dur!(from_micros(15))),
|
597
|
+
backoff_coefficient: 1_000.,
|
598
|
+
maximum_interval: Some(prost_dur!(from_millis(1500))),
|
599
|
+
maximum_attempts: 4,
|
600
|
+
non_retryable_error_types: vec![],
|
601
|
+
},
|
602
|
+
timer_backoff_threshold: Some(Duration::from_secs(1)),
|
603
|
+
..Default::default()
|
604
|
+
});
|
605
|
+
tokio::pin!(t1);
|
606
|
+
tokio::select! {
|
607
|
+
_ = &mut t1 => {},
|
608
|
+
_ = r1 => {
|
609
|
+
t1.cancel(&ctx);
|
610
|
+
},
|
611
|
+
};
|
612
|
+
ctx.timer(Duration::from_secs(1)).await;
|
613
|
+
Ok(().into())
|
614
|
+
});
|
615
|
+
worker.register_activity("delay", |_: ActContext, _: String| async {
|
616
|
+
tokio::time::sleep(Duration::from_secs(2)).await;
|
617
|
+
Ok(())
|
618
|
+
});
|
619
|
+
|
620
|
+
let run_id = worker
|
621
|
+
.submit_wf(
|
622
|
+
wf_name.to_owned(),
|
623
|
+
wf_name.to_owned(),
|
624
|
+
vec![],
|
625
|
+
WorkflowOptions::default(),
|
626
|
+
)
|
627
|
+
.await
|
628
|
+
.unwrap();
|
629
|
+
worker.run_until_done().await.unwrap();
|
630
|
+
starter
|
631
|
+
.fetch_history_and_replay(wf_name, run_id, worker.inner_mut())
|
632
|
+
.await
|
633
|
+
.unwrap();
|
634
|
+
}
|