temporalio 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Cargo.lock +4035 -0
- data/Cargo.toml +25 -0
- data/Gemfile +20 -0
- data/LICENSE +16 -15
- data/README.md +455 -195
- data/Rakefile +387 -0
- data/ext/Cargo.toml +25 -0
- data/lib/temporalio/activity/complete_async_error.rb +11 -0
- data/lib/temporalio/activity/context.rb +82 -77
- data/lib/temporalio/activity/definition.rb +77 -0
- data/lib/temporalio/activity/info.rb +42 -46
- data/lib/temporalio/activity.rb +49 -65
- data/lib/temporalio/api/batch/v1/message.rb +31 -0
- data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +93 -0
- data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +25 -0
- data/lib/temporalio/api/cloud/cloudservice.rb +3 -0
- data/lib/temporalio/api/cloud/identity/v1/message.rb +36 -0
- data/lib/temporalio/api/cloud/namespace/v1/message.rb +35 -0
- data/lib/temporalio/api/cloud/operation/v1/message.rb +27 -0
- data/lib/temporalio/api/cloud/region/v1/message.rb +23 -0
- data/lib/temporalio/api/command/v1/message.rb +46 -0
- data/lib/temporalio/api/common/v1/grpc_status.rb +23 -0
- data/lib/temporalio/api/common/v1/message.rb +41 -0
- data/lib/temporalio/api/enums/v1/batch_operation.rb +22 -0
- data/lib/temporalio/api/enums/v1/command_type.rb +21 -0
- data/lib/temporalio/api/enums/v1/common.rb +26 -0
- data/lib/temporalio/api/enums/v1/event_type.rb +21 -0
- data/lib/temporalio/api/enums/v1/failed_cause.rb +26 -0
- data/lib/temporalio/api/enums/v1/namespace.rb +23 -0
- data/lib/temporalio/api/enums/v1/query.rb +22 -0
- data/lib/temporalio/api/enums/v1/reset.rb +23 -0
- data/lib/temporalio/api/enums/v1/schedule.rb +21 -0
- data/lib/temporalio/api/enums/v1/task_queue.rb +25 -0
- data/lib/temporalio/api/enums/v1/update.rb +22 -0
- data/lib/temporalio/api/enums/v1/workflow.rb +30 -0
- data/lib/temporalio/api/errordetails/v1/message.rb +42 -0
- data/lib/temporalio/api/export/v1/message.rb +24 -0
- data/lib/temporalio/api/failure/v1/message.rb +35 -0
- data/lib/temporalio/api/filter/v1/message.rb +27 -0
- data/lib/temporalio/api/history/v1/message.rb +90 -0
- data/lib/temporalio/api/namespace/v1/message.rb +31 -0
- data/lib/temporalio/api/nexus/v1/message.rb +40 -0
- data/lib/temporalio/api/operatorservice/v1/request_response.rb +49 -0
- data/lib/temporalio/api/operatorservice/v1/service.rb +23 -0
- data/lib/temporalio/api/operatorservice.rb +3 -0
- data/lib/temporalio/api/protocol/v1/message.rb +23 -0
- data/lib/temporalio/api/query/v1/message.rb +27 -0
- data/lib/temporalio/api/replication/v1/message.rb +26 -0
- data/lib/temporalio/api/schedule/v1/message.rb +42 -0
- data/lib/temporalio/api/sdk/v1/enhanced_stack_trace.rb +25 -0
- data/lib/temporalio/api/sdk/v1/task_complete_metadata.rb +21 -0
- data/lib/temporalio/api/sdk/v1/user_metadata.rb +23 -0
- data/lib/temporalio/api/sdk/v1/workflow_metadata.rb +23 -0
- data/lib/temporalio/api/taskqueue/v1/message.rb +45 -0
- data/lib/temporalio/api/update/v1/message.rb +33 -0
- data/lib/temporalio/api/version/v1/message.rb +26 -0
- data/lib/temporalio/api/workflow/v1/message.rb +43 -0
- data/lib/temporalio/api/workflowservice/v1/request_response.rb +189 -0
- data/lib/temporalio/api/workflowservice/v1/service.rb +23 -0
- data/lib/temporalio/api/workflowservice.rb +3 -0
- data/lib/temporalio/api.rb +13 -0
- data/lib/temporalio/cancellation.rb +150 -0
- data/lib/temporalio/client/activity_id_reference.rb +32 -0
- data/lib/temporalio/client/async_activity_handle.rb +110 -0
- data/lib/temporalio/client/connection/cloud_service.rb +648 -0
- data/lib/temporalio/client/connection/operator_service.rb +249 -0
- data/lib/temporalio/client/connection/service.rb +41 -0
- data/lib/temporalio/client/connection/workflow_service.rb +1218 -0
- data/lib/temporalio/client/connection.rb +270 -0
- data/lib/temporalio/client/interceptor.rb +316 -0
- data/lib/temporalio/client/workflow_execution.rb +103 -0
- data/lib/temporalio/client/workflow_execution_count.rb +36 -0
- data/lib/temporalio/client/workflow_execution_status.rb +18 -0
- data/lib/temporalio/client/workflow_handle.rb +380 -177
- data/lib/temporalio/client/workflow_query_reject_condition.rb +14 -0
- data/lib/temporalio/client/workflow_update_handle.rb +67 -0
- data/lib/temporalio/client/workflow_update_wait_stage.rb +17 -0
- data/lib/temporalio/client.rb +366 -93
- data/lib/temporalio/common_enums.rb +24 -0
- data/lib/temporalio/converters/data_converter.rb +102 -0
- data/lib/temporalio/converters/failure_converter.rb +200 -0
- data/lib/temporalio/converters/payload_codec.rb +26 -0
- data/lib/temporalio/converters/payload_converter/binary_null.rb +34 -0
- data/lib/temporalio/converters/payload_converter/binary_plain.rb +35 -0
- data/lib/temporalio/converters/payload_converter/binary_protobuf.rb +42 -0
- data/lib/temporalio/converters/payload_converter/composite.rb +62 -0
- data/lib/temporalio/converters/payload_converter/encoding.rb +35 -0
- data/lib/temporalio/converters/payload_converter/json_plain.rb +44 -0
- data/lib/temporalio/converters/payload_converter/json_protobuf.rb +41 -0
- data/lib/temporalio/converters/payload_converter.rb +73 -0
- data/lib/temporalio/converters.rb +9 -0
- data/lib/temporalio/error/failure.rb +119 -94
- data/lib/temporalio/error.rb +147 -0
- data/lib/temporalio/internal/bridge/api/activity_result/activity_result.rb +34 -0
- data/lib/temporalio/internal/bridge/api/activity_task/activity_task.rb +31 -0
- data/lib/temporalio/internal/bridge/api/child_workflow/child_workflow.rb +33 -0
- data/lib/temporalio/internal/bridge/api/common/common.rb +26 -0
- data/lib/temporalio/internal/bridge/api/core_interface.rb +36 -0
- data/lib/temporalio/internal/bridge/api/external_data/external_data.rb +27 -0
- data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +52 -0
- data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +54 -0
- data/lib/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rb +30 -0
- data/lib/temporalio/internal/bridge/api.rb +3 -0
- data/lib/temporalio/internal/bridge/client.rb +90 -0
- data/lib/temporalio/internal/bridge/runtime.rb +53 -0
- data/lib/temporalio/internal/bridge/testing.rb +46 -0
- data/lib/temporalio/internal/bridge/worker.rb +83 -0
- data/lib/temporalio/internal/bridge.rb +36 -0
- data/lib/temporalio/internal/client/implementation.rb +525 -0
- data/lib/temporalio/internal/proto_utils.rb +54 -0
- data/lib/temporalio/internal/worker/activity_worker.rb +345 -0
- data/lib/temporalio/internal/worker/multi_runner.rb +169 -0
- data/lib/temporalio/internal.rb +7 -0
- data/lib/temporalio/retry_policy.rb +39 -80
- data/lib/temporalio/runtime.rb +259 -13
- data/lib/temporalio/scoped_logger.rb +96 -0
- data/lib/temporalio/search_attributes.rb +300 -0
- data/lib/temporalio/testing/activity_environment.rb +132 -0
- data/lib/temporalio/testing/workflow_environment.rb +113 -88
- data/lib/temporalio/testing.rb +4 -169
- data/lib/temporalio/version.rb +3 -1
- data/lib/temporalio/worker/activity_executor/fiber.rb +49 -0
- data/lib/temporalio/worker/activity_executor/thread_pool.rb +254 -0
- data/lib/temporalio/worker/activity_executor.rb +55 -0
- data/lib/temporalio/worker/interceptor.rb +88 -0
- data/lib/temporalio/worker/tuner.rb +151 -0
- data/lib/temporalio/worker.rb +385 -163
- data/lib/temporalio/workflow_history.rb +22 -0
- data/lib/temporalio.rb +2 -7
- data/temporalio.gemspec +20 -39
- metadata +131 -712
- data/bridge/Cargo.lock +0 -2997
- data/bridge/Cargo.toml +0 -29
- data/bridge/sdk-core/ARCHITECTURE.md +0 -76
- data/bridge/sdk-core/Cargo.toml +0 -2
- data/bridge/sdk-core/LICENSE.txt +0 -23
- data/bridge/sdk-core/README.md +0 -117
- data/bridge/sdk-core/arch_docs/diagrams/README.md +0 -10
- data/bridge/sdk-core/arch_docs/diagrams/sticky_queues.puml +0 -40
- data/bridge/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
- data/bridge/sdk-core/arch_docs/sticky_queues.md +0 -51
- data/bridge/sdk-core/client/Cargo.toml +0 -40
- data/bridge/sdk-core/client/LICENSE.txt +0 -23
- data/bridge/sdk-core/client/src/lib.rs +0 -1462
- data/bridge/sdk-core/client/src/metrics.rs +0 -174
- data/bridge/sdk-core/client/src/raw.rs +0 -932
- data/bridge/sdk-core/client/src/retry.rs +0 -763
- data/bridge/sdk-core/client/src/workflow_handle/mod.rs +0 -185
- data/bridge/sdk-core/core/Cargo.toml +0 -129
- data/bridge/sdk-core/core/LICENSE.txt +0 -23
- data/bridge/sdk-core/core/benches/workflow_replay.rs +0 -76
- data/bridge/sdk-core/core/src/abstractions.rs +0 -355
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +0 -1049
- data/bridge/sdk-core/core/src/core_tests/child_workflows.rs +0 -221
- data/bridge/sdk-core/core/src/core_tests/determinism.rs +0 -270
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +0 -1046
- data/bridge/sdk-core/core/src/core_tests/mod.rs +0 -100
- data/bridge/sdk-core/core/src/core_tests/queries.rs +0 -893
- data/bridge/sdk-core/core/src/core_tests/replay_flag.rs +0 -65
- data/bridge/sdk-core/core/src/core_tests/workers.rs +0 -257
- data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +0 -124
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +0 -2433
- data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +0 -609
- data/bridge/sdk-core/core/src/internal_flags.rs +0 -136
- data/bridge/sdk-core/core/src/lib.rs +0 -289
- data/bridge/sdk-core/core/src/pollers/mod.rs +0 -54
- data/bridge/sdk-core/core/src/pollers/poll_buffer.rs +0 -297
- data/bridge/sdk-core/core/src/protosext/mod.rs +0 -428
- data/bridge/sdk-core/core/src/replay/mod.rs +0 -215
- data/bridge/sdk-core/core/src/retry_logic.rs +0 -202
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +0 -190
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +0 -462
- data/bridge/sdk-core/core/src/telemetry/mod.rs +0 -423
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +0 -83
- data/bridge/sdk-core/core/src/test_help/mod.rs +0 -939
- data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +0 -536
- data/bridge/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +0 -89
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +0 -1278
- data/bridge/sdk-core/core/src/worker/activities.rs +0 -557
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +0 -107
- data/bridge/sdk-core/core/src/worker/client.rs +0 -389
- data/bridge/sdk-core/core/src/worker/mod.rs +0 -677
- data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +0 -35
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +0 -99
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +0 -1111
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +0 -964
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +0 -294
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -168
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +0 -918
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +0 -137
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +0 -158
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +0 -130
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +0 -1525
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +0 -324
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -179
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +0 -659
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +0 -439
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +0 -435
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +0 -175
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +0 -249
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +0 -85
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +0 -1280
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +0 -269
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +0 -213
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +0 -1305
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +0 -1276
- data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +0 -128
- data/bridge/sdk-core/core/src/worker/workflow/wft_extraction.rs +0 -125
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +0 -85
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +0 -117
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +0 -24
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +0 -715
- data/bridge/sdk-core/core-api/Cargo.toml +0 -33
- data/bridge/sdk-core/core-api/LICENSE.txt +0 -23
- data/bridge/sdk-core/core-api/src/errors.rs +0 -62
- data/bridge/sdk-core/core-api/src/lib.rs +0 -113
- data/bridge/sdk-core/core-api/src/telemetry.rs +0 -141
- data/bridge/sdk-core/core-api/src/worker.rs +0 -161
- data/bridge/sdk-core/etc/deps.svg +0 -162
- data/bridge/sdk-core/etc/dynamic-config.yaml +0 -2
- data/bridge/sdk-core/etc/otel-collector-config.yaml +0 -36
- data/bridge/sdk-core/etc/prometheus.yaml +0 -6
- data/bridge/sdk-core/etc/regen-depgraph.sh +0 -5
- data/bridge/sdk-core/fsm/Cargo.toml +0 -18
- data/bridge/sdk-core/fsm/LICENSE.txt +0 -23
- data/bridge/sdk-core/fsm/README.md +0 -3
- data/bridge/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +0 -27
- data/bridge/sdk-core/fsm/rustfsm_procmacro/LICENSE.txt +0 -23
- data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +0 -650
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +0 -8
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.rs +0 -18
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +0 -12
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dynamic_dest_pass.rs +0 -41
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.rs +0 -14
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.stderr +0 -11
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_arg_pass.rs +0 -32
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_pass.rs +0 -31
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/medium_complex_pass.rs +0 -46
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.rs +0 -29
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +0 -12
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/simple_pass.rs +0 -32
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.rs +0 -18
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +0 -5
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.rs +0 -11
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +0 -5
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.rs +0 -11
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +0 -5
- data/bridge/sdk-core/fsm/rustfsm_trait/Cargo.toml +0 -14
- data/bridge/sdk-core/fsm/rustfsm_trait/LICENSE.txt +0 -23
- data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +0 -254
- data/bridge/sdk-core/fsm/src/lib.rs +0 -2
- 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/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 +0 -7
- data/bridge/sdk-core/protos/api_upstream/README.md +0 -9
- data/bridge/sdk-core/protos/api_upstream/api-linter.yaml +0 -40
- data/bridge/sdk-core/protos/api_upstream/buf.yaml +0 -9
- data/bridge/sdk-core/protos/api_upstream/build/go.mod +0 -7
- data/bridge/sdk-core/protos/api_upstream/build/go.sum +0 -5
- data/bridge/sdk-core/protos/api_upstream/build/tools.go +0 -29
- data/bridge/sdk-core/protos/api_upstream/dependencies/gogoproto/gogo.proto +0 -141
- data/bridge/sdk-core/protos/api_upstream/go.mod +0 -6
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +0 -89
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +0 -248
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +0 -123
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -47
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +0 -52
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +0 -56
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +0 -170
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +0 -123
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +0 -51
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +0 -50
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +0 -41
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +0 -60
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -59
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +0 -56
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +0 -122
- data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +0 -108
- data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +0 -114
- data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +0 -56
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +0 -787
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +0 -99
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +0 -124
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -80
- data/bridge/sdk-core/protos/api_upstream/temporal/api/protocol/v1/message.proto +0 -57
- data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +0 -61
- data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +0 -55
- data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +0 -379
- data/bridge/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +0 -63
- data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +0 -108
- data/bridge/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +0 -111
- data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +0 -59
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +0 -146
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +0 -1199
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +0 -415
- data/bridge/sdk-core/protos/grpc/health/v1/health.proto +0 -63
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +0 -79
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +0 -80
- data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +0 -78
- data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +0 -16
- data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +0 -31
- data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +0 -31
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +0 -270
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +0 -305
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +0 -35
- data/bridge/sdk-core/protos/testsrv_upstream/api-linter.yaml +0 -38
- data/bridge/sdk-core/protos/testsrv_upstream/buf.yaml +0 -13
- data/bridge/sdk-core/protos/testsrv_upstream/dependencies/gogoproto/gogo.proto +0 -141
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +0 -63
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +0 -90
- data/bridge/sdk-core/rustfmt.toml +0 -1
- data/bridge/sdk-core/sdk/Cargo.toml +0 -48
- data/bridge/sdk-core/sdk/LICENSE.txt +0 -23
- data/bridge/sdk-core/sdk/src/activity_context.rs +0 -230
- data/bridge/sdk-core/sdk/src/app_data.rs +0 -37
- data/bridge/sdk-core/sdk/src/interceptors.rs +0 -50
- data/bridge/sdk-core/sdk/src/lib.rs +0 -861
- data/bridge/sdk-core/sdk/src/payload_converter.rs +0 -11
- data/bridge/sdk-core/sdk/src/workflow_context/options.rs +0 -295
- data/bridge/sdk-core/sdk/src/workflow_context.rs +0 -694
- data/bridge/sdk-core/sdk/src/workflow_future.rs +0 -500
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +0 -33
- data/bridge/sdk-core/sdk-core-protos/LICENSE.txt +0 -23
- data/bridge/sdk-core/sdk-core-protos/build.rs +0 -142
- data/bridge/sdk-core/sdk-core-protos/src/constants.rs +0 -7
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +0 -557
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +0 -234
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +0 -2088
- data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +0 -48
- data/bridge/sdk-core/sdk-core-protos/src/utilities.rs +0 -14
- data/bridge/sdk-core/test-utils/Cargo.toml +0 -38
- data/bridge/sdk-core/test-utils/src/canned_histories.rs +0 -1389
- data/bridge/sdk-core/test-utils/src/histfetch.rs +0 -28
- data/bridge/sdk-core/test-utils/src/lib.rs +0 -709
- data/bridge/sdk-core/test-utils/src/wf_input_saver.rs +0 -50
- data/bridge/sdk-core/test-utils/src/workflows.rs +0 -29
- data/bridge/sdk-core/tests/fuzzy_workflow.rs +0 -130
- data/bridge/sdk-core/tests/heavy_tests.rs +0 -265
- data/bridge/sdk-core/tests/integ_tests/client_tests.rs +0 -36
- data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +0 -150
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +0 -223
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +0 -239
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +0 -90
- data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +0 -314
- data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +0 -151
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +0 -902
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +0 -61
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +0 -60
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +0 -51
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +0 -51
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +0 -64
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +0 -47
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +0 -669
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +0 -54
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +0 -92
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +0 -228
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +0 -94
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +0 -171
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +0 -85
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +0 -120
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +0 -77
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +0 -596
- data/bridge/sdk-core/tests/main.rs +0 -103
- data/bridge/sdk-core/tests/runner.rs +0 -132
- data/bridge/sdk-core/tests/wf_input_replay.rs +0 -32
- data/bridge/src/connection.rs +0 -202
- data/bridge/src/lib.rs +0 -494
- data/bridge/src/runtime.rs +0 -54
- data/bridge/src/test_server.rs +0 -153
- data/bridge/src/worker.rs +0 -197
- data/ext/Rakefile +0 -9
- data/lib/gen/dependencies/gogoproto/gogo_pb.rb +0 -14
- data/lib/gen/temporal/api/batch/v1/message_pb.rb +0 -50
- data/lib/gen/temporal/api/command/v1/message_pb.rb +0 -160
- data/lib/gen/temporal/api/common/v1/message_pb.rb +0 -73
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +0 -33
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +0 -37
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +0 -42
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +0 -68
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +0 -79
- data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +0 -37
- data/lib/gen/temporal/api/enums/v1/query_pb.rb +0 -31
- data/lib/gen/temporal/api/enums/v1/reset_pb.rb +0 -24
- data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +0 -28
- data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +0 -30
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +0 -25
- data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +0 -89
- data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +0 -84
- data/lib/gen/temporal/api/failure/v1/message_pb.rb +0 -83
- data/lib/gen/temporal/api/filter/v1/message_pb.rb +0 -40
- data/lib/gen/temporal/api/history/v1/message_pb.rb +0 -498
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +0 -64
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +0 -88
- data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +0 -20
- data/lib/gen/temporal/api/protocol/v1/message_pb.rb +0 -30
- data/lib/gen/temporal/api/query/v1/message_pb.rb +0 -38
- data/lib/gen/temporal/api/replication/v1/message_pb.rb +0 -37
- data/lib/gen/temporal/api/schedule/v1/message_pb.rb +0 -149
- data/lib/gen/temporal/api/sdk/v1/task_complete_metadata_pb.rb +0 -23
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +0 -73
- data/lib/gen/temporal/api/testservice/v1/request_response_pb.rb +0 -49
- data/lib/gen/temporal/api/testservice/v1/service_pb.rb +0 -21
- data/lib/gen/temporal/api/update/v1/message_pb.rb +0 -72
- data/lib/gen/temporal/api/version/v1/message_pb.rb +0 -41
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +0 -111
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +0 -798
- data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +0 -20
- data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +0 -62
- data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +0 -61
- data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +0 -61
- data/lib/gen/temporal/sdk/core/common/common_pb.rb +0 -26
- data/lib/gen/temporal/sdk/core/core_interface_pb.rb +0 -40
- data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +0 -31
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +0 -171
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +0 -200
- data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +0 -41
- data/lib/temporalio/bridge/connect_options.rb +0 -15
- data/lib/temporalio/bridge/error.rb +0 -8
- data/lib/temporalio/bridge/retry_config.rb +0 -24
- data/lib/temporalio/bridge/tls_options.rb +0 -19
- data/lib/temporalio/bridge.rb +0 -14
- data/lib/temporalio/client/implementation.rb +0 -340
- data/lib/temporalio/connection/retry_config.rb +0 -44
- data/lib/temporalio/connection/service.rb +0 -20
- data/lib/temporalio/connection/test_service.rb +0 -92
- data/lib/temporalio/connection/tls_options.rb +0 -51
- data/lib/temporalio/connection/workflow_service.rb +0 -731
- data/lib/temporalio/connection.rb +0 -86
- data/lib/temporalio/data_converter.rb +0 -191
- data/lib/temporalio/error/workflow_failure.rb +0 -19
- data/lib/temporalio/errors.rb +0 -40
- data/lib/temporalio/failure_converter/base.rb +0 -26
- data/lib/temporalio/failure_converter/basic.rb +0 -319
- data/lib/temporalio/failure_converter.rb +0 -7
- data/lib/temporalio/interceptor/activity_inbound.rb +0 -22
- data/lib/temporalio/interceptor/activity_outbound.rb +0 -24
- data/lib/temporalio/interceptor/chain.rb +0 -28
- data/lib/temporalio/interceptor/client.rb +0 -127
- data/lib/temporalio/interceptor.rb +0 -22
- data/lib/temporalio/payload_codec/base.rb +0 -32
- data/lib/temporalio/payload_converter/base.rb +0 -24
- data/lib/temporalio/payload_converter/bytes.rb +0 -27
- data/lib/temporalio/payload_converter/composite.rb +0 -49
- data/lib/temporalio/payload_converter/encoding_base.rb +0 -35
- data/lib/temporalio/payload_converter/json.rb +0 -26
- data/lib/temporalio/payload_converter/nil.rb +0 -26
- data/lib/temporalio/payload_converter.rb +0 -14
- data/lib/temporalio/retry_state.rb +0 -35
- data/lib/temporalio/testing/time_skipping_handle.rb +0 -32
- data/lib/temporalio/testing/time_skipping_interceptor.rb +0 -23
- data/lib/temporalio/timeout_type.rb +0 -29
- data/lib/temporalio/worker/activity_runner.rb +0 -114
- data/lib/temporalio/worker/activity_worker.rb +0 -164
- data/lib/temporalio/worker/reactor.rb +0 -46
- data/lib/temporalio/worker/runner.rb +0 -63
- data/lib/temporalio/worker/sync_worker.rb +0 -124
- data/lib/temporalio/worker/thread_pool_executor.rb +0 -51
- data/lib/temporalio/workflow/async.rb +0 -46
- data/lib/temporalio/workflow/execution_info.rb +0 -54
- data/lib/temporalio/workflow/execution_status.rb +0 -36
- data/lib/temporalio/workflow/future.rb +0 -138
- data/lib/temporalio/workflow/id_reuse_policy.rb +0 -36
- data/lib/temporalio/workflow/info.rb +0 -76
- data/lib/temporalio/workflow/query_reject_condition.rb +0 -33
- data/lib/thermite_patch.rb +0 -33
- data/sig/async.rbs +0 -17
- data/sig/protobuf.rbs +0 -16
- data/sig/protos/dependencies/gogoproto/gogo.rbs +0 -914
- data/sig/protos/google/protobuf/any.rbs +0 -157
- data/sig/protos/google/protobuf/descriptor.rbs +0 -2825
- data/sig/protos/google/protobuf/duration.rbs +0 -114
- data/sig/protos/google/protobuf/empty.rbs +0 -36
- data/sig/protos/google/protobuf/timestamp.rbs +0 -145
- data/sig/protos/google/protobuf/wrappers.rbs +0 -358
- data/sig/protos/temporal/api/batch/v1/message.rbs +0 -300
- data/sig/protos/temporal/api/command/v1/message.rbs +0 -1399
- data/sig/protos/temporal/api/common/v1/message.rbs +0 -528
- data/sig/protos/temporal/api/enums/v1/batch_operation.rbs +0 -79
- data/sig/protos/temporal/api/enums/v1/command_type.rbs +0 -68
- data/sig/protos/temporal/api/enums/v1/common.rbs +0 -118
- data/sig/protos/temporal/api/enums/v1/event_type.rbs +0 -264
- data/sig/protos/temporal/api/enums/v1/failed_cause.rbs +0 -277
- data/sig/protos/temporal/api/enums/v1/namespace.rbs +0 -108
- data/sig/protos/temporal/api/enums/v1/query.rbs +0 -81
- data/sig/protos/temporal/api/enums/v1/reset.rbs +0 -44
- data/sig/protos/temporal/api/enums/v1/schedule.rbs +0 -72
- data/sig/protos/temporal/api/enums/v1/task_queue.rbs +0 -92
- data/sig/protos/temporal/api/enums/v1/update.rbs +0 -64
- data/sig/protos/temporal/api/enums/v1/workflow.rbs +0 -371
- data/sig/protos/temporal/api/errordetails/v1/message.rbs +0 -551
- data/sig/protos/temporal/api/failure/v1/message.rbs +0 -581
- data/sig/protos/temporal/api/filter/v1/message.rbs +0 -171
- data/sig/protos/temporal/api/history/v1/message.rbs +0 -4609
- data/sig/protos/temporal/api/namespace/v1/message.rbs +0 -410
- data/sig/protos/temporal/api/operatorservice/v1/request_response.rbs +0 -643
- data/sig/protos/temporal/api/operatorservice/v1/service.rbs +0 -17
- data/sig/protos/temporal/api/protocol/v1/message.rbs +0 -84
- data/sig/protos/temporal/api/query/v1/message.rbs +0 -182
- data/sig/protos/temporal/api/replication/v1/message.rbs +0 -148
- data/sig/protos/temporal/api/schedule/v1/message.rbs +0 -1488
- data/sig/protos/temporal/api/sdk/v1/task_complete_metadata.rbs +0 -110
- data/sig/protos/temporal/api/taskqueue/v1/message.rbs +0 -486
- data/sig/protos/temporal/api/testservice/v1/request_response.rbs +0 -249
- data/sig/protos/temporal/api/testservice/v1/service.rbs +0 -15
- data/sig/protos/temporal/api/update/v1/message.rbs +0 -489
- data/sig/protos/temporal/api/version/v1/message.rbs +0 -184
- data/sig/protos/temporal/api/workflow/v1/message.rbs +0 -824
- data/sig/protos/temporal/api/workflowservice/v1/request_response.rbs +0 -7250
- data/sig/protos/temporal/api/workflowservice/v1/service.rbs +0 -22
- data/sig/protos/temporal/sdk/core/activity_result/activity_result.rbs +0 -380
- data/sig/protos/temporal/sdk/core/activity_task/activity_task.rbs +0 -386
- data/sig/protos/temporal/sdk/core/child_workflow/child_workflow.rbs +0 -323
- data/sig/protos/temporal/sdk/core/common/common.rbs +0 -62
- data/sig/protos/temporal/sdk/core/core_interface.rbs +0 -101
- data/sig/protos/temporal/sdk/core/external_data/external_data.rbs +0 -119
- data/sig/protos/temporal/sdk/core/workflow_activation/workflow_activation.rbs +0 -1473
- data/sig/protos/temporal/sdk/core/workflow_commands/workflow_commands.rbs +0 -1784
- data/sig/protos/temporal/sdk/core/workflow_completion/workflow_completion.rbs +0 -180
- data/sig/ruby.rbs +0 -12
- data/sig/temporalio/activity/context.rbs +0 -29
- data/sig/temporalio/activity/info.rbs +0 -43
- data/sig/temporalio/activity.rbs +0 -19
- data/sig/temporalio/bridge/connect_options.rbs +0 -19
- data/sig/temporalio/bridge/error.rbs +0 -8
- data/sig/temporalio/bridge/retry_config.rbs +0 -21
- data/sig/temporalio/bridge/tls_options.rbs +0 -17
- data/sig/temporalio/bridge.rbs +0 -71
- data/sig/temporalio/client/implementation.rbs +0 -38
- data/sig/temporalio/client/workflow_handle.rbs +0 -41
- data/sig/temporalio/client.rbs +0 -35
- data/sig/temporalio/connection/retry_config.rbs +0 -37
- data/sig/temporalio/connection/service.rbs +0 -14
- data/sig/temporalio/connection/test_service.rbs +0 -13
- data/sig/temporalio/connection/tls_options.rbs +0 -43
- data/sig/temporalio/connection/workflow_service.rbs +0 -48
- data/sig/temporalio/connection.rbs +0 -30
- data/sig/temporalio/data_converter.rbs +0 -35
- data/sig/temporalio/error/failure.rbs +0 -121
- data/sig/temporalio/error/workflow_failure.rbs +0 -9
- data/sig/temporalio/errors.rbs +0 -36
- data/sig/temporalio/failure_converter/base.rbs +0 -12
- data/sig/temporalio/failure_converter/basic.rbs +0 -86
- data/sig/temporalio/failure_converter.rbs +0 -5
- data/sig/temporalio/interceptor/activity_inbound.rbs +0 -21
- data/sig/temporalio/interceptor/activity_outbound.rbs +0 -10
- data/sig/temporalio/interceptor/chain.rbs +0 -24
- data/sig/temporalio/interceptor/client.rbs +0 -148
- data/sig/temporalio/interceptor.rbs +0 -6
- data/sig/temporalio/payload_codec/base.rbs +0 -12
- data/sig/temporalio/payload_converter/base.rbs +0 -12
- data/sig/temporalio/payload_converter/bytes.rbs +0 -9
- data/sig/temporalio/payload_converter/composite.rbs +0 -19
- data/sig/temporalio/payload_converter/encoding_base.rbs +0 -14
- data/sig/temporalio/payload_converter/json.rbs +0 -9
- data/sig/temporalio/payload_converter/nil.rbs +0 -9
- data/sig/temporalio/payload_converter.rbs +0 -5
- data/sig/temporalio/retry_policy.rbs +0 -25
- data/sig/temporalio/retry_state.rbs +0 -20
- data/sig/temporalio/runtime.rbs +0 -12
- data/sig/temporalio/testing/time_skipping_handle.rbs +0 -15
- data/sig/temporalio/testing/time_skipping_interceptor.rbs +0 -13
- data/sig/temporalio/testing/workflow_environment.rbs +0 -22
- data/sig/temporalio/testing.rbs +0 -35
- data/sig/temporalio/timeout_type.rbs +0 -15
- data/sig/temporalio/version.rbs +0 -3
- data/sig/temporalio/worker/activity_runner.rbs +0 -35
- data/sig/temporalio/worker/activity_worker.rbs +0 -44
- data/sig/temporalio/worker/reactor.rbs +0 -22
- data/sig/temporalio/worker/runner.rbs +0 -21
- data/sig/temporalio/worker/sync_worker.rbs +0 -23
- data/sig/temporalio/worker/thread_pool_executor.rbs +0 -23
- data/sig/temporalio/worker.rbs +0 -46
- data/sig/temporalio/workflow/async.rbs +0 -9
- data/sig/temporalio/workflow/execution_info.rbs +0 -55
- data/sig/temporalio/workflow/execution_status.rbs +0 -21
- data/sig/temporalio/workflow/future.rbs +0 -40
- data/sig/temporalio/workflow/id_reuse_policy.rbs +0 -15
- data/sig/temporalio/workflow/info.rbs +0 -55
- data/sig/temporalio/workflow/query_reject_condition.rbs +0 -14
- data/sig/temporalio.rbs +0 -2
- data/sig/thermite_patch.rbs +0 -15
@@ -1,1276 +0,0 @@
|
|
1
|
-
//! This module and its submodules implement Core's logic for managing workflows (which is the
|
2
|
-
//! lion's share of the complexity in Core). See the `ARCHITECTURE.md` file in the repo root for
|
3
|
-
//! a diagram of the internals.
|
4
|
-
|
5
|
-
mod bridge;
|
6
|
-
mod driven_workflow;
|
7
|
-
mod history_update;
|
8
|
-
mod machines;
|
9
|
-
mod managed_run;
|
10
|
-
mod run_cache;
|
11
|
-
mod wft_extraction;
|
12
|
-
pub(crate) mod wft_poller;
|
13
|
-
mod workflow_stream;
|
14
|
-
|
15
|
-
#[cfg(feature = "save_wf_inputs")]
|
16
|
-
pub use workflow_stream::replay_wf_state_inputs;
|
17
|
-
|
18
|
-
pub(crate) use bridge::WorkflowBridge;
|
19
|
-
pub(crate) use driven_workflow::{DrivenWorkflow, WorkflowFetcher};
|
20
|
-
pub(crate) use history_update::HistoryUpdate;
|
21
|
-
#[cfg(test)]
|
22
|
-
pub(crate) use managed_run::ManagedWFFunc;
|
23
|
-
|
24
|
-
use crate::worker::activities::TrackedPermittedTqResp;
|
25
|
-
use crate::{
|
26
|
-
abstractions::{
|
27
|
-
stream_when_allowed, MeteredSemaphore, TrackedOwnedMeteredSemPermit, UsedMeteredSemPermit,
|
28
|
-
},
|
29
|
-
internal_flags::InternalFlags,
|
30
|
-
protosext::{legacy_query_failure, ValidPollWFTQResponse},
|
31
|
-
telemetry::{
|
32
|
-
metrics::workflow_worker_type, set_trace_subscriber_for_current_thread, TelemetryInstance,
|
33
|
-
VecDisplayer,
|
34
|
-
},
|
35
|
-
worker::{
|
36
|
-
activities::{ActivitiesFromWFTsHandle, LocalActivityManager},
|
37
|
-
client::{WorkerClient, WorkflowTaskCompletion},
|
38
|
-
workflow::{
|
39
|
-
history_update::HistoryPaginator,
|
40
|
-
managed_run::RunUpdateAct,
|
41
|
-
wft_extraction::{HistoryFetchReq, WFTExtractor},
|
42
|
-
wft_poller::validate_wft,
|
43
|
-
workflow_stream::{LocalInput, LocalInputs, WFStream},
|
44
|
-
},
|
45
|
-
LocalActRequest, LocalActivityExecutionResult, LocalActivityResolution,
|
46
|
-
},
|
47
|
-
MetricsContext,
|
48
|
-
};
|
49
|
-
use anyhow::anyhow;
|
50
|
-
use futures::{stream::BoxStream, Stream, StreamExt};
|
51
|
-
use futures_util::{future::abortable, stream};
|
52
|
-
use prost_types::TimestampError;
|
53
|
-
use std::{
|
54
|
-
cell::RefCell,
|
55
|
-
collections::VecDeque,
|
56
|
-
fmt::Debug,
|
57
|
-
future::Future,
|
58
|
-
ops::DerefMut,
|
59
|
-
rc::Rc,
|
60
|
-
result,
|
61
|
-
sync::Arc,
|
62
|
-
thread,
|
63
|
-
time::{Duration, Instant},
|
64
|
-
};
|
65
|
-
use temporal_sdk_core_api::errors::{CompleteWfError, PollWfError};
|
66
|
-
use temporal_sdk_core_protos::{
|
67
|
-
coresdk::{
|
68
|
-
workflow_activation::{
|
69
|
-
remove_from_cache::EvictionReason, workflow_activation_job, QueryWorkflow,
|
70
|
-
WorkflowActivation, WorkflowActivationJob,
|
71
|
-
},
|
72
|
-
workflow_commands::*,
|
73
|
-
workflow_completion,
|
74
|
-
workflow_completion::{
|
75
|
-
workflow_activation_completion, Failure, WorkflowActivationCompletion,
|
76
|
-
},
|
77
|
-
},
|
78
|
-
temporal::api::{
|
79
|
-
command::v1::{command::Attributes, Command as ProtoCommand, Command},
|
80
|
-
common::v1::{Memo, MeteringMetadata, RetryPolicy, SearchAttributes, WorkflowExecution},
|
81
|
-
enums::v1::WorkflowTaskFailedCause,
|
82
|
-
query::v1::WorkflowQuery,
|
83
|
-
sdk::v1::WorkflowTaskCompletedMetadata,
|
84
|
-
taskqueue::v1::StickyExecutionAttributes,
|
85
|
-
workflowservice::v1::{get_system_info_response, PollActivityTaskQueueResponse},
|
86
|
-
},
|
87
|
-
TaskToken,
|
88
|
-
};
|
89
|
-
use tokio::{
|
90
|
-
sync::{
|
91
|
-
mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
|
92
|
-
oneshot,
|
93
|
-
},
|
94
|
-
task::{spawn_blocking, LocalSet},
|
95
|
-
};
|
96
|
-
use tokio_stream::wrappers::UnboundedReceiverStream;
|
97
|
-
use tokio_util::sync::CancellationToken;
|
98
|
-
use tracing::Span;
|
99
|
-
|
100
|
-
pub(crate) const LEGACY_QUERY_ID: &str = "legacy_query";
|
101
|
-
/// What percentage of a WFT timeout we are willing to wait before sending a WFT heartbeat when
|
102
|
-
/// necessary.
|
103
|
-
const WFT_HEARTBEAT_TIMEOUT_FRACTION: f32 = 0.8;
|
104
|
-
const MAX_EAGER_ACTIVITY_RESERVATIONS_PER_WORKFLOW_TASK: usize = 3;
|
105
|
-
|
106
|
-
type Result<T, E = WFMachinesError> = result::Result<T, E>;
|
107
|
-
type BoxedActivationStream = BoxStream<'static, Result<ActivationOrAuto, PollWfError>>;
|
108
|
-
type InternalFlagsRef = Rc<RefCell<InternalFlags>>;
|
109
|
-
|
110
|
-
/// Centralizes all state related to workflows and workflow tasks
|
111
|
-
pub(crate) struct Workflows {
|
112
|
-
task_queue: String,
|
113
|
-
local_tx: UnboundedSender<LocalInput>,
|
114
|
-
processing_task: tokio::sync::Mutex<Option<thread::JoinHandle<()>>>,
|
115
|
-
activation_stream: tokio::sync::Mutex<(
|
116
|
-
BoxedActivationStream,
|
117
|
-
// Used to indicate polling may begin
|
118
|
-
Option<oneshot::Sender<()>>,
|
119
|
-
)>,
|
120
|
-
client: Arc<dyn WorkerClient>,
|
121
|
-
/// Will be populated when this worker is using a cache and should complete WFTs with a sticky
|
122
|
-
/// queue.
|
123
|
-
sticky_attrs: Option<StickyExecutionAttributes>,
|
124
|
-
/// If set, can be used to reserve activity task slots for eager-return of new activity tasks.
|
125
|
-
activity_tasks_handle: Option<ActivitiesFromWFTsHandle>,
|
126
|
-
/// Ensures we stay at or below this worker's maximum concurrent workflow task limit
|
127
|
-
wft_semaphore: MeteredSemaphore,
|
128
|
-
local_act_mgr: Arc<LocalActivityManager>,
|
129
|
-
}
|
130
|
-
|
131
|
-
pub(crate) struct WorkflowBasics {
|
132
|
-
pub max_cached_workflows: usize,
|
133
|
-
pub max_outstanding_wfts: usize,
|
134
|
-
pub shutdown_token: CancellationToken,
|
135
|
-
pub metrics: MetricsContext,
|
136
|
-
pub namespace: String,
|
137
|
-
pub task_queue: String,
|
138
|
-
pub ignore_evicts_on_shutdown: bool,
|
139
|
-
pub fetching_concurrency: usize,
|
140
|
-
pub server_capabilities: get_system_info_response::Capabilities,
|
141
|
-
#[cfg(feature = "save_wf_inputs")]
|
142
|
-
pub wf_state_inputs: Option<UnboundedSender<Vec<u8>>>,
|
143
|
-
}
|
144
|
-
|
145
|
-
pub(crate) struct RunBasics<'a> {
|
146
|
-
pub namespace: String,
|
147
|
-
pub workflow_id: String,
|
148
|
-
pub workflow_type: String,
|
149
|
-
pub run_id: String,
|
150
|
-
pub history: HistoryUpdate,
|
151
|
-
pub metrics: MetricsContext,
|
152
|
-
pub capabilities: &'a get_system_info_response::Capabilities,
|
153
|
-
}
|
154
|
-
|
155
|
-
impl Workflows {
|
156
|
-
#[allow(clippy::too_many_arguments)] // Not much worth combining here
|
157
|
-
pub(super) fn new(
|
158
|
-
basics: WorkflowBasics,
|
159
|
-
sticky_attrs: Option<StickyExecutionAttributes>,
|
160
|
-
client: Arc<dyn WorkerClient>,
|
161
|
-
wft_stream: impl Stream<Item = Result<ValidPollWFTQResponse, tonic::Status>> + Send + 'static,
|
162
|
-
local_activity_request_sink: impl LocalActivityRequestSink,
|
163
|
-
local_act_mgr: Arc<LocalActivityManager>,
|
164
|
-
heartbeat_timeout_rx: UnboundedReceiver<HeartbeatTimeoutMsg>,
|
165
|
-
activity_tasks_handle: Option<ActivitiesFromWFTsHandle>,
|
166
|
-
telem_instance: Option<&TelemetryInstance>,
|
167
|
-
) -> Self {
|
168
|
-
let (local_tx, local_rx) = unbounded_channel();
|
169
|
-
let (fetch_tx, fetch_rx) = unbounded_channel();
|
170
|
-
let shutdown_tok = basics.shutdown_token.clone();
|
171
|
-
let task_queue = basics.task_queue.clone();
|
172
|
-
let wft_semaphore = MeteredSemaphore::new(
|
173
|
-
basics.max_outstanding_wfts,
|
174
|
-
basics.metrics.with_new_attrs([workflow_worker_type()]),
|
175
|
-
MetricsContext::available_task_slots,
|
176
|
-
);
|
177
|
-
// Only allow polling of the new WFT stream if there are available task slots
|
178
|
-
let proceeder = stream::unfold(wft_semaphore.clone(), |sem| async move {
|
179
|
-
Some((sem.acquire_owned().await.unwrap(), sem))
|
180
|
-
});
|
181
|
-
let wft_stream = stream_when_allowed(wft_stream, proceeder);
|
182
|
-
let extracted_wft_stream = WFTExtractor::build(
|
183
|
-
client.clone(),
|
184
|
-
basics.fetching_concurrency,
|
185
|
-
wft_stream,
|
186
|
-
UnboundedReceiverStream::new(fetch_rx),
|
187
|
-
);
|
188
|
-
let locals_stream = stream::select(
|
189
|
-
UnboundedReceiverStream::new(local_rx),
|
190
|
-
UnboundedReceiverStream::new(heartbeat_timeout_rx).map(Into::into),
|
191
|
-
);
|
192
|
-
let (activation_tx, activation_rx) = unbounded_channel();
|
193
|
-
let (start_polling_tx, start_polling_rx) = oneshot::channel();
|
194
|
-
// We must spawn a task to constantly poll the activation stream, because otherwise
|
195
|
-
// activation completions would not cause anything to happen until the next poll.
|
196
|
-
let tracing_sub = telem_instance.map(|ti| ti.trace_subscriber());
|
197
|
-
let processing_task = thread::spawn(move || {
|
198
|
-
if let Some(ts) = tracing_sub {
|
199
|
-
set_trace_subscriber_for_current_thread(ts);
|
200
|
-
}
|
201
|
-
let rt = tokio::runtime::Builder::new_current_thread()
|
202
|
-
.enable_all()
|
203
|
-
.thread_name("workflow-processing")
|
204
|
-
.build()
|
205
|
-
.unwrap();
|
206
|
-
let local = LocalSet::new();
|
207
|
-
local.block_on(&rt, async move {
|
208
|
-
let mut stream = WFStream::build(
|
209
|
-
basics,
|
210
|
-
extracted_wft_stream,
|
211
|
-
locals_stream,
|
212
|
-
local_activity_request_sink,
|
213
|
-
);
|
214
|
-
|
215
|
-
// However, we want to avoid plowing ahead until we've been asked to poll at least
|
216
|
-
// once. This supports activity-only workers.
|
217
|
-
let do_poll = tokio::select! {
|
218
|
-
sp = start_polling_rx => {
|
219
|
-
sp.is_ok()
|
220
|
-
}
|
221
|
-
_ = shutdown_tok.cancelled() => {
|
222
|
-
false
|
223
|
-
}
|
224
|
-
};
|
225
|
-
if !do_poll {
|
226
|
-
return;
|
227
|
-
}
|
228
|
-
while let Some(output) = stream.next().await {
|
229
|
-
match output {
|
230
|
-
Ok(o) => {
|
231
|
-
for fetchreq in o.fetch_histories {
|
232
|
-
fetch_tx
|
233
|
-
.send(fetchreq)
|
234
|
-
.expect("Fetch channel must not be dropped");
|
235
|
-
}
|
236
|
-
for act in o.activations {
|
237
|
-
activation_tx
|
238
|
-
.send(Ok(act))
|
239
|
-
.expect("Activation processor channel not dropped");
|
240
|
-
}
|
241
|
-
}
|
242
|
-
Err(e) => activation_tx
|
243
|
-
.send(Err(e))
|
244
|
-
.expect("Activation processor channel not dropped"),
|
245
|
-
}
|
246
|
-
}
|
247
|
-
});
|
248
|
-
});
|
249
|
-
Self {
|
250
|
-
task_queue,
|
251
|
-
local_tx,
|
252
|
-
processing_task: tokio::sync::Mutex::new(Some(processing_task)),
|
253
|
-
activation_stream: tokio::sync::Mutex::new((
|
254
|
-
UnboundedReceiverStream::new(activation_rx).boxed(),
|
255
|
-
Some(start_polling_tx),
|
256
|
-
)),
|
257
|
-
client,
|
258
|
-
sticky_attrs,
|
259
|
-
activity_tasks_handle,
|
260
|
-
wft_semaphore,
|
261
|
-
local_act_mgr,
|
262
|
-
}
|
263
|
-
}
|
264
|
-
|
265
|
-
pub(super) async fn next_workflow_activation(&self) -> Result<WorkflowActivation, PollWfError> {
|
266
|
-
loop {
|
267
|
-
let al = {
|
268
|
-
let mut lock = self.activation_stream.lock().await;
|
269
|
-
let (ref mut stream, ref mut beginner) = lock.deref_mut();
|
270
|
-
if let Some(beginner) = beginner.take() {
|
271
|
-
let _ = beginner.send(());
|
272
|
-
}
|
273
|
-
stream.next().await.unwrap_or(Err(PollWfError::ShutDown))?
|
274
|
-
};
|
275
|
-
Span::current().record("run_id", al.run_id());
|
276
|
-
match al {
|
277
|
-
ActivationOrAuto::LangActivation(act) | ActivationOrAuto::ReadyForQueries(act) => {
|
278
|
-
debug!(activation=%act, "Sending activation to lang");
|
279
|
-
break Ok(act);
|
280
|
-
}
|
281
|
-
ActivationOrAuto::Autocomplete { run_id } => {
|
282
|
-
self.activation_completed(
|
283
|
-
WorkflowActivationCompletion {
|
284
|
-
run_id,
|
285
|
-
status: Some(
|
286
|
-
workflow_completion::Success::from_variants(vec![]).into(),
|
287
|
-
),
|
288
|
-
},
|
289
|
-
// We need to say a type, but the type is irrelevant, so imagine some
|
290
|
-
// boxed function we'll never call.
|
291
|
-
Option::<Box<dyn Fn(&str, usize) + Send>>::None,
|
292
|
-
)
|
293
|
-
.await?;
|
294
|
-
}
|
295
|
-
ActivationOrAuto::AutoFail {
|
296
|
-
run_id,
|
297
|
-
machines_err,
|
298
|
-
} => {
|
299
|
-
self.activation_completed(
|
300
|
-
WorkflowActivationCompletion {
|
301
|
-
run_id,
|
302
|
-
status: Some(auto_fail_to_complete_status(machines_err)),
|
303
|
-
},
|
304
|
-
Option::<Box<dyn Fn(&str, usize) + Send>>::None,
|
305
|
-
)
|
306
|
-
.await?;
|
307
|
-
}
|
308
|
-
}
|
309
|
-
}
|
310
|
-
}
|
311
|
-
|
312
|
-
/// Queue an activation completion for processing, returning a future that will resolve with
|
313
|
-
/// the outcome of that completion. See [ActivationCompletedOutcome].
|
314
|
-
///
|
315
|
-
/// Returns the most-recently-processed event number for the run.
|
316
|
-
pub(super) async fn activation_completed(
|
317
|
-
&self,
|
318
|
-
completion: WorkflowActivationCompletion,
|
319
|
-
post_activate_hook: Option<impl Fn(&str, usize)>,
|
320
|
-
) -> Result<usize, CompleteWfError> {
|
321
|
-
let is_empty_completion = completion.is_empty();
|
322
|
-
let completion = validate_completion(completion)?;
|
323
|
-
let run_id = completion.run_id().to_string();
|
324
|
-
let (tx, rx) = oneshot::channel();
|
325
|
-
let was_sent = self.send_local(WFActCompleteMsg {
|
326
|
-
completion,
|
327
|
-
response_tx: Some(tx),
|
328
|
-
});
|
329
|
-
if !was_sent {
|
330
|
-
if is_empty_completion {
|
331
|
-
// Empty complete which is likely an evict reply, we can just ignore.
|
332
|
-
return Ok(0);
|
333
|
-
}
|
334
|
-
panic!(
|
335
|
-
"A non-empty completion was not processed. Workflow processing may have \
|
336
|
-
terminated unexpectedly. This is a bug."
|
337
|
-
);
|
338
|
-
}
|
339
|
-
|
340
|
-
let completion_outcome = rx
|
341
|
-
.await
|
342
|
-
.expect("Send half of activation complete response not dropped");
|
343
|
-
let mut wft_from_complete = None;
|
344
|
-
let wft_report_status = match completion_outcome.outcome {
|
345
|
-
ActivationCompleteOutcome::ReportWFTSuccess(report) => match report {
|
346
|
-
ServerCommandsWithWorkflowInfo {
|
347
|
-
task_token,
|
348
|
-
action:
|
349
|
-
ActivationAction::WftComplete {
|
350
|
-
mut commands,
|
351
|
-
query_responses,
|
352
|
-
force_new_wft,
|
353
|
-
sdk_metadata,
|
354
|
-
},
|
355
|
-
} => {
|
356
|
-
let reserved_act_permits =
|
357
|
-
self.reserve_activity_slots_for_outgoing_commands(commands.as_mut_slice());
|
358
|
-
debug!(commands=%commands.display(), query_responses=%query_responses.display(),
|
359
|
-
force_new_wft, "Sending responses to server");
|
360
|
-
let mut completion = WorkflowTaskCompletion {
|
361
|
-
task_token,
|
362
|
-
commands,
|
363
|
-
query_responses,
|
364
|
-
sticky_attributes: None,
|
365
|
-
return_new_workflow_task: true,
|
366
|
-
force_create_new_workflow_task: force_new_wft,
|
367
|
-
sdk_metadata,
|
368
|
-
metering_metadata: MeteringMetadata {
|
369
|
-
nonfirst_local_activity_execution_attempts: self
|
370
|
-
.local_act_mgr
|
371
|
-
.get_nonfirst_attempt_count(&run_id)
|
372
|
-
as u32,
|
373
|
-
},
|
374
|
-
};
|
375
|
-
let sticky_attrs = self.sticky_attrs.clone();
|
376
|
-
// Do not return new WFT if we would not cache, because returned new WFTs are
|
377
|
-
// always partial.
|
378
|
-
if sticky_attrs.is_none() {
|
379
|
-
completion.return_new_workflow_task = false;
|
380
|
-
}
|
381
|
-
completion.sticky_attributes = sticky_attrs;
|
382
|
-
|
383
|
-
self.handle_wft_reporting_errs(&run_id, || async {
|
384
|
-
let maybe_wft = self.client.complete_workflow_task(completion).await?;
|
385
|
-
if let Some(wft) = maybe_wft.workflow_task {
|
386
|
-
wft_from_complete = Some(validate_wft(wft)?);
|
387
|
-
}
|
388
|
-
self.handle_eager_activities(
|
389
|
-
reserved_act_permits,
|
390
|
-
maybe_wft.activity_tasks,
|
391
|
-
);
|
392
|
-
Ok(())
|
393
|
-
})
|
394
|
-
.await;
|
395
|
-
WFTReportStatus::Reported
|
396
|
-
}
|
397
|
-
ServerCommandsWithWorkflowInfo {
|
398
|
-
task_token,
|
399
|
-
action: ActivationAction::RespondLegacyQuery { result },
|
400
|
-
} => {
|
401
|
-
self.respond_legacy_query(task_token, *result).await;
|
402
|
-
WFTReportStatus::Reported
|
403
|
-
}
|
404
|
-
},
|
405
|
-
ActivationCompleteOutcome::ReportWFTFail(outcome) => match outcome {
|
406
|
-
FailedActivationWFTReport::Report(tt, cause, failure) => {
|
407
|
-
warn!(run_id=%run_id, failure=?failure, "Failing workflow task");
|
408
|
-
self.handle_wft_reporting_errs(&run_id, || async {
|
409
|
-
self.client
|
410
|
-
.fail_workflow_task(tt, cause, failure.failure.map(Into::into))
|
411
|
-
.await
|
412
|
-
})
|
413
|
-
.await;
|
414
|
-
WFTReportStatus::Reported
|
415
|
-
}
|
416
|
-
FailedActivationWFTReport::ReportLegacyQueryFailure(task_token, failure) => {
|
417
|
-
warn!(run_id=%run_id, failure=?failure, "Failing legacy query request");
|
418
|
-
self.respond_legacy_query(task_token, legacy_query_failure(failure))
|
419
|
-
.await;
|
420
|
-
WFTReportStatus::Reported
|
421
|
-
}
|
422
|
-
},
|
423
|
-
ActivationCompleteOutcome::WFTFailedDontReport => WFTReportStatus::DropWft,
|
424
|
-
ActivationCompleteOutcome::DoNothing => WFTReportStatus::NotReported,
|
425
|
-
};
|
426
|
-
|
427
|
-
let maybe_pwft = if let Some(wft) = wft_from_complete {
|
428
|
-
match HistoryPaginator::from_poll(wft, self.client.clone()).await {
|
429
|
-
Ok((paginator, pwft)) => Some((pwft, paginator)),
|
430
|
-
Err(e) => {
|
431
|
-
self.request_eviction(
|
432
|
-
&run_id,
|
433
|
-
format!("Failed to paginate workflow task from completion: {e:?}"),
|
434
|
-
EvictionReason::Fatal,
|
435
|
-
);
|
436
|
-
None
|
437
|
-
}
|
438
|
-
}
|
439
|
-
} else {
|
440
|
-
None
|
441
|
-
};
|
442
|
-
|
443
|
-
if let Some(h) = post_activate_hook {
|
444
|
-
h(&run_id, completion_outcome.most_recently_processed_event);
|
445
|
-
}
|
446
|
-
|
447
|
-
self.post_activation(PostActivationMsg {
|
448
|
-
run_id,
|
449
|
-
wft_report_status,
|
450
|
-
wft_from_complete: maybe_pwft,
|
451
|
-
});
|
452
|
-
|
453
|
-
Ok(completion_outcome.most_recently_processed_event)
|
454
|
-
}
|
455
|
-
|
456
|
-
/// Tell workflow that a local activity has finished with the provided result
|
457
|
-
pub(super) fn notify_of_local_result(
|
458
|
-
&self,
|
459
|
-
run_id: impl Into<String>,
|
460
|
-
resolved: LocalResolution,
|
461
|
-
) {
|
462
|
-
self.send_local(LocalResolutionMsg {
|
463
|
-
run_id: run_id.into(),
|
464
|
-
res: resolved,
|
465
|
-
});
|
466
|
-
}
|
467
|
-
|
468
|
-
/// Request eviction of a workflow
|
469
|
-
pub(super) fn request_eviction(
|
470
|
-
&self,
|
471
|
-
run_id: impl Into<String>,
|
472
|
-
message: impl Into<String>,
|
473
|
-
reason: EvictionReason,
|
474
|
-
) {
|
475
|
-
self.send_local(RequestEvictMsg {
|
476
|
-
run_id: run_id.into(),
|
477
|
-
message: message.into(),
|
478
|
-
reason,
|
479
|
-
});
|
480
|
-
}
|
481
|
-
|
482
|
-
/// Query the state of workflow management. Can return `None` if workflow state is shut down.
|
483
|
-
pub(super) fn get_state_info(&self) -> impl Future<Output = Option<WorkflowStateInfo>> {
|
484
|
-
let (tx, rx) = oneshot::channel();
|
485
|
-
self.send_local(GetStateInfoMsg { response_tx: tx });
|
486
|
-
async move { rx.await.ok() }
|
487
|
-
}
|
488
|
-
|
489
|
-
pub(super) fn available_wft_permits(&self) -> usize {
|
490
|
-
self.wft_semaphore.available_permits()
|
491
|
-
}
|
492
|
-
|
493
|
-
pub(super) async fn shutdown(&self) -> Result<(), anyhow::Error> {
|
494
|
-
let maybe_jh = self.processing_task.lock().await.take();
|
495
|
-
if let Some(jh) = maybe_jh {
|
496
|
-
// This serves to drive the stream if it is still alive and wouldn't otherwise receive
|
497
|
-
// another message. It allows it to shut itself down.
|
498
|
-
let (waker, stop_waker) = abortable(async {
|
499
|
-
let mut interval = tokio::time::interval(Duration::from_millis(10));
|
500
|
-
loop {
|
501
|
-
interval.tick().await;
|
502
|
-
let _ = self.get_state_info().await;
|
503
|
-
}
|
504
|
-
});
|
505
|
-
let (_, jh_res) = tokio::join!(
|
506
|
-
waker,
|
507
|
-
spawn_blocking(move || {
|
508
|
-
let r = jh.join();
|
509
|
-
stop_waker.abort();
|
510
|
-
r
|
511
|
-
})
|
512
|
-
);
|
513
|
-
jh_res?.map_err(|e| anyhow!("Error joining workflow processing thread: {e:?}"))?;
|
514
|
-
}
|
515
|
-
Ok(())
|
516
|
-
}
|
517
|
-
|
518
|
-
/// Must be called after every activation completion has finished
|
519
|
-
fn post_activation(&self, msg: PostActivationMsg) {
|
520
|
-
self.send_local(msg);
|
521
|
-
}
|
522
|
-
|
523
|
-
/// Handle server errors from either completing or failing a workflow task. Un-handleable errors
|
524
|
-
/// trigger a workflow eviction and are logged.
|
525
|
-
async fn handle_wft_reporting_errs<T, Fut>(&self, run_id: &str, completer: impl FnOnce() -> Fut)
|
526
|
-
where
|
527
|
-
Fut: Future<Output = Result<T, tonic::Status>>,
|
528
|
-
{
|
529
|
-
let mut should_evict = None;
|
530
|
-
if let Err(err) = completer().await {
|
531
|
-
match err.code() {
|
532
|
-
// Silence unhandled command errors since the lang SDK cannot do anything
|
533
|
-
// about them besides poll again, which it will do anyway.
|
534
|
-
tonic::Code::InvalidArgument if err.message() == "UnhandledCommand" => {
|
535
|
-
debug!(error = %err, run_id, "Unhandled command response when completing");
|
536
|
-
should_evict = Some(EvictionReason::UnhandledCommand);
|
537
|
-
}
|
538
|
-
tonic::Code::NotFound => {
|
539
|
-
warn!(error = %err, run_id, "Task not found when completing");
|
540
|
-
should_evict = Some(EvictionReason::TaskNotFound);
|
541
|
-
}
|
542
|
-
_ => {
|
543
|
-
warn!(error= %err, "Network error while completing workflow activation");
|
544
|
-
should_evict = Some(EvictionReason::Fatal);
|
545
|
-
}
|
546
|
-
}
|
547
|
-
}
|
548
|
-
if let Some(reason) = should_evict {
|
549
|
-
self.request_eviction(run_id, "Error reporting WFT to server", reason);
|
550
|
-
}
|
551
|
-
}
|
552
|
-
|
553
|
-
/// Sends a message to the workflow processing stream. Returns true if the message was sent
|
554
|
-
/// successfully.
|
555
|
-
fn send_local(&self, msg: impl Into<LocalInputs>) -> bool {
|
556
|
-
let msg = msg.into();
|
557
|
-
let print_err = match &msg {
|
558
|
-
LocalInputs::GetStateInfo(_) => false,
|
559
|
-
LocalInputs::LocalResolution(lr) if lr.res.is_la_cancel_confirmation() => false,
|
560
|
-
_ => true,
|
561
|
-
};
|
562
|
-
if let Err(e) = self.local_tx.send(LocalInput {
|
563
|
-
input: msg,
|
564
|
-
span: Span::current(),
|
565
|
-
}) {
|
566
|
-
if print_err {
|
567
|
-
warn!(
|
568
|
-
"Tried to interact with workflow state after it shut down. This may be benign \
|
569
|
-
when processing evictions during shutdown. When sending {:?}",
|
570
|
-
e.0.input
|
571
|
-
)
|
572
|
-
}
|
573
|
-
false
|
574
|
-
} else {
|
575
|
-
true
|
576
|
-
}
|
577
|
-
}
|
578
|
-
|
579
|
-
/// Process eagerly returned activities from WFT completion
|
580
|
-
fn handle_eager_activities(
|
581
|
-
&self,
|
582
|
-
reserved_act_permits: Vec<TrackedOwnedMeteredSemPermit>,
|
583
|
-
eager_acts: Vec<PollActivityTaskQueueResponse>,
|
584
|
-
) {
|
585
|
-
if let Some(at_handle) = self.activity_tasks_handle.as_ref() {
|
586
|
-
let excess_reserved = reserved_act_permits.len().saturating_sub(eager_acts.len());
|
587
|
-
if excess_reserved > 0 {
|
588
|
-
debug!(
|
589
|
-
"Server returned {excess_reserved} fewer activities for \
|
590
|
-
eager execution than we requested"
|
591
|
-
);
|
592
|
-
} else if eager_acts.len() > reserved_act_permits.len() {
|
593
|
-
// If we somehow got more activities from server than we asked for, server did
|
594
|
-
// something wrong.
|
595
|
-
error!(
|
596
|
-
"Server sent more activities for eager execution than we requested! They will \
|
597
|
-
be dropped and eventually time out. Please report this, as it is a server bug."
|
598
|
-
)
|
599
|
-
}
|
600
|
-
let with_permits = reserved_act_permits
|
601
|
-
.into_iter()
|
602
|
-
.zip(eager_acts.into_iter())
|
603
|
-
.map(|(permit, resp)| TrackedPermittedTqResp { permit, resp });
|
604
|
-
if with_permits.len() > 0 {
|
605
|
-
debug!(
|
606
|
-
"Adding {} activity tasks received from WFT complete",
|
607
|
-
with_permits.len()
|
608
|
-
);
|
609
|
-
at_handle.add_tasks(with_permits);
|
610
|
-
}
|
611
|
-
} else if !eager_acts.is_empty() {
|
612
|
-
panic!(
|
613
|
-
"Requested eager activity execution but this worker has no activity task \
|
614
|
-
manager! This is an internal bug, Core should not have asked for tasks."
|
615
|
-
)
|
616
|
-
}
|
617
|
-
}
|
618
|
-
|
619
|
-
/// Attempt to reserve activity slots for activities we could eagerly execute on
|
620
|
-
/// this worker.
|
621
|
-
///
|
622
|
-
/// Returns the number of activity slots that were reserved
|
623
|
-
fn reserve_activity_slots_for_outgoing_commands(
|
624
|
-
&self,
|
625
|
-
commands: &mut [Command],
|
626
|
-
) -> Vec<TrackedOwnedMeteredSemPermit> {
|
627
|
-
let mut reserved = vec![];
|
628
|
-
for cmd in commands {
|
629
|
-
if let Some(Attributes::ScheduleActivityTaskCommandAttributes(attrs)) =
|
630
|
-
cmd.attributes.as_mut()
|
631
|
-
{
|
632
|
-
// If request_eager_execution was already false, that means lang explicitly
|
633
|
-
// told us it didn't want to eagerly execute for some reason. So, we only
|
634
|
-
// ever turn *off* eager execution if a slot is not available or the activity
|
635
|
-
// is scheduled on a different task queue.
|
636
|
-
if attrs.request_eager_execution {
|
637
|
-
let same_task_queue = attrs
|
638
|
-
.task_queue
|
639
|
-
.as_ref()
|
640
|
-
.map(|q| q.name == self.task_queue)
|
641
|
-
.unwrap_or_default();
|
642
|
-
if same_task_queue
|
643
|
-
&& reserved.len() < MAX_EAGER_ACTIVITY_RESERVATIONS_PER_WORKFLOW_TASK
|
644
|
-
{
|
645
|
-
if let Some(p) = self
|
646
|
-
.activity_tasks_handle
|
647
|
-
.as_ref()
|
648
|
-
.and_then(|h| h.reserve_slot())
|
649
|
-
{
|
650
|
-
reserved.push(p);
|
651
|
-
} else {
|
652
|
-
attrs.request_eager_execution = false;
|
653
|
-
}
|
654
|
-
} else {
|
655
|
-
attrs.request_eager_execution = false;
|
656
|
-
}
|
657
|
-
}
|
658
|
-
}
|
659
|
-
}
|
660
|
-
reserved
|
661
|
-
}
|
662
|
-
|
663
|
-
/// Wraps responding to legacy queries. Handles ignore-able failures.
|
664
|
-
async fn respond_legacy_query(&self, tt: TaskToken, res: QueryResult) {
|
665
|
-
match self.client.respond_legacy_query(tt, res).await {
|
666
|
-
Ok(_) => {}
|
667
|
-
Err(e) if e.code() == tonic::Code::NotFound => {
|
668
|
-
warn!(error=?e, "Query not found when attempting to respond to it");
|
669
|
-
}
|
670
|
-
Err(e) => {
|
671
|
-
warn!(error= %e, "Network error while responding to legacy query");
|
672
|
-
}
|
673
|
-
}
|
674
|
-
}
|
675
|
-
}
|
676
|
-
|
677
|
-
/// Returned when a cache miss happens and we need to fetch history from the beginning to
|
678
|
-
/// replay a run
|
679
|
-
#[derive(Debug, derive_more::Display)]
|
680
|
-
#[display(
|
681
|
-
fmt = "CacheMissFetchReq(run_id: {})",
|
682
|
-
"original_wft.work.execution.run_id"
|
683
|
-
)]
|
684
|
-
#[must_use]
|
685
|
-
struct CacheMissFetchReq {
|
686
|
-
original_wft: PermittedWFT,
|
687
|
-
}
|
688
|
-
/// Bubbled up from inside workflow state if we're trying to apply the next workflow task but it
|
689
|
-
/// isn't in memory
|
690
|
-
#[derive(Debug)]
|
691
|
-
#[must_use]
|
692
|
-
struct NextPageReq {
|
693
|
-
paginator: HistoryPaginator,
|
694
|
-
span: Span,
|
695
|
-
}
|
696
|
-
|
697
|
-
#[derive(Debug)]
|
698
|
-
struct WFStreamOutput {
|
699
|
-
activations: VecDeque<ActivationOrAuto>,
|
700
|
-
fetch_histories: VecDeque<HistoryFetchReq>,
|
701
|
-
}
|
702
|
-
|
703
|
-
#[derive(Debug, derive_more::Display)]
|
704
|
-
enum ActivationOrAuto {
|
705
|
-
LangActivation(WorkflowActivation),
|
706
|
-
/// This type should only be filled with an empty activation which is ready to have queries
|
707
|
-
/// inserted into the joblist
|
708
|
-
ReadyForQueries(WorkflowActivation),
|
709
|
-
#[display(fmt = "Autocomplete(run_id={run_id})")]
|
710
|
-
Autocomplete {
|
711
|
-
run_id: String,
|
712
|
-
},
|
713
|
-
#[display(fmt = "AutoFail(run_id={run_id})")]
|
714
|
-
AutoFail {
|
715
|
-
run_id: String,
|
716
|
-
machines_err: WFMachinesError,
|
717
|
-
},
|
718
|
-
}
|
719
|
-
impl ActivationOrAuto {
|
720
|
-
pub fn run_id(&self) -> &str {
|
721
|
-
match self {
|
722
|
-
ActivationOrAuto::LangActivation(act) => &act.run_id,
|
723
|
-
ActivationOrAuto::Autocomplete { run_id, .. } => run_id,
|
724
|
-
ActivationOrAuto::ReadyForQueries(act) => &act.run_id,
|
725
|
-
ActivationOrAuto::AutoFail { run_id, .. } => run_id,
|
726
|
-
}
|
727
|
-
}
|
728
|
-
}
|
729
|
-
|
730
|
-
/// A processed WFT which has been validated and had a history update extracted from it
|
731
|
-
#[derive(derive_more::DebugCustom)]
|
732
|
-
#[cfg_attr(
|
733
|
-
feature = "save_wf_inputs",
|
734
|
-
derive(serde::Serialize, serde::Deserialize)
|
735
|
-
)]
|
736
|
-
#[debug(fmt = "PermittedWft({work:?})")]
|
737
|
-
pub(crate) struct PermittedWFT {
|
738
|
-
work: PreparedWFT,
|
739
|
-
#[cfg_attr(
|
740
|
-
feature = "save_wf_inputs",
|
741
|
-
serde(skip, default = "UsedMeteredSemPermit::fake_deserialized")
|
742
|
-
)]
|
743
|
-
permit: UsedMeteredSemPermit,
|
744
|
-
#[cfg_attr(
|
745
|
-
feature = "save_wf_inputs",
|
746
|
-
serde(skip, default = "HistoryPaginator::fake_deserialized")
|
747
|
-
)]
|
748
|
-
paginator: HistoryPaginator,
|
749
|
-
}
|
750
|
-
#[derive(Debug)]
|
751
|
-
#[cfg_attr(
|
752
|
-
feature = "save_wf_inputs",
|
753
|
-
derive(serde::Serialize, serde::Deserialize)
|
754
|
-
)]
|
755
|
-
struct PreparedWFT {
|
756
|
-
task_token: TaskToken,
|
757
|
-
attempt: u32,
|
758
|
-
execution: WorkflowExecution,
|
759
|
-
workflow_type: String,
|
760
|
-
legacy_query: Option<WorkflowQuery>,
|
761
|
-
query_requests: Vec<QueryWorkflow>,
|
762
|
-
update: HistoryUpdate,
|
763
|
-
}
|
764
|
-
impl PreparedWFT {
|
765
|
-
/// Returns true if the contained history update is incremental (IE: expects to hit a cached
|
766
|
-
/// workflow)
|
767
|
-
pub fn is_incremental(&self) -> bool {
|
768
|
-
let start_event_id = self.update.first_event_id();
|
769
|
-
let poll_resp_is_incremental = start_event_id.map(|eid| eid > 1).unwrap_or_default();
|
770
|
-
poll_resp_is_incremental || start_event_id.is_none()
|
771
|
-
}
|
772
|
-
}
|
773
|
-
|
774
|
-
#[derive(Debug)]
|
775
|
-
pub(crate) struct OutstandingTask {
|
776
|
-
pub info: WorkflowTaskInfo,
|
777
|
-
pub hit_cache: bool,
|
778
|
-
/// Set if the outstanding task has quer(ies) which must be fulfilled upon finishing replay
|
779
|
-
pub pending_queries: Vec<QueryWorkflow>,
|
780
|
-
pub start_time: Instant,
|
781
|
-
/// The WFT permit owned by this task, ensures we don't exceed max concurrent WFT, and makes
|
782
|
-
/// sure the permit is automatically freed when we delete the task.
|
783
|
-
pub permit: UsedMeteredSemPermit,
|
784
|
-
}
|
785
|
-
|
786
|
-
impl OutstandingTask {
|
787
|
-
pub fn has_pending_legacy_query(&self) -> bool {
|
788
|
-
self.pending_queries
|
789
|
-
.iter()
|
790
|
-
.any(|q| q.query_id == LEGACY_QUERY_ID)
|
791
|
-
}
|
792
|
-
}
|
793
|
-
|
794
|
-
#[derive(Copy, Clone, Debug)]
|
795
|
-
pub(crate) enum OutstandingActivation {
|
796
|
-
/// A normal activation with a joblist
|
797
|
-
Normal {
|
798
|
-
/// True if there is an eviction in the joblist
|
799
|
-
contains_eviction: bool,
|
800
|
-
/// Number of jobs in the activation
|
801
|
-
num_jobs: usize,
|
802
|
-
},
|
803
|
-
/// An activation for a legacy query
|
804
|
-
LegacyQuery,
|
805
|
-
/// A fake activation which is never sent to lang, but used internally
|
806
|
-
Autocomplete,
|
807
|
-
}
|
808
|
-
|
809
|
-
impl OutstandingActivation {
|
810
|
-
pub(crate) const fn has_only_eviction(self) -> bool {
|
811
|
-
matches!(
|
812
|
-
self,
|
813
|
-
OutstandingActivation::Normal {
|
814
|
-
contains_eviction: true,
|
815
|
-
num_jobs: nj
|
816
|
-
}
|
817
|
-
if nj == 1)
|
818
|
-
}
|
819
|
-
pub(crate) const fn has_eviction(self) -> bool {
|
820
|
-
matches!(
|
821
|
-
self,
|
822
|
-
OutstandingActivation::Normal {
|
823
|
-
contains_eviction: true,
|
824
|
-
..
|
825
|
-
}
|
826
|
-
)
|
827
|
-
}
|
828
|
-
}
|
829
|
-
|
830
|
-
/// Contains important information about a given workflow task that we need to memorize while
|
831
|
-
/// lang handles it.
|
832
|
-
#[derive(Clone, Debug)]
|
833
|
-
pub struct WorkflowTaskInfo {
|
834
|
-
pub task_token: TaskToken,
|
835
|
-
pub attempt: u32,
|
836
|
-
/// Exists to allow easy tagging of spans with workflow ids. Is duplicative of info inside the
|
837
|
-
/// run machines themselves, but that can't be accessed easily. Would be nice to somehow have a
|
838
|
-
/// shared repository, or refcounts, or whatever, for strings like these that get duped all
|
839
|
-
/// sorts of places.
|
840
|
-
pub wf_id: String,
|
841
|
-
}
|
842
|
-
|
843
|
-
#[derive(Debug)]
|
844
|
-
pub enum FailedActivationWFTReport {
|
845
|
-
Report(TaskToken, WorkflowTaskFailedCause, Failure),
|
846
|
-
ReportLegacyQueryFailure(TaskToken, Failure),
|
847
|
-
}
|
848
|
-
|
849
|
-
#[derive(Debug)]
|
850
|
-
pub(crate) struct ServerCommandsWithWorkflowInfo {
|
851
|
-
pub task_token: TaskToken,
|
852
|
-
pub action: ActivationAction,
|
853
|
-
}
|
854
|
-
|
855
|
-
#[derive(Debug)]
|
856
|
-
pub(crate) enum ActivationAction {
|
857
|
-
/// We should respond that the workflow task is complete
|
858
|
-
WftComplete {
|
859
|
-
commands: Vec<ProtoCommand>,
|
860
|
-
query_responses: Vec<QueryResult>,
|
861
|
-
force_new_wft: bool,
|
862
|
-
sdk_metadata: WorkflowTaskCompletedMetadata,
|
863
|
-
},
|
864
|
-
/// We should respond to a legacy query request
|
865
|
-
RespondLegacyQuery { result: Box<QueryResult> },
|
866
|
-
}
|
867
|
-
|
868
|
-
#[derive(Debug)]
|
869
|
-
enum EvictionRequestResult {
|
870
|
-
EvictionRequested(Option<u32>, RunUpdateAct),
|
871
|
-
NotFound,
|
872
|
-
EvictionAlreadyRequested(Option<u32>),
|
873
|
-
}
|
874
|
-
impl EvictionRequestResult {
|
875
|
-
fn into_run_update_resp(self) -> RunUpdateAct {
|
876
|
-
match self {
|
877
|
-
EvictionRequestResult::EvictionRequested(_, resp) => resp,
|
878
|
-
EvictionRequestResult::NotFound
|
879
|
-
| EvictionRequestResult::EvictionAlreadyRequested(_) => None,
|
880
|
-
}
|
881
|
-
}
|
882
|
-
}
|
883
|
-
|
884
|
-
#[derive(Debug)]
|
885
|
-
#[allow(dead_code)] // Not always used in non-test
|
886
|
-
pub(crate) struct WorkflowStateInfo {
|
887
|
-
pub cached_workflows: usize,
|
888
|
-
pub outstanding_wft: usize,
|
889
|
-
}
|
890
|
-
|
891
|
-
#[derive(Debug)]
|
892
|
-
#[cfg_attr(
|
893
|
-
feature = "save_wf_inputs",
|
894
|
-
derive(serde::Serialize, serde::Deserialize)
|
895
|
-
)]
|
896
|
-
struct WFActCompleteMsg {
|
897
|
-
completion: ValidatedCompletion,
|
898
|
-
#[cfg_attr(feature = "save_wf_inputs", serde(skip))]
|
899
|
-
response_tx: Option<oneshot::Sender<ActivationCompleteResult>>,
|
900
|
-
}
|
901
|
-
#[derive(Debug)]
|
902
|
-
#[cfg_attr(
|
903
|
-
feature = "save_wf_inputs",
|
904
|
-
derive(serde::Serialize, serde::Deserialize)
|
905
|
-
)]
|
906
|
-
struct LocalResolutionMsg {
|
907
|
-
run_id: String,
|
908
|
-
res: LocalResolution,
|
909
|
-
}
|
910
|
-
#[derive(Debug)]
|
911
|
-
#[cfg_attr(
|
912
|
-
feature = "save_wf_inputs",
|
913
|
-
derive(serde::Serialize, serde::Deserialize)
|
914
|
-
)]
|
915
|
-
struct PostActivationMsg {
|
916
|
-
run_id: String,
|
917
|
-
wft_report_status: WFTReportStatus,
|
918
|
-
wft_from_complete: Option<(PreparedWFT, HistoryPaginator)>,
|
919
|
-
}
|
920
|
-
#[derive(Debug, Clone)]
|
921
|
-
#[cfg_attr(
|
922
|
-
feature = "save_wf_inputs",
|
923
|
-
derive(serde::Serialize, serde::Deserialize)
|
924
|
-
)]
|
925
|
-
struct RequestEvictMsg {
|
926
|
-
run_id: String,
|
927
|
-
message: String,
|
928
|
-
reason: EvictionReason,
|
929
|
-
}
|
930
|
-
#[derive(Debug)]
|
931
|
-
pub(crate) struct HeartbeatTimeoutMsg {
|
932
|
-
pub(crate) run_id: String,
|
933
|
-
pub(crate) span: Span,
|
934
|
-
}
|
935
|
-
#[derive(Debug)]
|
936
|
-
struct GetStateInfoMsg {
|
937
|
-
response_tx: oneshot::Sender<WorkflowStateInfo>,
|
938
|
-
}
|
939
|
-
|
940
|
-
/// Each activation completion produces one of these
|
941
|
-
#[derive(Debug)]
|
942
|
-
struct ActivationCompleteResult {
|
943
|
-
most_recently_processed_event: usize,
|
944
|
-
outcome: ActivationCompleteOutcome,
|
945
|
-
}
|
946
|
-
/// What needs to be done after calling [Workflows::activation_completed]
|
947
|
-
#[derive(Debug)]
|
948
|
-
#[allow(clippy::large_enum_variant)]
|
949
|
-
enum ActivationCompleteOutcome {
|
950
|
-
/// The WFT must be reported as successful to the server using the contained information.
|
951
|
-
ReportWFTSuccess(ServerCommandsWithWorkflowInfo),
|
952
|
-
/// The WFT must be reported as failed to the server using the contained information.
|
953
|
-
ReportWFTFail(FailedActivationWFTReport),
|
954
|
-
/// There's nothing to do right now. EX: The workflow needs to keep replaying.
|
955
|
-
DoNothing,
|
956
|
-
/// The workflow task failed, but we shouldn't report it. EX: We have failed 2 or more attempts
|
957
|
-
/// in a row.
|
958
|
-
WFTFailedDontReport,
|
959
|
-
}
|
960
|
-
/// Did we report, or not, completion of a WFT to server?
|
961
|
-
#[derive(Debug, Copy, Clone)]
|
962
|
-
#[cfg_attr(
|
963
|
-
feature = "save_wf_inputs",
|
964
|
-
derive(serde::Serialize, serde::Deserialize)
|
965
|
-
)]
|
966
|
-
enum WFTReportStatus {
|
967
|
-
Reported,
|
968
|
-
/// The WFT completion was not reported when finishing the activation, because there's still
|
969
|
-
/// work to be done. EX: Running LAs.
|
970
|
-
NotReported,
|
971
|
-
/// We didn't report, but we want to clear the outstanding workflow task anyway. See
|
972
|
-
/// [ActivationCompleteOutcome::WFTFailedDontReport]
|
973
|
-
DropWft,
|
974
|
-
}
|
975
|
-
|
976
|
-
fn validate_completion(
|
977
|
-
completion: WorkflowActivationCompletion,
|
978
|
-
) -> Result<ValidatedCompletion, CompleteWfError> {
|
979
|
-
match completion.status {
|
980
|
-
Some(workflow_activation_completion::Status::Successful(success)) => {
|
981
|
-
// Convert to wf commands
|
982
|
-
let commands = success
|
983
|
-
.commands
|
984
|
-
.into_iter()
|
985
|
-
.map(|c| c.try_into())
|
986
|
-
.collect::<Result<Vec<_>, EmptyWorkflowCommandErr>>()
|
987
|
-
.map_err(|_| CompleteWfError::MalformedWorkflowCompletion {
|
988
|
-
reason: "At least one workflow command in the completion contained \
|
989
|
-
an empty variant"
|
990
|
-
.to_owned(),
|
991
|
-
run_id: completion.run_id.clone(),
|
992
|
-
})?;
|
993
|
-
|
994
|
-
if commands.len() > 1
|
995
|
-
&& commands.iter().any(
|
996
|
-
|c| matches!(c, WFCommand::QueryResponse(q) if q.query_id == LEGACY_QUERY_ID),
|
997
|
-
)
|
998
|
-
{
|
999
|
-
return Err(CompleteWfError::MalformedWorkflowCompletion {
|
1000
|
-
reason: format!(
|
1001
|
-
"Workflow completion had a legacy query response along with other \
|
1002
|
-
commands. This is not allowed and constitutes an error in the \
|
1003
|
-
lang SDK. Commands: {commands:?}"
|
1004
|
-
),
|
1005
|
-
run_id: completion.run_id,
|
1006
|
-
});
|
1007
|
-
}
|
1008
|
-
|
1009
|
-
Ok(ValidatedCompletion::Success {
|
1010
|
-
run_id: completion.run_id,
|
1011
|
-
commands,
|
1012
|
-
used_flags: success.used_internal_flags,
|
1013
|
-
})
|
1014
|
-
}
|
1015
|
-
Some(workflow_activation_completion::Status::Failed(failure)) => {
|
1016
|
-
Ok(ValidatedCompletion::Fail {
|
1017
|
-
run_id: completion.run_id,
|
1018
|
-
failure,
|
1019
|
-
})
|
1020
|
-
}
|
1021
|
-
None => Err(CompleteWfError::MalformedWorkflowCompletion {
|
1022
|
-
reason: "Workflow completion had empty status field".to_owned(),
|
1023
|
-
run_id: completion.run_id,
|
1024
|
-
}),
|
1025
|
-
}
|
1026
|
-
}
|
1027
|
-
|
1028
|
-
#[derive(Debug)]
|
1029
|
-
#[cfg_attr(
|
1030
|
-
feature = "save_wf_inputs",
|
1031
|
-
derive(serde::Serialize, serde::Deserialize)
|
1032
|
-
)]
|
1033
|
-
#[allow(clippy::large_enum_variant)]
|
1034
|
-
enum ValidatedCompletion {
|
1035
|
-
Success {
|
1036
|
-
run_id: String,
|
1037
|
-
commands: Vec<WFCommand>,
|
1038
|
-
used_flags: Vec<u32>,
|
1039
|
-
},
|
1040
|
-
Fail {
|
1041
|
-
run_id: String,
|
1042
|
-
failure: Failure,
|
1043
|
-
},
|
1044
|
-
}
|
1045
|
-
|
1046
|
-
impl ValidatedCompletion {
|
1047
|
-
pub fn run_id(&self) -> &str {
|
1048
|
-
match self {
|
1049
|
-
ValidatedCompletion::Success { run_id, .. } => run_id,
|
1050
|
-
ValidatedCompletion::Fail { run_id, .. } => run_id,
|
1051
|
-
}
|
1052
|
-
}
|
1053
|
-
}
|
1054
|
-
|
1055
|
-
#[derive(Debug)]
|
1056
|
-
pub struct OutgoingServerCommands {
|
1057
|
-
pub commands: Vec<ProtoCommand>,
|
1058
|
-
pub replaying: bool,
|
1059
|
-
}
|
1060
|
-
|
1061
|
-
#[derive(Debug)]
|
1062
|
-
#[cfg_attr(
|
1063
|
-
feature = "save_wf_inputs",
|
1064
|
-
derive(serde::Serialize, serde::Deserialize)
|
1065
|
-
)]
|
1066
|
-
pub(crate) enum LocalResolution {
|
1067
|
-
LocalActivity(LocalActivityResolution),
|
1068
|
-
}
|
1069
|
-
impl LocalResolution {
|
1070
|
-
pub fn is_la_cancel_confirmation(&self) -> bool {
|
1071
|
-
match self {
|
1072
|
-
LocalResolution::LocalActivity(lar) => {
|
1073
|
-
matches!(lar.result, LocalActivityExecutionResult::Cancelled(_))
|
1074
|
-
}
|
1075
|
-
}
|
1076
|
-
}
|
1077
|
-
}
|
1078
|
-
|
1079
|
-
#[derive(thiserror::Error, Debug, derive_more::From)]
|
1080
|
-
#[error("Lang provided workflow command with empty variant")]
|
1081
|
-
pub struct EmptyWorkflowCommandErr;
|
1082
|
-
|
1083
|
-
/// [DrivenWorkflow]s respond with these when called, to indicate what they want to do next.
|
1084
|
-
/// EX: Create a new timer, complete the workflow, etc.
|
1085
|
-
#[derive(Debug, derive_more::From, derive_more::Display)]
|
1086
|
-
#[cfg_attr(
|
1087
|
-
feature = "save_wf_inputs",
|
1088
|
-
derive(serde::Serialize, serde::Deserialize)
|
1089
|
-
)]
|
1090
|
-
#[allow(clippy::large_enum_variant)]
|
1091
|
-
pub enum WFCommand {
|
1092
|
-
/// Returned when we need to wait for the lang sdk to send us something
|
1093
|
-
NoCommandsFromLang,
|
1094
|
-
AddActivity(ScheduleActivity),
|
1095
|
-
AddLocalActivity(ScheduleLocalActivity),
|
1096
|
-
RequestCancelActivity(RequestCancelActivity),
|
1097
|
-
RequestCancelLocalActivity(RequestCancelLocalActivity),
|
1098
|
-
AddTimer(StartTimer),
|
1099
|
-
CancelTimer(CancelTimer),
|
1100
|
-
CompleteWorkflow(CompleteWorkflowExecution),
|
1101
|
-
FailWorkflow(FailWorkflowExecution),
|
1102
|
-
QueryResponse(QueryResult),
|
1103
|
-
ContinueAsNew(ContinueAsNewWorkflowExecution),
|
1104
|
-
CancelWorkflow(CancelWorkflowExecution),
|
1105
|
-
SetPatchMarker(SetPatchMarker),
|
1106
|
-
AddChildWorkflow(StartChildWorkflowExecution),
|
1107
|
-
CancelChild(CancelChildWorkflowExecution),
|
1108
|
-
RequestCancelExternalWorkflow(RequestCancelExternalWorkflowExecution),
|
1109
|
-
SignalExternalWorkflow(SignalExternalWorkflowExecution),
|
1110
|
-
CancelSignalWorkflow(CancelSignalWorkflow),
|
1111
|
-
UpsertSearchAttributes(UpsertWorkflowSearchAttributes),
|
1112
|
-
ModifyWorkflowProperties(ModifyWorkflowProperties),
|
1113
|
-
}
|
1114
|
-
|
1115
|
-
impl TryFrom<WorkflowCommand> for WFCommand {
|
1116
|
-
type Error = EmptyWorkflowCommandErr;
|
1117
|
-
|
1118
|
-
fn try_from(c: WorkflowCommand) -> result::Result<Self, Self::Error> {
|
1119
|
-
match c.variant.ok_or(EmptyWorkflowCommandErr)? {
|
1120
|
-
workflow_command::Variant::StartTimer(s) => Ok(Self::AddTimer(s)),
|
1121
|
-
workflow_command::Variant::CancelTimer(s) => Ok(Self::CancelTimer(s)),
|
1122
|
-
workflow_command::Variant::ScheduleActivity(s) => Ok(Self::AddActivity(s)),
|
1123
|
-
workflow_command::Variant::RequestCancelActivity(s) => {
|
1124
|
-
Ok(Self::RequestCancelActivity(s))
|
1125
|
-
}
|
1126
|
-
workflow_command::Variant::CompleteWorkflowExecution(c) => {
|
1127
|
-
Ok(Self::CompleteWorkflow(c))
|
1128
|
-
}
|
1129
|
-
workflow_command::Variant::FailWorkflowExecution(s) => Ok(Self::FailWorkflow(s)),
|
1130
|
-
workflow_command::Variant::RespondToQuery(s) => Ok(Self::QueryResponse(s)),
|
1131
|
-
workflow_command::Variant::ContinueAsNewWorkflowExecution(s) => {
|
1132
|
-
Ok(Self::ContinueAsNew(s))
|
1133
|
-
}
|
1134
|
-
workflow_command::Variant::CancelWorkflowExecution(s) => Ok(Self::CancelWorkflow(s)),
|
1135
|
-
workflow_command::Variant::SetPatchMarker(s) => Ok(Self::SetPatchMarker(s)),
|
1136
|
-
workflow_command::Variant::StartChildWorkflowExecution(s) => {
|
1137
|
-
Ok(Self::AddChildWorkflow(s))
|
1138
|
-
}
|
1139
|
-
workflow_command::Variant::RequestCancelExternalWorkflowExecution(s) => {
|
1140
|
-
Ok(Self::RequestCancelExternalWorkflow(s))
|
1141
|
-
}
|
1142
|
-
workflow_command::Variant::SignalExternalWorkflowExecution(s) => {
|
1143
|
-
Ok(Self::SignalExternalWorkflow(s))
|
1144
|
-
}
|
1145
|
-
workflow_command::Variant::CancelSignalWorkflow(s) => Ok(Self::CancelSignalWorkflow(s)),
|
1146
|
-
workflow_command::Variant::CancelChildWorkflowExecution(s) => Ok(Self::CancelChild(s)),
|
1147
|
-
workflow_command::Variant::ScheduleLocalActivity(s) => Ok(Self::AddLocalActivity(s)),
|
1148
|
-
workflow_command::Variant::RequestCancelLocalActivity(s) => {
|
1149
|
-
Ok(Self::RequestCancelLocalActivity(s))
|
1150
|
-
}
|
1151
|
-
workflow_command::Variant::UpsertWorkflowSearchAttributes(s) => {
|
1152
|
-
Ok(Self::UpsertSearchAttributes(s))
|
1153
|
-
}
|
1154
|
-
workflow_command::Variant::ModifyWorkflowProperties(s) => {
|
1155
|
-
Ok(Self::ModifyWorkflowProperties(s))
|
1156
|
-
}
|
1157
|
-
}
|
1158
|
-
}
|
1159
|
-
}
|
1160
|
-
|
1161
|
-
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
|
1162
|
-
enum CommandID {
|
1163
|
-
Timer(u32),
|
1164
|
-
Activity(u32),
|
1165
|
-
LocalActivity(u32),
|
1166
|
-
ChildWorkflowStart(u32),
|
1167
|
-
SignalExternal(u32),
|
1168
|
-
CancelExternal(u32),
|
1169
|
-
}
|
1170
|
-
|
1171
|
-
/// Details remembered from the workflow execution started event that we may need to recall later.
|
1172
|
-
/// Is a subset of `WorkflowExecutionStartedEventAttributes`, but avoids holding on to huge fields.
|
1173
|
-
#[derive(Debug, Clone)]
|
1174
|
-
pub struct WorkflowStartedInfo {
|
1175
|
-
workflow_task_timeout: Option<Duration>,
|
1176
|
-
workflow_execution_timeout: Option<Duration>,
|
1177
|
-
memo: Option<Memo>,
|
1178
|
-
search_attrs: Option<SearchAttributes>,
|
1179
|
-
retry_policy: Option<RetryPolicy>,
|
1180
|
-
}
|
1181
|
-
|
1182
|
-
/// Wraps outgoing activation job protos with some internal details core might care about
|
1183
|
-
#[derive(Debug, derive_more::Display)]
|
1184
|
-
#[display(fmt = "{variant}")]
|
1185
|
-
struct OutgoingJob {
|
1186
|
-
variant: workflow_activation_job::Variant,
|
1187
|
-
/// Since LA resolutions are not distinguished from non-LA resolutions as far as lang is
|
1188
|
-
/// concerned, but core cares about that sometimes, attach that info here.
|
1189
|
-
is_la_resolution: bool,
|
1190
|
-
}
|
1191
|
-
impl<WA: Into<workflow_activation_job::Variant>> From<WA> for OutgoingJob {
|
1192
|
-
fn from(wa: WA) -> Self {
|
1193
|
-
Self {
|
1194
|
-
variant: wa.into(),
|
1195
|
-
is_la_resolution: false,
|
1196
|
-
}
|
1197
|
-
}
|
1198
|
-
}
|
1199
|
-
impl From<OutgoingJob> for WorkflowActivationJob {
|
1200
|
-
fn from(og: OutgoingJob) -> Self {
|
1201
|
-
Self {
|
1202
|
-
variant: Some(og.variant),
|
1203
|
-
}
|
1204
|
-
}
|
1205
|
-
}
|
1206
|
-
|
1207
|
-
/// Errors thrown inside of workflow machines
|
1208
|
-
#[derive(thiserror::Error, Debug)]
|
1209
|
-
pub(crate) enum WFMachinesError {
|
1210
|
-
#[error("Nondeterminism error: {0}")]
|
1211
|
-
Nondeterminism(String),
|
1212
|
-
#[error("Fatal error in workflow machines: {0}")]
|
1213
|
-
Fatal(String),
|
1214
|
-
}
|
1215
|
-
|
1216
|
-
impl WFMachinesError {
|
1217
|
-
pub fn evict_reason(&self) -> EvictionReason {
|
1218
|
-
match self {
|
1219
|
-
WFMachinesError::Nondeterminism(_) => EvictionReason::Nondeterminism,
|
1220
|
-
WFMachinesError::Fatal(_) => EvictionReason::Fatal,
|
1221
|
-
}
|
1222
|
-
}
|
1223
|
-
}
|
1224
|
-
|
1225
|
-
impl From<TimestampError> for WFMachinesError {
|
1226
|
-
fn from(_: TimestampError) -> Self {
|
1227
|
-
Self::Fatal("Could not decode timestamp".to_string())
|
1228
|
-
}
|
1229
|
-
}
|
1230
|
-
|
1231
|
-
fn auto_fail_to_complete_status(err: WFMachinesError) -> workflow_activation_completion::Status {
|
1232
|
-
workflow_activation_completion::Status::Failed(Failure {
|
1233
|
-
failure: Some(
|
1234
|
-
temporal_sdk_core_protos::temporal::api::failure::v1::Failure {
|
1235
|
-
message: "Error while processing workflow task".to_string(),
|
1236
|
-
source: err.to_string(),
|
1237
|
-
stack_trace: "".to_string(),
|
1238
|
-
encoded_attributes: None,
|
1239
|
-
cause: None,
|
1240
|
-
failure_info: None,
|
1241
|
-
},
|
1242
|
-
),
|
1243
|
-
force_cause: WorkflowTaskFailedCause::from(err.evict_reason()) as i32,
|
1244
|
-
})
|
1245
|
-
}
|
1246
|
-
|
1247
|
-
pub(crate) trait LocalActivityRequestSink: Send + Sync + 'static {
|
1248
|
-
fn sink_reqs(&self, reqs: Vec<LocalActRequest>) -> Vec<LocalActivityResolution>;
|
1249
|
-
}
|
1250
|
-
|
1251
|
-
#[derive(derive_more::Constructor)]
|
1252
|
-
pub(super) struct LAReqSink {
|
1253
|
-
lam: Arc<LocalActivityManager>,
|
1254
|
-
/// If we're recording WF inputs, we also need to store immediate resolutions so they're
|
1255
|
-
/// available on replay.
|
1256
|
-
#[allow(dead_code)] // sometimes appears unused due to feature flagging
|
1257
|
-
recorder: Option<UnboundedSender<Vec<u8>>>,
|
1258
|
-
}
|
1259
|
-
|
1260
|
-
impl LocalActivityRequestSink for LAReqSink {
|
1261
|
-
fn sink_reqs(&self, reqs: Vec<LocalActRequest>) -> Vec<LocalActivityResolution> {
|
1262
|
-
if reqs.is_empty() {
|
1263
|
-
return vec![];
|
1264
|
-
}
|
1265
|
-
|
1266
|
-
#[allow(clippy::let_and_return)] // When feature is off clippy doesn't like this
|
1267
|
-
let res = self.lam.enqueue(reqs);
|
1268
|
-
|
1269
|
-
// We always save when there are any reqs, even if the response might be empty, so that
|
1270
|
-
// calls/responses are 1:1
|
1271
|
-
#[cfg(feature = "save_wf_inputs")]
|
1272
|
-
self.write_req(&res);
|
1273
|
-
|
1274
|
-
res
|
1275
|
-
}
|
1276
|
-
}
|