temporalio 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +180 -7
- data/bridge/Cargo.lock +208 -76
- data/bridge/Cargo.toml +5 -2
- data/bridge/sdk-core/Cargo.toml +1 -1
- data/bridge/sdk-core/README.md +20 -10
- data/bridge/sdk-core/client/Cargo.toml +1 -1
- data/bridge/sdk-core/client/src/lib.rs +227 -59
- data/bridge/sdk-core/client/src/metrics.rs +17 -8
- data/bridge/sdk-core/client/src/raw.rs +13 -12
- data/bridge/sdk-core/client/src/retry.rs +132 -43
- data/bridge/sdk-core/core/Cargo.toml +28 -15
- data/bridge/sdk-core/core/benches/workflow_replay.rs +13 -10
- data/bridge/sdk-core/core/src/abstractions.rs +225 -36
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +217 -79
- data/bridge/sdk-core/core/src/core_tests/determinism.rs +165 -2
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +565 -34
- data/bridge/sdk-core/core/src/core_tests/queries.rs +247 -90
- data/bridge/sdk-core/core/src/core_tests/workers.rs +3 -5
- data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +1 -1
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +430 -67
- data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +106 -12
- data/bridge/sdk-core/core/src/internal_flags.rs +136 -0
- data/bridge/sdk-core/core/src/lib.rs +148 -34
- data/bridge/sdk-core/core/src/protosext/mod.rs +1 -1
- data/bridge/sdk-core/core/src/replay/mod.rs +185 -41
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +190 -0
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +219 -140
- data/bridge/sdk-core/core/src/telemetry/mod.rs +326 -315
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +20 -14
- data/bridge/sdk-core/core/src/test_help/mod.rs +85 -21
- data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +112 -156
- data/bridge/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +89 -0
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +364 -128
- data/bridge/sdk-core/core/src/worker/activities.rs +263 -170
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +23 -3
- data/bridge/sdk-core/core/src/worker/client.rs +48 -6
- data/bridge/sdk-core/core/src/worker/mod.rs +186 -75
- data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +1 -3
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +13 -24
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +879 -226
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +101 -48
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +8 -12
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +90 -32
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +7 -10
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +160 -83
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +36 -54
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +179 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +104 -157
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +8 -12
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +9 -13
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +10 -4
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +14 -11
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +6 -17
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +395 -299
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +12 -20
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +33 -18
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +1032 -374
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +525 -392
- data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +40 -57
- data/bridge/sdk-core/core/src/worker/workflow/wft_extraction.rs +125 -0
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +3 -6
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +117 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +24 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +456 -681
- data/bridge/sdk-core/core-api/Cargo.toml +6 -4
- data/bridge/sdk-core/core-api/src/errors.rs +1 -34
- data/bridge/sdk-core/core-api/src/lib.rs +7 -45
- data/bridge/sdk-core/core-api/src/telemetry.rs +141 -0
- data/bridge/sdk-core/core-api/src/worker.rs +27 -1
- data/bridge/sdk-core/etc/deps.svg +115 -140
- data/bridge/sdk-core/etc/regen-depgraph.sh +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +18 -15
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +8 -3
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-16_history.bin +0 -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/protos/api_upstream/buf.yaml +0 -3
- 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/{temporal/api/enums/v1/cluster.proto → build/tools.go} +7 -18
- data/bridge/sdk-core/protos/api_upstream/go.mod +6 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +12 -9
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +15 -26
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +13 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +4 -9
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +10 -8
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +28 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +24 -19
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +62 -26
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +4 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +24 -61
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +2 -21
- data/bridge/sdk-core/protos/api_upstream/temporal/api/protocol/v1/message.proto +57 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +110 -31
- data/bridge/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +63 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +4 -4
- data/bridge/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +71 -6
- data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +111 -36
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +19 -5
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +9 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +9 -1
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +6 -0
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +2 -2
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +2 -2
- data/bridge/sdk-core/sdk/Cargo.toml +4 -3
- data/bridge/sdk-core/sdk/src/interceptors.rs +36 -3
- data/bridge/sdk-core/sdk/src/lib.rs +94 -25
- data/bridge/sdk-core/sdk/src/workflow_context.rs +13 -2
- data/bridge/sdk-core/sdk/src/workflow_future.rs +10 -13
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +5 -2
- data/bridge/sdk-core/sdk-core-protos/build.rs +36 -2
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +164 -104
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +27 -23
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +252 -74
- data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +12 -2
- data/bridge/sdk-core/test-utils/Cargo.toml +4 -1
- data/bridge/sdk-core/test-utils/src/canned_histories.rs +106 -296
- data/bridge/sdk-core/test-utils/src/histfetch.rs +1 -1
- data/bridge/sdk-core/test-utils/src/lib.rs +161 -50
- data/bridge/sdk-core/test-utils/src/wf_input_saver.rs +50 -0
- data/bridge/sdk-core/test-utils/src/workflows.rs +29 -0
- data/bridge/sdk-core/tests/fuzzy_workflow.rs +130 -0
- data/bridge/sdk-core/tests/{load_tests.rs → heavy_tests.rs} +125 -51
- data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +25 -3
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +10 -5
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +239 -0
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +4 -60
- data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +5 -128
- data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +83 -25
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +93 -69
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +6 -13
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +6 -2
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -10
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +151 -116
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +54 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +7 -28
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +115 -24
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +18 -14
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +6 -20
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -21
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +6 -4
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +27 -18
- data/bridge/sdk-core/tests/main.rs +8 -16
- data/bridge/sdk-core/tests/runner.rs +75 -36
- data/bridge/sdk-core/tests/wf_input_replay.rs +32 -0
- data/bridge/src/connection.rs +117 -82
- data/bridge/src/lib.rs +356 -42
- data/bridge/src/runtime.rs +10 -3
- data/bridge/src/test_server.rs +153 -0
- data/bridge/src/worker.rs +133 -9
- data/lib/gen/temporal/api/batch/v1/message_pb.rb +8 -6
- data/lib/gen/temporal/api/command/v1/message_pb.rb +10 -16
- data/lib/gen/temporal/api/common/v1/message_pb.rb +5 -1
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +3 -3
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +5 -4
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +9 -1
- data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/query_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/reset_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +7 -10
- data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +1 -1
- data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/failure/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/filter/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/history/v1/message_pb.rb +34 -25
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +2 -1
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +14 -51
- data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/api/protocol/v1/message_pb.rb +30 -0
- data/lib/gen/temporal/api/query/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/replication/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/schedule/v1/message_pb.rb +22 -1
- data/lib/gen/temporal/api/sdk/v1/task_complete_metadata_pb.rb +23 -0
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +2 -2
- data/lib/gen/temporal/api/testservice/v1/request_response_pb.rb +49 -0
- data/lib/gen/temporal/api/testservice/v1/service_pb.rb +21 -0
- data/lib/gen/temporal/api/update/v1/message_pb.rb +49 -3
- data/lib/gen/temporal/api/version/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +2 -1
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +47 -20
- data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +13 -9
- data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +10 -6
- data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +13 -9
- data/lib/gen/temporal/sdk/core/common/common_pb.rb +7 -3
- data/lib/gen/temporal/sdk/core/core_interface_pb.rb +9 -3
- data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +7 -3
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +28 -21
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +32 -24
- data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +12 -5
- data/lib/temporalio/activity/context.rb +102 -0
- data/lib/temporalio/activity/info.rb +67 -0
- data/lib/temporalio/activity.rb +85 -0
- data/lib/temporalio/bridge/connect_options.rb +15 -0
- data/lib/temporalio/bridge/error.rb +8 -0
- data/lib/temporalio/bridge/retry_config.rb +24 -0
- data/lib/temporalio/bridge/tls_options.rb +19 -0
- data/lib/temporalio/bridge.rb +14 -0
- data/lib/{temporal → temporalio}/client/implementation.rb +57 -56
- data/lib/{temporal → temporalio}/client/workflow_handle.rb +35 -35
- data/lib/{temporal → temporalio}/client.rb +19 -32
- data/lib/temporalio/connection/retry_config.rb +44 -0
- data/lib/temporalio/connection/service.rb +20 -0
- data/lib/temporalio/connection/test_service.rb +92 -0
- data/lib/temporalio/connection/tls_options.rb +51 -0
- data/lib/temporalio/connection/workflow_service.rb +731 -0
- data/lib/temporalio/connection.rb +86 -0
- data/lib/{temporal → temporalio}/data_converter.rb +76 -35
- data/lib/{temporal → temporalio}/error/failure.rb +6 -6
- data/lib/{temporal → temporalio}/error/workflow_failure.rb +4 -2
- data/lib/{temporal → temporalio}/errors.rb +19 -1
- data/lib/{temporal → temporalio}/failure_converter/base.rb +5 -5
- data/lib/{temporal → temporalio}/failure_converter/basic.rb +58 -52
- data/lib/temporalio/failure_converter.rb +7 -0
- data/lib/temporalio/interceptor/activity_inbound.rb +22 -0
- data/lib/temporalio/interceptor/activity_outbound.rb +24 -0
- data/lib/{temporal → temporalio}/interceptor/chain.rb +7 -6
- data/lib/{temporal → temporalio}/interceptor/client.rb +27 -2
- data/lib/temporalio/interceptor.rb +22 -0
- data/lib/{temporal → temporalio}/payload_codec/base.rb +5 -5
- data/lib/{temporal → temporalio}/payload_converter/base.rb +3 -3
- data/lib/{temporal → temporalio}/payload_converter/bytes.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/composite.rb +7 -5
- data/lib/{temporal → temporalio}/payload_converter/encoding_base.rb +4 -4
- data/lib/{temporal → temporalio}/payload_converter/json.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/nil.rb +4 -3
- data/lib/temporalio/payload_converter.rb +14 -0
- data/lib/{temporal → temporalio}/retry_policy.rb +17 -7
- data/lib/{temporal → temporalio}/retry_state.rb +1 -1
- data/lib/temporalio/runtime.rb +25 -0
- data/lib/temporalio/testing/time_skipping_handle.rb +32 -0
- data/lib/temporalio/testing/time_skipping_interceptor.rb +23 -0
- data/lib/temporalio/testing/workflow_environment.rb +112 -0
- data/lib/temporalio/testing.rb +175 -0
- data/lib/{temporal → temporalio}/timeout_type.rb +2 -2
- data/lib/temporalio/version.rb +3 -0
- data/lib/temporalio/worker/activity_runner.rb +114 -0
- data/lib/temporalio/worker/activity_worker.rb +164 -0
- data/lib/temporalio/worker/reactor.rb +46 -0
- data/lib/temporalio/worker/runner.rb +63 -0
- data/lib/temporalio/worker/sync_worker.rb +124 -0
- data/lib/temporalio/worker/thread_pool_executor.rb +51 -0
- data/lib/temporalio/worker.rb +204 -0
- data/lib/temporalio/workflow/async.rb +46 -0
- data/lib/{temporal → temporalio}/workflow/execution_info.rb +4 -4
- data/lib/{temporal → temporalio}/workflow/execution_status.rb +1 -1
- data/lib/temporalio/workflow/future.rb +138 -0
- data/lib/{temporal → temporalio}/workflow/id_reuse_policy.rb +6 -6
- data/lib/temporalio/workflow/info.rb +76 -0
- data/lib/{temporal → temporalio}/workflow/query_reject_condition.rb +5 -5
- data/lib/temporalio.rb +12 -3
- data/temporalio.gemspec +11 -6
- metadata +137 -64
- data/bridge/sdk-core/Cargo.lock +0 -2606
- data/bridge/sdk-core/bridge-ffi/Cargo.toml +0 -24
- data/bridge/sdk-core/bridge-ffi/LICENSE.txt +0 -23
- data/bridge/sdk-core/bridge-ffi/build.rs +0 -25
- data/bridge/sdk-core/bridge-ffi/include/sdk-core-bridge.h +0 -249
- data/bridge/sdk-core/bridge-ffi/src/lib.rs +0 -825
- data/bridge/sdk-core/bridge-ffi/src/wrappers.rs +0 -211
- data/bridge/sdk-core/core/src/log_export.rs +0 -62
- data/bridge/sdk-core/core/src/worker/workflow/machines/mutable_side_effect_state_machine.rs +0 -127
- data/bridge/sdk-core/core/src/worker/workflow/machines/side_effect_state_machine.rs +0 -71
- data/bridge/sdk-core/protos/api_upstream/temporal/api/cluster/v1/message.proto +0 -83
- data/bridge/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +0 -210
- data/bridge/sdk-core/sdk/src/conversions.rs +0 -8
- data/lib/bridge.so +0 -0
- data/lib/gen/temporal/api/cluster/v1/message_pb.rb +0 -67
- data/lib/gen/temporal/api/enums/v1/cluster_pb.rb +0 -26
- data/lib/gen/temporal/sdk/core/bridge/bridge_pb.rb +0 -222
- data/lib/temporal/bridge.rb +0 -14
- data/lib/temporal/connection.rb +0 -736
- data/lib/temporal/failure_converter.rb +0 -8
- data/lib/temporal/payload_converter.rb +0 -14
- data/lib/temporal/runtime.rb +0 -22
- data/lib/temporal/version.rb +0 -3
- data/lib/temporal.rb +0 -8
|
@@ -6,22 +6,25 @@ use crate::{
|
|
|
6
6
|
NamespacedWorkflowExecution,
|
|
7
7
|
},
|
|
8
8
|
external_data::LocalActivityMarkerData,
|
|
9
|
+
workflow_commands::ScheduleActivity,
|
|
9
10
|
IntoPayloadsExt,
|
|
10
11
|
},
|
|
11
12
|
temporal::api::{
|
|
12
|
-
common::v1::{Payload, Payloads, WorkflowExecution, WorkflowType},
|
|
13
|
-
enums::v1::{EventType, WorkflowTaskFailedCause},
|
|
13
|
+
common::v1::{ActivityType, Payload, Payloads, WorkflowExecution, WorkflowType},
|
|
14
|
+
enums::v1::{EventType, TaskQueueKind, WorkflowTaskFailedCause},
|
|
14
15
|
failure::v1::{failure, CanceledFailureInfo, Failure},
|
|
15
16
|
history::v1::{history_event::Attributes, *},
|
|
17
|
+
taskqueue::v1::TaskQueue,
|
|
16
18
|
},
|
|
17
19
|
HistoryInfo,
|
|
18
20
|
};
|
|
19
21
|
use anyhow::bail;
|
|
20
|
-
use
|
|
22
|
+
use prost_wkt_types::Timestamp;
|
|
21
23
|
use std::time::{Duration, SystemTime};
|
|
22
24
|
use uuid::Uuid;
|
|
23
25
|
|
|
24
26
|
pub static DEFAULT_WORKFLOW_TYPE: &str = "default_wf_type";
|
|
27
|
+
pub static DEFAULT_ACTIVITY_TYPE: &str = "default_act_type";
|
|
25
28
|
|
|
26
29
|
type Result<T, E = anyhow::Error> = std::result::Result<T, E>;
|
|
27
30
|
|
|
@@ -38,27 +41,41 @@ pub struct TestHistoryBuilder {
|
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
impl TestHistoryBuilder {
|
|
44
|
+
pub fn from_history(events: Vec<HistoryEvent>) -> Self {
|
|
45
|
+
let find_matching_id = |etype: EventType| {
|
|
46
|
+
events
|
|
47
|
+
.iter()
|
|
48
|
+
.rev()
|
|
49
|
+
.find(|e| e.event_type() == etype)
|
|
50
|
+
.map(|e| e.event_id)
|
|
51
|
+
.unwrap_or_default()
|
|
52
|
+
};
|
|
53
|
+
Self {
|
|
54
|
+
current_event_id: events.last().map(|e| e.event_id).unwrap_or_default(),
|
|
55
|
+
workflow_task_scheduled_event_id: find_matching_id(EventType::WorkflowTaskScheduled),
|
|
56
|
+
final_workflow_task_started_event_id: find_matching_id(EventType::WorkflowTaskStarted),
|
|
57
|
+
previous_task_completed_id: find_matching_id(EventType::WorkflowTaskCompleted),
|
|
58
|
+
original_run_id: extract_original_run_id_from_events(&events)
|
|
59
|
+
.expect("Run id must be discoverable")
|
|
60
|
+
.to_string(),
|
|
61
|
+
events,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
41
65
|
/// Add an event by type with attributes. Bundles both into a [HistoryEvent] with an id that is
|
|
42
|
-
/// incremented on each call to add.
|
|
43
|
-
pub fn add(&mut self,
|
|
44
|
-
|
|
66
|
+
/// incremented on each call to add. Returns the id of the new event.
|
|
67
|
+
pub fn add(&mut self, attribs: impl Into<Attributes>) -> i64 {
|
|
68
|
+
let attribs: Attributes = attribs.into();
|
|
69
|
+
self.build_and_push_event(attribs.event_type(), attribs);
|
|
70
|
+
self.current_event_id
|
|
45
71
|
}
|
|
46
72
|
|
|
47
|
-
/// Adds an event to the history by type, with default attributes.
|
|
48
|
-
|
|
73
|
+
/// Adds an event to the history by type, with default attributes. Returns the id of the new
|
|
74
|
+
/// event.
|
|
75
|
+
pub fn add_by_type(&mut self, event_type: EventType) -> i64 {
|
|
49
76
|
let attribs =
|
|
50
77
|
default_attribs(event_type).expect("Couldn't make default attributes in test builder");
|
|
51
|
-
self.
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/// Adds an event, returning the ID that was assigned to it
|
|
55
|
-
pub fn add_get_event_id(&mut self, event_type: EventType, attrs: Option<Attributes>) -> i64 {
|
|
56
|
-
if let Some(a) = attrs {
|
|
57
|
-
self.build_and_push_event(event_type, a);
|
|
58
|
-
} else {
|
|
59
|
-
self.add_by_type(event_type);
|
|
60
|
-
}
|
|
61
|
-
self.current_event_id
|
|
78
|
+
self.add(attribs)
|
|
62
79
|
}
|
|
63
80
|
|
|
64
81
|
/// Adds the following events:
|
|
@@ -78,25 +95,21 @@ impl TestHistoryBuilder {
|
|
|
78
95
|
}
|
|
79
96
|
|
|
80
97
|
pub fn add_workflow_task_scheduled(&mut self) {
|
|
81
|
-
self.workflow_task_scheduled_event_id =
|
|
82
|
-
self.add_get_event_id(EventType::WorkflowTaskScheduled, None);
|
|
98
|
+
self.workflow_task_scheduled_event_id = self.add_by_type(EventType::WorkflowTaskScheduled);
|
|
83
99
|
}
|
|
84
100
|
|
|
85
101
|
pub fn add_workflow_task_started(&mut self) {
|
|
86
|
-
|
|
102
|
+
self.final_workflow_task_started_event_id = self.add(WorkflowTaskStartedEventAttributes {
|
|
87
103
|
scheduled_event_id: self.workflow_task_scheduled_event_id,
|
|
88
104
|
..Default::default()
|
|
89
|
-
};
|
|
90
|
-
self.final_workflow_task_started_event_id =
|
|
91
|
-
self.add_get_event_id(EventType::WorkflowTaskStarted, Some(attrs.into()));
|
|
105
|
+
});
|
|
92
106
|
}
|
|
93
107
|
|
|
94
108
|
pub fn add_workflow_task_completed(&mut self) {
|
|
95
|
-
let
|
|
109
|
+
let id = self.add(WorkflowTaskCompletedEventAttributes {
|
|
96
110
|
scheduled_event_id: self.workflow_task_scheduled_event_id,
|
|
97
111
|
..Default::default()
|
|
98
|
-
};
|
|
99
|
-
let id = self.add_get_event_id(EventType::WorkflowTaskCompleted, Some(attrs.into()));
|
|
112
|
+
});
|
|
100
113
|
self.previous_task_completed_id = id;
|
|
101
114
|
}
|
|
102
115
|
|
|
@@ -154,30 +167,22 @@ impl TestHistoryBuilder {
|
|
|
154
167
|
}
|
|
155
168
|
|
|
156
169
|
pub fn add_activity_task_scheduled(&mut self, activity_id: impl Into<String>) -> i64 {
|
|
157
|
-
self.
|
|
158
|
-
|
|
159
|
-
Some(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
},
|
|
165
|
-
),
|
|
166
|
-
),
|
|
167
|
-
)
|
|
170
|
+
self.add(ActivityTaskScheduledEventAttributes {
|
|
171
|
+
activity_id: activity_id.into(),
|
|
172
|
+
activity_type: Some(ActivityType {
|
|
173
|
+
name: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
174
|
+
}),
|
|
175
|
+
..Default::default()
|
|
176
|
+
})
|
|
168
177
|
}
|
|
178
|
+
|
|
169
179
|
pub fn add_activity_task_started(&mut self, scheduled_event_id: i64) -> i64 {
|
|
170
|
-
self.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
..Default::default()
|
|
177
|
-
},
|
|
178
|
-
),
|
|
179
|
-
),
|
|
180
|
-
)
|
|
180
|
+
self.add(Attributes::ActivityTaskStartedEventAttributes(
|
|
181
|
+
ActivityTaskStartedEventAttributes {
|
|
182
|
+
scheduled_event_id,
|
|
183
|
+
..Default::default()
|
|
184
|
+
},
|
|
185
|
+
))
|
|
181
186
|
}
|
|
182
187
|
|
|
183
188
|
pub fn add_activity_task_completed(
|
|
@@ -186,17 +191,12 @@ impl TestHistoryBuilder {
|
|
|
186
191
|
started_event_id: i64,
|
|
187
192
|
payload: Payload,
|
|
188
193
|
) {
|
|
189
|
-
self.add(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
result: vec![payload].into_payloads(),
|
|
196
|
-
..Default::default()
|
|
197
|
-
},
|
|
198
|
-
),
|
|
199
|
-
);
|
|
194
|
+
self.add(ActivityTaskCompletedEventAttributes {
|
|
195
|
+
scheduled_event_id,
|
|
196
|
+
started_event_id,
|
|
197
|
+
result: vec![payload].into_payloads(),
|
|
198
|
+
..Default::default()
|
|
199
|
+
});
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
pub fn add_activity_task_cancel_requested(&mut self, scheduled_event_id: i64) {
|
|
@@ -236,13 +236,10 @@ impl TestHistoryBuilder {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
pub fn add_timer_fired(&mut self, timer_started_evt_id: i64, timer_id: String) {
|
|
239
|
-
self.add(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
timer_id,
|
|
244
|
-
}),
|
|
245
|
-
);
|
|
239
|
+
self.add(TimerFiredEventAttributes {
|
|
240
|
+
started_event_id: timer_started_evt_id,
|
|
241
|
+
timer_id,
|
|
242
|
+
});
|
|
246
243
|
}
|
|
247
244
|
|
|
248
245
|
pub fn add_we_signaled(&mut self, signal_name: &str, payloads: Vec<Payload>) {
|
|
@@ -270,22 +267,21 @@ impl TestHistoryBuilder {
|
|
|
270
267
|
activity_id: &str,
|
|
271
268
|
payload: Option<Payload>,
|
|
272
269
|
failure: Option<Failure>,
|
|
273
|
-
|
|
270
|
+
detail_mutator: impl FnOnce(&mut LocalActivityMarkerData),
|
|
274
271
|
) {
|
|
272
|
+
let mut lamd = LocalActivityMarkerData {
|
|
273
|
+
seq,
|
|
274
|
+
attempt: 1,
|
|
275
|
+
activity_id: activity_id.to_string(),
|
|
276
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
277
|
+
complete_time: None,
|
|
278
|
+
backoff: None,
|
|
279
|
+
original_schedule_time: None,
|
|
280
|
+
};
|
|
281
|
+
detail_mutator(&mut lamd);
|
|
275
282
|
let attrs = MarkerRecordedEventAttributes {
|
|
276
283
|
marker_name: LOCAL_ACTIVITY_MARKER_NAME.to_string(),
|
|
277
|
-
details: build_local_activity_marker_details(
|
|
278
|
-
LocalActivityMarkerData {
|
|
279
|
-
seq,
|
|
280
|
-
attempt: 1,
|
|
281
|
-
activity_id: activity_id.to_string(),
|
|
282
|
-
activity_type: "some_act_type".to_string(),
|
|
283
|
-
complete_time,
|
|
284
|
-
backoff: None,
|
|
285
|
-
original_schedule_time: None,
|
|
286
|
-
},
|
|
287
|
-
payload,
|
|
288
|
-
),
|
|
284
|
+
details: build_local_activity_marker_details(lamd, payload),
|
|
289
285
|
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
290
286
|
failure,
|
|
291
287
|
..Default::default()
|
|
@@ -299,7 +295,7 @@ impl TestHistoryBuilder {
|
|
|
299
295
|
activity_id: &str,
|
|
300
296
|
payload: Payload,
|
|
301
297
|
) {
|
|
302
|
-
self.add_local_activity_marker(seq, activity_id, Some(payload), None,
|
|
298
|
+
self.add_local_activity_marker(seq, activity_id, Some(payload), None, |_| {});
|
|
303
299
|
}
|
|
304
300
|
|
|
305
301
|
pub fn add_local_activity_result_marker_with_time(
|
|
@@ -309,7 +305,9 @@ impl TestHistoryBuilder {
|
|
|
309
305
|
payload: Payload,
|
|
310
306
|
complete_time: Timestamp,
|
|
311
307
|
) {
|
|
312
|
-
self.add_local_activity_marker(seq, activity_id, Some(payload), None,
|
|
308
|
+
self.add_local_activity_marker(seq, activity_id, Some(payload), None, |d| {
|
|
309
|
+
d.complete_time = Some(complete_time)
|
|
310
|
+
});
|
|
313
311
|
}
|
|
314
312
|
|
|
315
313
|
pub fn add_local_activity_fail_marker(
|
|
@@ -318,7 +316,7 @@ impl TestHistoryBuilder {
|
|
|
318
316
|
activity_id: &str,
|
|
319
317
|
failure: Failure,
|
|
320
318
|
) {
|
|
321
|
-
self.add_local_activity_marker(seq, activity_id, None, Some(failure),
|
|
319
|
+
self.add_local_activity_marker(seq, activity_id, None, Some(failure), |_| {});
|
|
322
320
|
}
|
|
323
321
|
|
|
324
322
|
pub fn add_local_activity_cancel_marker(&mut self, seq: u32, activity_id: &str) {
|
|
@@ -336,7 +334,7 @@ impl TestHistoryBuilder {
|
|
|
336
334
|
)),
|
|
337
335
|
encoded_attributes: Default::default(),
|
|
338
336
|
}),
|
|
339
|
-
|
|
337
|
+
|_| {},
|
|
340
338
|
);
|
|
341
339
|
}
|
|
342
340
|
|
|
@@ -346,7 +344,7 @@ impl TestHistoryBuilder {
|
|
|
346
344
|
workflow_id: impl Into<String>,
|
|
347
345
|
run_id: impl Into<String>,
|
|
348
346
|
) -> i64 {
|
|
349
|
-
|
|
347
|
+
self.add(SignalExternalWorkflowExecutionInitiatedEventAttributes {
|
|
350
348
|
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
351
349
|
workflow_execution: Some(WorkflowExecution {
|
|
352
350
|
workflow_id: workflow_id.into(),
|
|
@@ -355,11 +353,7 @@ impl TestHistoryBuilder {
|
|
|
355
353
|
signal_name: signal_name.into(),
|
|
356
354
|
control: "".to_string(),
|
|
357
355
|
..Default::default()
|
|
358
|
-
}
|
|
359
|
-
self.add_get_event_id(
|
|
360
|
-
EventType::SignalExternalWorkflowExecutionInitiated,
|
|
361
|
-
Some(attrs.into()),
|
|
362
|
-
)
|
|
356
|
+
})
|
|
363
357
|
}
|
|
364
358
|
|
|
365
359
|
pub fn add_external_signal_completed(&mut self, initiated_id: i64) {
|
|
@@ -382,18 +376,16 @@ impl TestHistoryBuilder {
|
|
|
382
376
|
}
|
|
383
377
|
|
|
384
378
|
pub fn add_cancel_external_wf(&mut self, execution: NamespacedWorkflowExecution) -> i64 {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
EventType::RequestCancelExternalWorkflowExecutionInitiated,
|
|
396
|
-
Some(attrs.into()),
|
|
379
|
+
self.add(
|
|
380
|
+
RequestCancelExternalWorkflowExecutionInitiatedEventAttributes {
|
|
381
|
+
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
382
|
+
namespace: execution.namespace,
|
|
383
|
+
workflow_execution: Some(WorkflowExecution {
|
|
384
|
+
workflow_id: execution.workflow_id,
|
|
385
|
+
run_id: execution.run_id,
|
|
386
|
+
}),
|
|
387
|
+
..Default::default()
|
|
388
|
+
},
|
|
397
389
|
)
|
|
398
390
|
}
|
|
399
391
|
|
|
@@ -419,6 +411,12 @@ impl TestHistoryBuilder {
|
|
|
419
411
|
);
|
|
420
412
|
}
|
|
421
413
|
|
|
414
|
+
pub fn add_wfe_started_with_wft_timeout(&mut self, dur: Duration) {
|
|
415
|
+
let mut wesattrs = default_wes_attribs();
|
|
416
|
+
wesattrs.workflow_task_timeout = Some(dur.try_into().unwrap());
|
|
417
|
+
self.add(wesattrs);
|
|
418
|
+
}
|
|
419
|
+
|
|
422
420
|
pub fn get_orig_run_id(&self) -> &str {
|
|
423
421
|
&self.original_run_id
|
|
424
422
|
}
|
|
@@ -443,13 +441,64 @@ impl TestHistoryBuilder {
|
|
|
443
441
|
}
|
|
444
442
|
|
|
445
443
|
/// Return most recent wft start time or panic if unset
|
|
446
|
-
pub fn wft_start_time(&self) ->
|
|
444
|
+
pub fn wft_start_time(&self) -> Timestamp {
|
|
447
445
|
self.events[(self.workflow_task_scheduled_event_id + 1) as usize]
|
|
448
446
|
.event_time
|
|
449
447
|
.clone()
|
|
450
448
|
.unwrap()
|
|
451
449
|
}
|
|
452
450
|
|
|
451
|
+
/// Alter the workflow type of the history
|
|
452
|
+
pub fn set_wf_type(&mut self, name: &str) {
|
|
453
|
+
if let Some(Attributes::WorkflowExecutionStartedEventAttributes(wes)) =
|
|
454
|
+
self.events.get_mut(0).and_then(|e| e.attributes.as_mut())
|
|
455
|
+
{
|
|
456
|
+
wes.workflow_type = Some(WorkflowType {
|
|
457
|
+
name: name.to_string(),
|
|
458
|
+
})
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/// Alter some specific event. You can easily craft nonsense histories this way, use carefully.
|
|
463
|
+
pub fn modify_event(&mut self, event_id: i64, modifier: impl FnOnce(&mut HistoryEvent)) {
|
|
464
|
+
let he = self
|
|
465
|
+
.events
|
|
466
|
+
.get_mut((event_id - 1) as usize)
|
|
467
|
+
.expect("Event must be present");
|
|
468
|
+
modifier(he);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/// Sets internal patches which should appear in the first WFT complete event
|
|
472
|
+
pub fn set_flags_first_wft(&mut self, core: &[u32], lang: &[u32]) {
|
|
473
|
+
Self::set_flags(self.events.iter_mut(), core, lang)
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/// Sets internal patches which should appear in the most recent complete event
|
|
477
|
+
pub fn set_flags_last_wft(&mut self, core: &[u32], lang: &[u32]) {
|
|
478
|
+
Self::set_flags(self.events.iter_mut().rev(), core, lang)
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
fn set_flags<'a>(
|
|
482
|
+
mut events: impl Iterator<Item = &'a mut HistoryEvent>,
|
|
483
|
+
core: &[u32],
|
|
484
|
+
lang: &[u32],
|
|
485
|
+
) {
|
|
486
|
+
if let Some(first_attrs) = events.find_map(|e| {
|
|
487
|
+
if let Some(Attributes::WorkflowTaskCompletedEventAttributes(a)) = e.attributes.as_mut()
|
|
488
|
+
{
|
|
489
|
+
Some(a)
|
|
490
|
+
} else {
|
|
491
|
+
None
|
|
492
|
+
}
|
|
493
|
+
}) {
|
|
494
|
+
let sdk_dat = first_attrs
|
|
495
|
+
.sdk_metadata
|
|
496
|
+
.get_or_insert_with(Default::default);
|
|
497
|
+
sdk_dat.core_used_flags = core.to_vec();
|
|
498
|
+
sdk_dat.lang_used_flags = lang.to_vec();
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
453
502
|
fn build_and_push_event(&mut self, event_type: EventType, attribs: Attributes) {
|
|
454
503
|
self.current_event_id += 1;
|
|
455
504
|
let evt = HistoryEvent {
|
|
@@ -492,6 +541,17 @@ pub fn default_wes_attribs() -> WorkflowExecutionStartedEventAttributes {
|
|
|
492
541
|
.try_into()
|
|
493
542
|
.expect("5 secs is a valid duration"),
|
|
494
543
|
),
|
|
544
|
+
task_queue: Some(TaskQueue {
|
|
545
|
+
name: "q".to_string(),
|
|
546
|
+
kind: TaskQueueKind::Normal as i32,
|
|
547
|
+
}),
|
|
548
|
+
..Default::default()
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
pub fn default_act_sched() -> ScheduleActivity {
|
|
553
|
+
ScheduleActivity {
|
|
554
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
495
555
|
..Default::default()
|
|
496
556
|
}
|
|
497
557
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use crate::temporal::api::{
|
|
2
2
|
common::v1::WorkflowType,
|
|
3
3
|
enums::v1::{EventType, TaskQueueKind},
|
|
4
|
-
history::v1::{history_event, History, HistoryEvent},
|
|
4
|
+
history::v1::{history_event, History, HistoryEvent, WorkflowExecutionStartedEventAttributes},
|
|
5
5
|
taskqueue::v1::TaskQueue,
|
|
6
6
|
workflowservice::v1::{GetWorkflowExecutionHistoryResponse, PollWorkflowTaskQueueResponse},
|
|
7
7
|
};
|
|
@@ -18,6 +18,7 @@ pub struct HistoryInfo {
|
|
|
18
18
|
events: Vec<HistoryEvent>,
|
|
19
19
|
wf_task_count: usize,
|
|
20
20
|
wf_type: String,
|
|
21
|
+
wf_exe_started_attrs: WorkflowExecutionStartedEventAttributes,
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
type Result<T, E = anyhow::Error> = std::result::Result<T, E>;
|
|
@@ -36,20 +37,18 @@ impl HistoryInfo {
|
|
|
36
37
|
let mut workflow_task_started_event_id = 0;
|
|
37
38
|
let mut wf_task_count = 0;
|
|
38
39
|
let mut history = events.iter().peekable();
|
|
39
|
-
|
|
40
|
-
let wf_type = match &events.get(0).unwrap().attributes {
|
|
40
|
+
let started_attrs = match &events.get(0).unwrap().attributes {
|
|
41
41
|
Some(history_event::Attributes::WorkflowExecutionStartedEventAttributes(attrs)) => {
|
|
42
|
-
attrs
|
|
43
|
-
.workflow_type
|
|
44
|
-
.as_ref()
|
|
45
|
-
.ok_or_else(|| {
|
|
46
|
-
anyhow!("No workflow type defined in execution started attributes")
|
|
47
|
-
})?
|
|
48
|
-
.name
|
|
49
|
-
.clone()
|
|
42
|
+
attrs.clone()
|
|
50
43
|
}
|
|
51
44
|
_ => bail!("First event in history was not workflow execution started!"),
|
|
52
45
|
};
|
|
46
|
+
let wf_type = started_attrs
|
|
47
|
+
.workflow_type
|
|
48
|
+
.as_ref()
|
|
49
|
+
.ok_or_else(|| anyhow!("No workflow type defined in execution started attributes"))?
|
|
50
|
+
.name
|
|
51
|
+
.clone();
|
|
53
52
|
|
|
54
53
|
let mut events = vec![];
|
|
55
54
|
while let Some(event) = history.next() {
|
|
@@ -87,6 +86,7 @@ impl HistoryInfo {
|
|
|
87
86
|
events,
|
|
88
87
|
wf_task_count,
|
|
89
88
|
wf_type,
|
|
89
|
+
wf_exe_started_attrs: started_attrs,
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
} else if next_event.is_some() && !next_is_failed_or_timeout_or_term {
|
|
@@ -108,6 +108,7 @@ impl HistoryInfo {
|
|
|
108
108
|
events,
|
|
109
109
|
wf_task_count,
|
|
110
110
|
wf_type,
|
|
111
|
+
wf_exe_started_attrs: started_attrs,
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
114
|
// No more events
|
|
@@ -135,16 +136,13 @@ impl HistoryInfo {
|
|
|
135
136
|
&self.events
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
pub fn into_events(self) -> Vec<HistoryEvent> {
|
|
140
|
+
self.events
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/// Extract run id from the workflow execution started attributes.
|
|
140
144
|
pub fn orig_run_id(&self) -> &str {
|
|
141
|
-
|
|
142
|
-
&self.events[0].attributes
|
|
143
|
-
{
|
|
144
|
-
&wes.original_execution_run_id
|
|
145
|
-
} else {
|
|
146
|
-
panic!("First event is wrong type")
|
|
147
|
-
}
|
|
145
|
+
&self.wf_exe_started_attrs.original_execution_run_id
|
|
148
146
|
}
|
|
149
147
|
|
|
150
148
|
/// Return total workflow task count in this history
|
|
@@ -155,7 +153,7 @@ impl HistoryInfo {
|
|
|
155
153
|
/// Create a workflow task polling response containing all the events in this history and a
|
|
156
154
|
/// randomly generated task token. Caller should attach a meaningful `workflow_execution` if
|
|
157
155
|
/// needed.
|
|
158
|
-
pub fn as_poll_wft_response(&self
|
|
156
|
+
pub fn as_poll_wft_response(&self) -> PollWorkflowTaskQueueResponse {
|
|
159
157
|
let task_token: [u8; 16] = thread_rng().gen();
|
|
160
158
|
PollWorkflowTaskQueueResponse {
|
|
161
159
|
history: Some(History {
|
|
@@ -166,7 +164,13 @@ impl HistoryInfo {
|
|
|
166
164
|
name: self.wf_type.clone(),
|
|
167
165
|
}),
|
|
168
166
|
workflow_execution_task_queue: Some(TaskQueue {
|
|
169
|
-
name:
|
|
167
|
+
name: self
|
|
168
|
+
.wf_exe_started_attrs
|
|
169
|
+
.task_queue
|
|
170
|
+
.as_ref()
|
|
171
|
+
.unwrap()
|
|
172
|
+
.name
|
|
173
|
+
.clone(),
|
|
170
174
|
kind: TaskQueueKind::Normal as i32,
|
|
171
175
|
}),
|
|
172
176
|
previous_started_event_id: self.previous_started_event_id,
|
|
@@ -204,7 +208,7 @@ mod tests {
|
|
|
204
208
|
let mut t = TestHistoryBuilder::default();
|
|
205
209
|
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
206
210
|
t.add_full_wf_task();
|
|
207
|
-
let timer_started_event_id = t.
|
|
211
|
+
let timer_started_event_id = t.add_by_type(EventType::TimerStarted);
|
|
208
212
|
t.add_timer_fired(timer_started_event_id, timer_id.to_string());
|
|
209
213
|
t.add_workflow_task_scheduled_and_started();
|
|
210
214
|
t
|