@temporalio/core-bridge 1.13.1 → 1.14.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.
- package/Cargo.lock +350 -436
- package/Cargo.toml +14 -13
- package/{sdk-core/fsm/rustfsm_procmacro/LICENSE.txt → LICENSE} +5 -5
- package/README.md +0 -1
- package/bridge-macros/Cargo.toml +16 -0
- package/bridge-macros/src/derive_js_function.rs +126 -0
- package/bridge-macros/src/derive_tryfromjs.rs +138 -0
- package/bridge-macros/src/derive_tryintojs.rs +151 -0
- package/bridge-macros/src/lib.rs +42 -0
- package/lib/native.d.ts +23 -9
- package/package.json +6 -5
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.cargo/config.toml +78 -12
- package/sdk-core/.clippy.toml +1 -0
- package/sdk-core/.github/workflows/heavy.yml +2 -0
- package/sdk-core/.github/workflows/per-pr.yml +90 -21
- package/sdk-core/AGENTS.md +17 -19
- package/sdk-core/ARCHITECTURE.md +44 -48
- package/sdk-core/Cargo.toml +25 -7
- package/sdk-core/README.md +16 -15
- package/sdk-core/arch_docs/diagrams/TimerMachine_Coverage.puml +14 -0
- package/sdk-core/arch_docs/diagrams/deps.svg +102 -0
- package/sdk-core/arch_docs/diagrams/initial_event_history.png +0 -0
- package/sdk-core/arch_docs/sdks_intro.md +299 -0
- package/sdk-core/{client → crates/client}/Cargo.toml +15 -16
- package/sdk-core/{client → crates/client}/src/callback_based.rs +1 -2
- package/sdk-core/{client → crates/client}/src/lib.rs +594 -457
- package/sdk-core/{client → crates/client}/src/metrics.rs +32 -8
- package/sdk-core/crates/client/src/proxy.rs +209 -0
- package/sdk-core/{client → crates/client}/src/raw.rs +648 -328
- package/sdk-core/crates/client/src/replaceable.rs +253 -0
- package/sdk-core/crates/client/src/request_extensions.rs +40 -0
- package/sdk-core/{client → crates/client}/src/retry.rs +32 -22
- package/sdk-core/crates/client/src/worker/mod.rs +1468 -0
- package/sdk-core/{client → crates/client}/src/workflow_handle/mod.rs +24 -21
- package/sdk-core/{core-api → crates/common}/Cargo.toml +21 -12
- package/sdk-core/{sdk-core-protos → crates/common}/build.rs +10 -23
- package/sdk-core/crates/common/protos/api_cloud_upstream/VERSION +1 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/account/v1/message.proto +18 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +38 -11
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +21 -4
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +6 -6
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/sink/v1/message.proto +22 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/create-release.yml +13 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv2.json +254 -5
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv3.yaml +234 -5
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/common/v1/message.proto +1 -1
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/deployment/v1/message.proto +6 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -2
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -2
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +30 -6
- package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
- package/sdk-core/{core-api → crates/common}/src/envconfig.rs +155 -56
- package/sdk-core/{core-api → crates/common}/src/errors.rs +8 -1
- package/sdk-core/{fsm/rustfsm_trait/src/lib.rs → crates/common/src/fsm_trait.rs} +1 -27
- package/sdk-core/{core-api → crates/common}/src/lib.rs +92 -9
- package/sdk-core/{test-utils/src → crates/common/src/protos}/canned_histories.rs +5 -5
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_builder.rs +3 -3
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_info.rs +2 -2
- package/sdk-core/{sdk-core-protos/src/lib.rs → crates/common/src/protos/mod.rs} +43 -26
- package/sdk-core/crates/common/src/protos/test_utils.rs +89 -0
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/utilities.rs +14 -5
- package/sdk-core/{core-api → crates/common}/src/telemetry/metrics.rs +449 -51
- package/sdk-core/{core-api → crates/common}/src/telemetry.rs +16 -1
- package/sdk-core/{core-api → crates/common}/src/worker.rs +112 -18
- package/sdk-core/crates/common/tests/worker_task_types_test.rs +129 -0
- package/sdk-core/crates/macros/Cargo.toml +23 -0
- package/sdk-core/{fsm/rustfsm_procmacro → crates/macros}/src/lib.rs +12 -12
- package/sdk-core/{sdk → crates/sdk}/Cargo.toml +18 -12
- package/sdk-core/{sdk → crates/sdk}/src/activity_context.rs +9 -7
- package/sdk-core/{sdk → crates/sdk}/src/app_data.rs +1 -1
- package/sdk-core/{sdk → crates/sdk}/src/interceptors.rs +2 -5
- package/sdk-core/{sdk → crates/sdk}/src/lib.rs +43 -42
- package/sdk-core/{sdk → crates/sdk}/src/workflow_context/options.rs +12 -3
- package/sdk-core/{sdk → crates/sdk}/src/workflow_context.rs +21 -19
- package/sdk-core/{sdk → crates/sdk}/src/workflow_future.rs +2 -2
- package/sdk-core/crates/sdk-core/Cargo.toml +222 -0
- package/sdk-core/{core/benches/workflow_replay.rs → crates/sdk-core/benches/workflow_replay_bench.rs} +15 -10
- package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +32 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CancelExternalMachine_Coverage.puml +9 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CancelWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ChildWorkflowMachine_Coverage.puml +27 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CompleteWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ContinueAsNewWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/FailWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/LocalActivityMachine_Coverage.puml +23 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ModifyWorkflowPropertiesMachine_Coverage.puml +5 -0
- package/sdk-core/crates/sdk-core/machine_coverage/PatchMachine_Coverage.puml +8 -0
- package/sdk-core/crates/sdk-core/machine_coverage/SignalExternalMachine_Coverage.puml +12 -0
- package/sdk-core/crates/sdk-core/machine_coverage/TimerMachine_Coverage.puml +13 -0
- package/sdk-core/crates/sdk-core/machine_coverage/UpdateMachine_Coverage.puml +19 -0
- package/sdk-core/crates/sdk-core/machine_coverage/UpsertSearchAttributesMachine_Coverage.puml +5 -0
- package/sdk-core/crates/sdk-core/machine_coverage/WorkflowTaskMachine_Coverage.puml +11 -0
- package/sdk-core/{core → crates/sdk-core}/src/abstractions.rs +62 -6
- package/sdk-core/crates/sdk-core/src/antithesis.rs +60 -0
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/activity_tasks.rs +85 -250
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/mod.rs +13 -16
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/queries.rs +25 -24
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/replay_flag.rs +11 -68
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/updates.rs +21 -20
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workers.rs +242 -16
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_cancels.rs +10 -7
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_tasks.rs +150 -326
- package/sdk-core/{core → crates/sdk-core}/src/debug_client.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/ephemeral_server/mod.rs +18 -6
- package/sdk-core/{test-utils → crates/sdk-core}/src/histfetch.rs +9 -4
- package/sdk-core/{core → crates/sdk-core}/src/internal_flags.rs +15 -4
- package/sdk-core/{core → crates/sdk-core}/src/lib.rs +128 -72
- package/sdk-core/{core → crates/sdk-core}/src/pollers/mod.rs +13 -11
- package/sdk-core/{core → crates/sdk-core}/src/pollers/poll_buffer.rs +53 -18
- package/sdk-core/{core → crates/sdk-core}/src/protosext/mod.rs +14 -6
- package/sdk-core/{core → crates/sdk-core}/src/protosext/protocol_messages.rs +5 -12
- package/sdk-core/{core → crates/sdk-core}/src/replay/mod.rs +14 -11
- package/sdk-core/crates/sdk-core/src/retry_logic.rs +390 -0
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/log_export.rs +2 -2
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/metrics.rs +80 -33
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/mod.rs +12 -6
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/otel.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_meter.rs +14 -14
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_server.rs +2 -2
- package/sdk-core/{core/src/test_help/mod.rs → crates/sdk-core/src/test_help/integ_helpers.rs} +284 -329
- package/sdk-core/crates/sdk-core/src/test_help/mod.rs +13 -0
- package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +220 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities/activity_heartbeat_manager.rs +44 -8
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities/local_activities.rs +33 -31
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities.rs +31 -15
- package/sdk-core/{core → crates/sdk-core}/src/worker/client/mocks.rs +28 -15
- package/sdk-core/{core → crates/sdk-core}/src/worker/client.rs +275 -145
- package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +246 -0
- package/sdk-core/crates/sdk-core/src/worker/mod.rs +1462 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/nexus.rs +24 -12
- package/sdk-core/{core → crates/sdk-core}/src/worker/slot_provider.rs +18 -10
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/fixed_size.rs +5 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/resource_based.rs +453 -57
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner.rs +179 -3
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/driven_workflow.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/history_update.rs +5 -267
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/activity_state_machine.rs +147 -90
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_external_state_machine.rs +8 -91
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_nexus_op_state_machine.rs +14 -12
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +97 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/child_workflow_state_machine.rs +32 -229
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/complete_workflow_state_machine.rs +13 -8
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +6 -50
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/fail_workflow_state_machine.rs +6 -7
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/local_activity_state_machine.rs +39 -584
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/mod.rs +22 -17
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +4 -74
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/nexus_operation_state_machine.rs +118 -21
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/patch_state_machine.rs +273 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/signal_external_state_machine.rs +9 -151
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/timer_state_machine.rs +27 -132
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/transition_coverage.rs +1 -2
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/update_state_machine.rs +19 -13
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +25 -80
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines/local_acts.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines.rs +68 -72
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_task_state_machine.rs +13 -15
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/managed_run.rs +55 -37
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/mod.rs +171 -61
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/run_cache.rs +10 -7
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_extraction.rs +4 -2
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_poller.rs +15 -4
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/workflow_stream.rs +38 -19
- package/sdk-core/crates/sdk-core/tests/c_bridge_smoke_test.c +10 -0
- package/sdk-core/crates/sdk-core/tests/cloud_tests.rs +25 -0
- package/sdk-core/crates/sdk-core/tests/common/fake_grpc_server.rs +106 -0
- package/sdk-core/crates/sdk-core/tests/common/http_proxy.rs +134 -0
- package/sdk-core/{test-utils/src/lib.rs → crates/sdk-core/tests/common/mod.rs} +286 -334
- package/sdk-core/{test-utils/src → crates/sdk-core/tests/common}/workflows.rs +6 -4
- package/sdk-core/crates/sdk-core/tests/fsm_procmacro.rs +6 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dupe_transitions_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/dupe_transitions_fail.stderr +12 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dynamic_dest_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.rs +1 -3
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.stderr +4 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_arg_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/medium_complex_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/no_handle_conversions_require_into_fail.rs +2 -4
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/no_handle_conversions_require_into_fail.stderr +15 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/simple_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/struct_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/struct_event_variant_fail.stderr +5 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_more_item_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_more_item_event_variant_fail.stderr +5 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_zero_item_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_zero_item_event_variant_fail.stderr +5 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/global_metric_tests.rs +22 -22
- package/sdk-core/{tests → crates/sdk-core/tests/heavy_tests}/fuzzy_workflow.rs +4 -4
- package/sdk-core/{tests → crates/sdk-core/tests}/heavy_tests.rs +25 -14
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/activity_functions.rs +1 -1
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/client_tests.rs +115 -123
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/ephemeral_server_tests.rs +19 -15
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/heartbeat_tests.rs +24 -20
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/metrics_tests.rs +241 -67
- package/sdk-core/crates/sdk-core/tests/integ_tests/pagination_tests.rs +273 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/polling_tests.rs +513 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/queries_tests.rs +13 -11
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/update_tests.rs +47 -29
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/visibility_tests.rs +49 -27
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +1061 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +920 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/worker_versioning_tests.rs +58 -40
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/activities.rs +268 -30
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/appdata_propagation.rs +4 -4
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +155 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +121 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +717 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +109 -0
- package/sdk-core/{core/src/core_tests → crates/sdk-core/tests/integ_tests/workflow_tests}/determinism.rs +108 -20
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/eager.rs +10 -5
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +2884 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +119 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/nexus.rs +174 -46
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +740 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/replay.rs +78 -27
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/resets.rs +46 -28
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +294 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/stickyness.rs +9 -8
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +249 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/upsert_search_attrs.rs +72 -7
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests.rs +97 -33
- package/sdk-core/{tests → crates/sdk-core/tests}/main.rs +40 -25
- package/sdk-core/{tests → crates/sdk-core/tests}/manual_tests.rs +25 -15
- package/sdk-core/{tests → crates/sdk-core/tests}/runner.rs +23 -41
- package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/mod.rs +11 -6
- package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/priority.rs +6 -6
- package/sdk-core/crates/sdk-core-c-bridge/Cargo.toml +59 -0
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/include/temporal-sdk-core-c-bridge.h +215 -44
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/client.rs +515 -214
- package/sdk-core/crates/sdk-core-c-bridge/src/envconfig.rs +314 -0
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/lib.rs +2 -1
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/metric.rs +1 -1
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/random.rs +4 -4
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/runtime.rs +42 -28
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/testing.rs +2 -5
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/context.rs +42 -41
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/mod.rs +38 -34
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/utils.rs +10 -11
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/worker.rs +427 -121
- package/sdk-core/docker-cgroup-tests.sh +24 -0
- package/sdk-core/{docker → etc/docker}/docker-compose-ci.yaml +9 -9
- package/sdk-core/{docker → etc/docker}/docker-compose-telem.yaml +11 -11
- package/sdk-core/{docker → etc/docker}/docker-compose.yaml +8 -8
- package/sdk-core/{integ-with-otel.sh → etc/integ-with-otel.sh} +1 -1
- package/sdk-core/etc/regen-depgraph.sh +2 -2
- package/src/client.rs +117 -49
- package/src/helpers/callbacks.rs +4 -4
- package/src/helpers/errors.rs +7 -1
- package/src/helpers/handles.rs +1 -0
- package/src/helpers/try_from_js.rs +5 -4
- package/src/lib.rs +3 -2
- package/src/logs.rs +1 -1
- package/src/metrics.rs +6 -3
- package/src/runtime.rs +41 -24
- package/src/testing.rs +3 -3
- package/src/worker.rs +77 -44
- package/ts/native.ts +26 -9
- package/LICENSE.md +0 -23
- package/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
- package/sdk-core/client/src/proxy.rs +0 -90
- package/sdk-core/client/src/worker_registry/mod.rs +0 -266
- package/sdk-core/core/Cargo.toml +0 -146
- package/sdk-core/core/src/core_tests/child_workflows.rs +0 -281
- package/sdk-core/core/src/core_tests/local_activities.rs +0 -1442
- package/sdk-core/core/src/retry_logic.rs +0 -224
- package/sdk-core/core/src/worker/heartbeat.rs +0 -231
- package/sdk-core/core/src/worker/mod.rs +0 -980
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -165
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +0 -801
- package/sdk-core/core-c-bridge/Cargo.toml +0 -51
- package/sdk-core/etc/deps.svg +0 -162
- package/sdk-core/fsm/Cargo.toml +0 -21
- package/sdk-core/fsm/README.md +0 -3
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +0 -27
- package/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +0 -8
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +0 -12
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +0 -15
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_trait/Cargo.toml +0 -14
- package/sdk-core/fsm/rustfsm_trait/LICENSE.txt +0 -21
- package/sdk-core/fsm/src/lib.rs +0 -2
- package/sdk-core/sdk-core-protos/Cargo.toml +0 -37
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +0 -1
- package/sdk-core/test-utils/Cargo.toml +0 -38
- package/sdk-core/test-utils/src/interceptors.rs +0 -46
- package/sdk-core/tests/cloud_tests.rs +0 -23
- package/sdk-core/tests/integ_tests/polling_tests.rs +0 -294
- package/sdk-core/tests/integ_tests/worker_tests.rs +0 -203
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +0 -74
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +0 -57
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +0 -246
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +0 -65
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +0 -85
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +0 -908
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +0 -51
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +0 -206
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +0 -164
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +0 -123
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/build.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/push-to-buf.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/CODEOWNERS +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/LICENSE +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/README.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.gen.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.lock +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/connectivityrule/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/resource/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/usage/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/CODEOWNERS +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/ci.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/publish-docs.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/push-to-buf.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-delete-release.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-publish-release.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/LICENSE +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/README.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/api-linter.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.gen.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.lock +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/annotations.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/http.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/any.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/descriptor.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/duration.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/empty.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/struct.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/timestamp.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/wrappers.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/payload_description.txt +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/activity/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/batch/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/command/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/command_type.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/common.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/deployment.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/event_type.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/namespace.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/nexus.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/query.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/reset.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/schedule.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/update.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/workflow.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/errordetails/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/export/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/failure/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/filter/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/history/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/nexus/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/protocol/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/query/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/replication/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/rules/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/schedule/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/enhanced_stack_trace.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/user_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/worker_config.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/update/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/version/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/worker/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflow/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/google/rpc/status.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/grpc/health/v1/health.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_result/activity_result.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_task/activity_task.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/common/common.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/core_interface.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/external_data/external_data.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/nexus/nexus.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/api-linter.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +0 -0
- /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/constants.rs +0 -0
- /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/task_token.rs +0 -0
- /package/sdk-core/{fsm → crates/macros}/LICENSE.txt +0 -0
- /package/sdk-core/{core → crates/sdk-core}/src/abstractions/take_cell.rs +0 -0
- /package/sdk-core/{core → crates/sdk-core}/src/worker/slot_supplier.rs +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/ends_empty_wft_complete.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-16_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-23_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-85_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/fail_wf_task.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-0_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-1_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-2_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-3_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/old_change_marker_format.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/timer_workflow_history.bin +0 -0
- /package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/priority.rs +0 -0
- /package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/build.rs +0 -0
- /package/sdk-core/{cargo-tokio-console.sh → etc/cargo-tokio-console.sh} +0 -0
|
@@ -6,7 +6,7 @@ use std::{
|
|
|
6
6
|
collections::{BTreeSet, HashSet},
|
|
7
7
|
iter,
|
|
8
8
|
};
|
|
9
|
-
use
|
|
9
|
+
use temporalio_common::protos::temporal::api::{
|
|
10
10
|
history::v1::WorkflowTaskCompletedEventAttributes, sdk::v1::WorkflowTaskCompletedMetadata,
|
|
11
11
|
workflowservice::v1::get_system_info_response,
|
|
12
12
|
};
|
|
@@ -18,9 +18,10 @@ use temporal_sdk_core_protos::temporal::api::{
|
|
|
18
18
|
/// may be removed from the enum. *Importantly*, all variants must be given explicit values, such
|
|
19
19
|
/// that removing older variants does not create any change in existing values. Removed flag
|
|
20
20
|
/// variants must be reserved forever (a-la protobuf), and should be called out in a comment.
|
|
21
|
+
#[allow(unreachable_pub)] // re-exported in test_help::integ_helpers
|
|
21
22
|
#[repr(u32)]
|
|
22
23
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone, Debug, enum_iterator::Sequence)]
|
|
23
|
-
pub
|
|
24
|
+
pub enum CoreInternalFlags {
|
|
24
25
|
/// In this flag additional checks were added to a number of state machines to ensure that
|
|
25
26
|
/// the ID and type of activities, local activities, and child workflows match during replay.
|
|
26
27
|
IdAndTypeDeterminismChecks = 1,
|
|
@@ -34,7 +35,7 @@ pub(crate) enum CoreInternalFlags {
|
|
|
34
35
|
/// multiple workflow coroutines generated a terminal command). This has the
|
|
35
36
|
/// consequence that all non-terminal commands are sent to the server, even
|
|
36
37
|
/// if in the sequence delivered by lang they came after a terminal command.
|
|
37
|
-
/// See https://github.com/temporalio/features/issues/481
|
|
38
|
+
/// See <https://github.com/temporalio/features/issues/481>.
|
|
38
39
|
MoveTerminalCommands = 3,
|
|
39
40
|
/// We received a value higher than this code can understand.
|
|
40
41
|
TooHigh = u32::MAX,
|
|
@@ -202,6 +203,15 @@ impl InternalFlags {
|
|
|
202
203
|
Self::Disabled => Either::Right(iter::empty()),
|
|
203
204
|
}
|
|
204
205
|
}
|
|
206
|
+
|
|
207
|
+
pub(crate) fn last_sdk_version(&self) -> Option<&str> {
|
|
208
|
+
match self {
|
|
209
|
+
InternalFlags::Enabled {
|
|
210
|
+
last_sdk_version, ..
|
|
211
|
+
} if !last_sdk_version.is_empty() => Some(last_sdk_version),
|
|
212
|
+
InternalFlags::Enabled { .. } | InternalFlags::Disabled => None,
|
|
213
|
+
}
|
|
214
|
+
}
|
|
205
215
|
}
|
|
206
216
|
|
|
207
217
|
impl CoreInternalFlags {
|
|
@@ -223,8 +233,9 @@ impl CoreInternalFlags {
|
|
|
223
233
|
#[cfg(test)]
|
|
224
234
|
mod tests {
|
|
225
235
|
use super::*;
|
|
226
|
-
use
|
|
236
|
+
use temporalio_common::protos::temporal::api::workflowservice::v1::get_system_info_response::Capabilities;
|
|
227
237
|
|
|
238
|
+
#[allow(clippy::derivable_impls)] // Only want this in test
|
|
228
239
|
impl Default for InternalFlags {
|
|
229
240
|
fn default() -> Self {
|
|
230
241
|
Self::Disabled
|
|
@@ -12,6 +12,8 @@ extern crate tracing;
|
|
|
12
12
|
extern crate core;
|
|
13
13
|
|
|
14
14
|
mod abstractions;
|
|
15
|
+
#[cfg(feature = "antithesis_assertions")]
|
|
16
|
+
mod antithesis;
|
|
15
17
|
#[cfg(feature = "debug-plugin")]
|
|
16
18
|
pub mod debug_client;
|
|
17
19
|
#[cfg(feature = "ephemeral-server")]
|
|
@@ -26,25 +28,22 @@ mod worker;
|
|
|
26
28
|
|
|
27
29
|
#[cfg(test)]
|
|
28
30
|
mod core_tests;
|
|
29
|
-
#[cfg(test)]
|
|
31
|
+
#[cfg(any(feature = "test-utilities", test))]
|
|
30
32
|
#[macro_use]
|
|
31
|
-
mod test_help;
|
|
33
|
+
pub mod test_help;
|
|
32
34
|
|
|
33
|
-
pub(crate) use
|
|
35
|
+
pub(crate) use temporalio_common::errors;
|
|
34
36
|
|
|
35
37
|
pub use pollers::{
|
|
36
|
-
Client, ClientOptions,
|
|
37
|
-
|
|
38
|
+
Client, ClientOptions, ClientTlsOptions, RetryClient, RetryOptions, TlsOptions,
|
|
39
|
+
WorkflowClientTrait,
|
|
38
40
|
};
|
|
39
|
-
pub use
|
|
40
|
-
pub use temporal_sdk_core_protos as protos;
|
|
41
|
-
pub use temporal_sdk_core_protos::TaskToken;
|
|
41
|
+
pub use temporalio_common::protos::TaskToken;
|
|
42
42
|
pub use url::Url;
|
|
43
43
|
pub use worker::{
|
|
44
|
-
FixedSizeSlotSupplier,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
WorkerConfigBuilder,
|
|
44
|
+
FixedSizeSlotSupplier, ResourceBasedSlotsOptions, ResourceBasedSlotsOptionsBuilder,
|
|
45
|
+
ResourceBasedTuner, ResourceSlotOptions, SlotSupplierOptions, TunerBuilder, TunerHolder,
|
|
46
|
+
TunerHolderOptions, TunerHolderOptionsBuilder, Worker, WorkerConfig, WorkerConfigBuilder,
|
|
48
47
|
};
|
|
49
48
|
|
|
50
49
|
/// Expose [WorkerClient] symbols
|
|
@@ -61,14 +60,14 @@ use crate::{
|
|
|
61
60
|
};
|
|
62
61
|
use anyhow::bail;
|
|
63
62
|
use futures_util::Stream;
|
|
64
|
-
use std::sync::
|
|
65
|
-
use
|
|
66
|
-
use
|
|
63
|
+
use std::{sync::Arc, time::Duration};
|
|
64
|
+
use temporalio_client::{ConfiguredClient, NamespacedClient, SharedReplaceableClient};
|
|
65
|
+
use temporalio_common::{
|
|
67
66
|
Worker as WorkerTrait,
|
|
68
67
|
errors::{CompleteActivityError, PollError},
|
|
68
|
+
protos::coresdk::ActivityHeartbeat,
|
|
69
69
|
telemetry::TelemetryOptions,
|
|
70
70
|
};
|
|
71
|
-
use temporal_sdk_core_protos::coresdk::ActivityHeartbeat;
|
|
72
71
|
|
|
73
72
|
/// Initialize a worker bound to a task queue.
|
|
74
73
|
///
|
|
@@ -89,39 +88,40 @@ pub fn init_worker<CT>(
|
|
|
89
88
|
where
|
|
90
89
|
CT: Into<sealed::AnyClient>,
|
|
91
90
|
{
|
|
92
|
-
let
|
|
93
|
-
if
|
|
94
|
-
bail!("
|
|
95
|
-
}
|
|
96
|
-
if client.namespace() == "" {
|
|
97
|
-
bail!("Client namespace cannot be empty");
|
|
91
|
+
let namespace = worker_config.namespace.clone();
|
|
92
|
+
if namespace.is_empty() {
|
|
93
|
+
bail!("Worker namespace cannot be empty");
|
|
98
94
|
}
|
|
99
|
-
|
|
100
|
-
let
|
|
95
|
+
|
|
96
|
+
let client = RetryClient::new(
|
|
97
|
+
SharedReplaceableClient::new(init_worker_client(
|
|
98
|
+
worker_config.namespace.clone(),
|
|
99
|
+
worker_config.client_identity_override.clone(),
|
|
100
|
+
client,
|
|
101
|
+
)),
|
|
102
|
+
RetryOptions::default(),
|
|
103
|
+
);
|
|
104
|
+
let client_ident = client.identity();
|
|
105
|
+
let sticky_q = sticky_q_name_for_worker(&client_ident, worker_config.max_cached_workflows);
|
|
101
106
|
|
|
102
107
|
if client_ident.is_empty() {
|
|
103
108
|
bail!("Client identity cannot be empty. Either lang or user should be setting this value");
|
|
104
109
|
}
|
|
105
110
|
|
|
106
|
-
let heartbeat_fn = worker_config
|
|
107
|
-
.heartbeat_interval
|
|
108
|
-
.map(|_| Arc::new(OnceLock::new()));
|
|
109
|
-
|
|
110
111
|
let client_bag = Arc::new(WorkerClientBag::new(
|
|
111
112
|
client,
|
|
112
|
-
|
|
113
|
-
client_ident,
|
|
113
|
+
namespace.clone(),
|
|
114
|
+
client_ident.clone(),
|
|
114
115
|
worker_config.versioning_strategy.clone(),
|
|
115
|
-
heartbeat_fn.clone(),
|
|
116
116
|
));
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
worker_config,
|
|
118
|
+
Worker::new(
|
|
119
|
+
worker_config.clone(),
|
|
120
120
|
sticky_q,
|
|
121
|
-
client_bag,
|
|
121
|
+
client_bag.clone(),
|
|
122
122
|
Some(&runtime.telemetry),
|
|
123
|
-
|
|
124
|
-
)
|
|
123
|
+
runtime.heartbeat_interval,
|
|
124
|
+
)
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
/// Create a worker for replaying one or more existing histories. It will auto-shutdown as soon as
|
|
@@ -141,24 +141,28 @@ where
|
|
|
141
141
|
rwi.into_core_worker()
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
pub(crate) fn init_worker_client(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
pub(crate) fn init_worker_client<CT>(
|
|
145
|
+
namespace: String,
|
|
146
|
+
client_identity_override: Option<String>,
|
|
147
|
+
client: CT,
|
|
148
|
+
) -> Client
|
|
149
|
+
where
|
|
150
|
+
CT: Into<sealed::AnyClient>,
|
|
151
|
+
{
|
|
152
|
+
let mut client = Client::new(*client.into().into_inner(), namespace.clone());
|
|
153
|
+
if let Some(ref id_override) = client_identity_override {
|
|
150
154
|
client.options_mut().identity.clone_from(id_override);
|
|
151
155
|
}
|
|
152
|
-
|
|
156
|
+
client
|
|
153
157
|
}
|
|
154
158
|
|
|
155
159
|
/// Creates a unique sticky queue name for a worker, iff the config allows for 1 or more cached
|
|
156
160
|
/// workflows.
|
|
157
161
|
pub(crate) fn sticky_q_name_for_worker(
|
|
158
162
|
process_identity: &str,
|
|
159
|
-
|
|
163
|
+
max_cached_workflows: usize,
|
|
160
164
|
) -> Option<String> {
|
|
161
|
-
if
|
|
165
|
+
if max_cached_workflows > 0 {
|
|
162
166
|
Some(format!(
|
|
163
167
|
"{}-{}",
|
|
164
168
|
&process_identity,
|
|
@@ -171,44 +175,57 @@ pub(crate) fn sticky_q_name_for_worker(
|
|
|
171
175
|
|
|
172
176
|
mod sealed {
|
|
173
177
|
use super::*;
|
|
178
|
+
use temporalio_client::{SharedReplaceableClient, TemporalServiceClient};
|
|
174
179
|
|
|
175
180
|
/// Allows passing different kinds of clients into things that want to be flexible. Motivating
|
|
176
181
|
/// use-case was worker initialization.
|
|
177
182
|
///
|
|
178
183
|
/// Needs to exist in this crate to avoid blanket impl conflicts.
|
|
179
184
|
pub struct AnyClient {
|
|
180
|
-
pub(crate) inner: Box<ConfiguredClient<
|
|
185
|
+
pub(crate) inner: Box<ConfiguredClient<TemporalServiceClient>>,
|
|
181
186
|
}
|
|
182
187
|
impl AnyClient {
|
|
183
|
-
pub(crate) fn into_inner(self) -> Box<ConfiguredClient<
|
|
188
|
+
pub(crate) fn into_inner(self) -> Box<ConfiguredClient<TemporalServiceClient>> {
|
|
184
189
|
self.inner
|
|
185
190
|
}
|
|
186
191
|
}
|
|
187
192
|
|
|
188
|
-
impl From<
|
|
189
|
-
fn from(c:
|
|
190
|
-
Self {
|
|
191
|
-
inner: Box::new(c.into_inner()),
|
|
192
|
-
}
|
|
193
|
+
impl From<ConfiguredClient<TemporalServiceClient>> for AnyClient {
|
|
194
|
+
fn from(c: ConfiguredClient<TemporalServiceClient>) -> Self {
|
|
195
|
+
Self { inner: Box::new(c) }
|
|
193
196
|
}
|
|
194
197
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
198
|
+
|
|
199
|
+
impl From<Client> for AnyClient {
|
|
200
|
+
fn from(c: Client) -> Self {
|
|
201
|
+
c.into_inner().into()
|
|
200
202
|
}
|
|
201
203
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
|
|
205
|
+
impl<T> From<RetryClient<T>> for AnyClient
|
|
206
|
+
where
|
|
207
|
+
T: Into<AnyClient>,
|
|
208
|
+
{
|
|
209
|
+
fn from(c: RetryClient<T>) -> Self {
|
|
210
|
+
c.into_inner().into()
|
|
207
211
|
}
|
|
208
212
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
213
|
+
|
|
214
|
+
impl<T> From<SharedReplaceableClient<T>> for AnyClient
|
|
215
|
+
where
|
|
216
|
+
T: Into<AnyClient> + Clone + Send + Sync,
|
|
217
|
+
{
|
|
218
|
+
fn from(c: SharedReplaceableClient<T>) -> Self {
|
|
219
|
+
c.inner_clone().into()
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
impl<T> From<Arc<T>> for AnyClient
|
|
224
|
+
where
|
|
225
|
+
T: Into<AnyClient> + Clone,
|
|
226
|
+
{
|
|
227
|
+
fn from(c: Arc<T>) -> Self {
|
|
228
|
+
Arc::unwrap_or_clone(c).into()
|
|
212
229
|
}
|
|
213
230
|
}
|
|
214
231
|
}
|
|
@@ -220,6 +237,37 @@ pub struct CoreRuntime {
|
|
|
220
237
|
telemetry: TelemetryInstance,
|
|
221
238
|
runtime: Option<tokio::runtime::Runtime>,
|
|
222
239
|
runtime_handle: tokio::runtime::Handle,
|
|
240
|
+
heartbeat_interval: Option<Duration>,
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/// Holds telemetry options, as well as worker heartbeat_interval. Construct with [RuntimeOptionsBuilder]
|
|
244
|
+
#[derive(Default, derive_builder::Builder)]
|
|
245
|
+
#[builder(build_fn(validate = "Self::validate"))]
|
|
246
|
+
#[non_exhaustive]
|
|
247
|
+
pub struct RuntimeOptions {
|
|
248
|
+
/// Telemetry configuration options.
|
|
249
|
+
#[builder(default)]
|
|
250
|
+
telemetry_options: TelemetryOptions,
|
|
251
|
+
/// Optional worker heartbeat interval - This configures the heartbeat setting of all
|
|
252
|
+
/// workers created using this runtime.
|
|
253
|
+
///
|
|
254
|
+
/// Interval must be between 1s and 60s, inclusive.
|
|
255
|
+
#[builder(default = "Some(Duration::from_secs(60))")]
|
|
256
|
+
heartbeat_interval: Option<Duration>,
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
impl RuntimeOptionsBuilder {
|
|
260
|
+
fn validate(&self) -> Result<(), String> {
|
|
261
|
+
if let Some(Some(interval)) = self.heartbeat_interval
|
|
262
|
+
&& (interval < Duration::from_secs(1) || interval > Duration::from_secs(60))
|
|
263
|
+
{
|
|
264
|
+
return Err(format!(
|
|
265
|
+
"heartbeat_interval ({interval:?}) must be between 1s and 60s",
|
|
266
|
+
));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
Ok(())
|
|
270
|
+
}
|
|
223
271
|
}
|
|
224
272
|
|
|
225
273
|
/// Wraps a [tokio::runtime::Builder] to allow layering multiple on_thread_start functions
|
|
@@ -254,13 +302,13 @@ impl CoreRuntime {
|
|
|
254
302
|
/// If a tokio runtime has already been initialized. To re-use an existing runtime, call
|
|
255
303
|
/// [CoreRuntime::new_assume_tokio].
|
|
256
304
|
pub fn new<F>(
|
|
257
|
-
|
|
305
|
+
runtime_options: RuntimeOptions,
|
|
258
306
|
mut tokio_builder: TokioRuntimeBuilder<F>,
|
|
259
307
|
) -> Result<Self, anyhow::Error>
|
|
260
308
|
where
|
|
261
309
|
F: Fn() + Send + Sync + 'static,
|
|
262
310
|
{
|
|
263
|
-
let telemetry = telemetry_init(telemetry_options)?;
|
|
311
|
+
let telemetry = telemetry_init(runtime_options.telemetry_options)?;
|
|
264
312
|
let subscriber = telemetry.trace_subscriber();
|
|
265
313
|
let runtime = tokio_builder
|
|
266
314
|
.inner
|
|
@@ -275,7 +323,8 @@ impl CoreRuntime {
|
|
|
275
323
|
})
|
|
276
324
|
.build()?;
|
|
277
325
|
let _rg = runtime.enter();
|
|
278
|
-
let mut me =
|
|
326
|
+
let mut me =
|
|
327
|
+
Self::new_assume_tokio_initialized_telem(telemetry, runtime_options.heartbeat_interval);
|
|
279
328
|
me.runtime = Some(runtime);
|
|
280
329
|
Ok(me)
|
|
281
330
|
}
|
|
@@ -285,9 +334,12 @@ impl CoreRuntime {
|
|
|
285
334
|
///
|
|
286
335
|
/// # Panics
|
|
287
336
|
/// If there is no currently active Tokio runtime
|
|
288
|
-
pub fn new_assume_tokio(
|
|
289
|
-
let telemetry = telemetry_init(telemetry_options)?;
|
|
290
|
-
Ok(Self::new_assume_tokio_initialized_telem(
|
|
337
|
+
pub fn new_assume_tokio(runtime_options: RuntimeOptions) -> Result<Self, anyhow::Error> {
|
|
338
|
+
let telemetry = telemetry_init(runtime_options.telemetry_options)?;
|
|
339
|
+
Ok(Self::new_assume_tokio_initialized_telem(
|
|
340
|
+
telemetry,
|
|
341
|
+
runtime_options.heartbeat_interval,
|
|
342
|
+
))
|
|
291
343
|
}
|
|
292
344
|
|
|
293
345
|
/// Construct a runtime from an already-initialized telemetry instance, assuming a tokio runtime
|
|
@@ -295,7 +347,10 @@ impl CoreRuntime {
|
|
|
295
347
|
///
|
|
296
348
|
/// # Panics
|
|
297
349
|
/// If there is no currently active Tokio runtime
|
|
298
|
-
pub fn new_assume_tokio_initialized_telem(
|
|
350
|
+
pub fn new_assume_tokio_initialized_telem(
|
|
351
|
+
telemetry: TelemetryInstance,
|
|
352
|
+
heartbeat_interval: Option<Duration>,
|
|
353
|
+
) -> Self {
|
|
299
354
|
let runtime_handle = tokio::runtime::Handle::current();
|
|
300
355
|
if let Some(sub) = telemetry.trace_subscriber() {
|
|
301
356
|
set_trace_subscriber_for_current_thread(sub);
|
|
@@ -304,6 +359,7 @@ impl CoreRuntime {
|
|
|
304
359
|
telemetry,
|
|
305
360
|
runtime: None,
|
|
306
361
|
runtime_handle,
|
|
362
|
+
heartbeat_interval,
|
|
307
363
|
}
|
|
308
364
|
}
|
|
309
365
|
|
|
@@ -3,9 +3,9 @@ mod poll_buffer;
|
|
|
3
3
|
pub(crate) use poll_buffer::{
|
|
4
4
|
ActivityTaskOptions, LongPollBuffer, WorkflowTaskOptions, WorkflowTaskPoller,
|
|
5
5
|
};
|
|
6
|
-
pub use
|
|
7
|
-
Client, ClientOptions,
|
|
8
|
-
|
|
6
|
+
pub use temporalio_client::{
|
|
7
|
+
Client, ClientOptions, ClientTlsOptions, RetryClient, RetryOptions, TlsOptions,
|
|
8
|
+
WorkflowClientTrait,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
use crate::{
|
|
@@ -15,23 +15,25 @@ use crate::{
|
|
|
15
15
|
use anyhow::{anyhow, bail};
|
|
16
16
|
use futures_util::{Stream, stream};
|
|
17
17
|
use std::{fmt::Debug, marker::PhantomData};
|
|
18
|
-
use
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
use temporalio_common::{
|
|
19
|
+
protos::temporal::api::workflowservice::v1::{
|
|
20
|
+
PollActivityTaskQueueResponse, PollNexusTaskQueueResponse, PollWorkflowTaskQueueResponse,
|
|
21
|
+
},
|
|
22
|
+
worker::{ActivitySlotKind, NexusSlotKind, SlotKind, WorkflowSlotKind},
|
|
21
23
|
};
|
|
22
24
|
use tokio::select;
|
|
23
25
|
use tokio_util::sync::CancellationToken;
|
|
24
26
|
|
|
25
|
-
#[cfg(test)]
|
|
27
|
+
#[cfg(any(feature = "test-utilities", test))]
|
|
26
28
|
use futures_util::Future;
|
|
27
|
-
#[cfg(test)]
|
|
29
|
+
#[cfg(any(feature = "test-utilities", test))]
|
|
28
30
|
pub(crate) use poll_buffer::MockPermittedPollBuffer;
|
|
29
31
|
|
|
30
32
|
pub(crate) type Result<T, E = tonic::Status> = std::result::Result<T, E>;
|
|
31
33
|
|
|
32
34
|
/// A trait for things that long poll the server.
|
|
33
|
-
#[cfg_attr(test, mockall::automock)]
|
|
34
|
-
#[cfg_attr(test, allow(unused))]
|
|
35
|
+
#[cfg_attr(any(feature = "test-utilities", test), mockall::automock)]
|
|
36
|
+
#[cfg_attr(any(feature = "test-utilities", test), allow(unused))]
|
|
35
37
|
#[async_trait::async_trait]
|
|
36
38
|
pub(crate) trait Poller<PollResult>
|
|
37
39
|
where
|
|
@@ -79,7 +81,7 @@ where
|
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
#[cfg(test)]
|
|
84
|
+
#[cfg(any(feature = "test-utilities", test))]
|
|
83
85
|
mockall::mock! {
|
|
84
86
|
pub ManualPoller<T: Send + Sync + 'static> {}
|
|
85
87
|
#[allow(unused)]
|
|
@@ -6,6 +6,7 @@ use crate::{
|
|
|
6
6
|
client::{PollActivityOptions, PollOptions, PollWorkflowOptions, WorkerClient},
|
|
7
7
|
},
|
|
8
8
|
};
|
|
9
|
+
use crossbeam_utils::atomic::AtomicCell;
|
|
9
10
|
use futures_util::{FutureExt, StreamExt, future::BoxFuture};
|
|
10
11
|
use governor::{Quota, RateLimiter};
|
|
11
12
|
use std::{
|
|
@@ -16,17 +17,20 @@ use std::{
|
|
|
16
17
|
Arc,
|
|
17
18
|
atomic::{AtomicBool, AtomicUsize, Ordering},
|
|
18
19
|
},
|
|
19
|
-
time::Duration,
|
|
20
|
+
time::{Duration, SystemTime},
|
|
20
21
|
};
|
|
21
|
-
use
|
|
22
|
-
|
|
23
|
-
ActivitySlotKind, NexusSlotKind, PollerBehavior, SlotKind, WorkflowSlotKind,
|
|
22
|
+
use temporalio_client::{
|
|
23
|
+
ERROR_RETURNED_DUE_TO_SHORT_CIRCUIT, request_extensions::NoRetryOnMatching,
|
|
24
24
|
};
|
|
25
|
-
use
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
use temporalio_common::{
|
|
26
|
+
protos::temporal::api::{
|
|
27
|
+
taskqueue::v1::PollerScalingDecision,
|
|
28
|
+
workflowservice::v1::{
|
|
29
|
+
PollActivityTaskQueueResponse, PollNexusTaskQueueResponse,
|
|
30
|
+
PollWorkflowTaskQueueResponse,
|
|
31
|
+
},
|
|
29
32
|
},
|
|
33
|
+
worker::{ActivitySlotKind, NexusSlotKind, PollerBehavior, SlotKind, WorkflowSlotKind},
|
|
30
34
|
};
|
|
31
35
|
use tokio::{
|
|
32
36
|
sync::{
|
|
@@ -74,9 +78,15 @@ impl LongPollBuffer<PollWorkflowTaskQueueResponse, WorkflowSlotKind> {
|
|
|
74
78
|
shutdown: CancellationToken,
|
|
75
79
|
num_pollers_handler: Option<impl Fn(usize) + Send + Sync + 'static>,
|
|
76
80
|
options: WorkflowTaskOptions,
|
|
81
|
+
last_successful_poll_time: Arc<AtomicCell<Option<SystemTime>>>,
|
|
77
82
|
) -> Self {
|
|
78
83
|
let is_sticky = sticky_queue.is_some();
|
|
79
|
-
let poll_scaler = PollScaler::new(
|
|
84
|
+
let poll_scaler = PollScaler::new(
|
|
85
|
+
poller_behavior,
|
|
86
|
+
num_pollers_handler,
|
|
87
|
+
shutdown.clone(),
|
|
88
|
+
last_successful_poll_time,
|
|
89
|
+
);
|
|
80
90
|
if let Some(wftps) = options.wft_poller_shared.as_ref() {
|
|
81
91
|
if is_sticky {
|
|
82
92
|
wftps.set_sticky_active(poll_scaler.active_rx.clone());
|
|
@@ -136,6 +146,7 @@ impl LongPollBuffer<PollWorkflowTaskQueueResponse, WorkflowSlotKind> {
|
|
|
136
146
|
}
|
|
137
147
|
|
|
138
148
|
impl LongPollBuffer<PollActivityTaskQueueResponse, ActivitySlotKind> {
|
|
149
|
+
#[allow(clippy::too_many_arguments)]
|
|
139
150
|
pub(crate) fn new_activity_task(
|
|
140
151
|
client: Arc<dyn WorkerClient>,
|
|
141
152
|
task_queue: String,
|
|
@@ -144,6 +155,7 @@ impl LongPollBuffer<PollActivityTaskQueueResponse, ActivitySlotKind> {
|
|
|
144
155
|
shutdown: CancellationToken,
|
|
145
156
|
num_pollers_handler: Option<impl Fn(usize) + Send + Sync + 'static>,
|
|
146
157
|
options: ActivityTaskOptions,
|
|
158
|
+
last_successful_poll_time: Arc<AtomicCell<Option<SystemTime>>>,
|
|
147
159
|
) -> Self {
|
|
148
160
|
let pre_permit_delay = options
|
|
149
161
|
.max_worker_acts_per_second
|
|
@@ -183,7 +195,12 @@ impl LongPollBuffer<PollActivityTaskQueueResponse, ActivitySlotKind> {
|
|
|
183
195
|
}
|
|
184
196
|
};
|
|
185
197
|
|
|
186
|
-
let poll_scaler = PollScaler::new(
|
|
198
|
+
let poll_scaler = PollScaler::new(
|
|
199
|
+
poller_behavior,
|
|
200
|
+
num_pollers_handler,
|
|
201
|
+
shutdown.clone(),
|
|
202
|
+
last_successful_poll_time,
|
|
203
|
+
);
|
|
187
204
|
Self::new(
|
|
188
205
|
poll_fn,
|
|
189
206
|
permit_dealer,
|
|
@@ -196,6 +213,7 @@ impl LongPollBuffer<PollActivityTaskQueueResponse, ActivitySlotKind> {
|
|
|
196
213
|
}
|
|
197
214
|
|
|
198
215
|
impl LongPollBuffer<PollNexusTaskQueueResponse, NexusSlotKind> {
|
|
216
|
+
#[allow(clippy::too_many_arguments)]
|
|
199
217
|
pub(crate) fn new_nexus_task(
|
|
200
218
|
client: Arc<dyn WorkerClient>,
|
|
201
219
|
task_queue: String,
|
|
@@ -203,6 +221,8 @@ impl LongPollBuffer<PollNexusTaskQueueResponse, NexusSlotKind> {
|
|
|
203
221
|
permit_dealer: MeteredPermitDealer<NexusSlotKind>,
|
|
204
222
|
shutdown: CancellationToken,
|
|
205
223
|
num_pollers_handler: Option<impl Fn(usize) + Send + Sync + 'static>,
|
|
224
|
+
last_successful_poll_time: Arc<AtomicCell<Option<SystemTime>>>,
|
|
225
|
+
send_heartbeat: bool,
|
|
206
226
|
) -> Self {
|
|
207
227
|
let no_retry = if matches!(poller_behavior, PollerBehavior::Autoscaling { .. }) {
|
|
208
228
|
Some(NoRetryOnMatching {
|
|
@@ -216,11 +236,14 @@ impl LongPollBuffer<PollNexusTaskQueueResponse, NexusSlotKind> {
|
|
|
216
236
|
let task_queue = task_queue.clone();
|
|
217
237
|
async move {
|
|
218
238
|
client
|
|
219
|
-
.poll_nexus_task(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
239
|
+
.poll_nexus_task(
|
|
240
|
+
PollOptions {
|
|
241
|
+
task_queue,
|
|
242
|
+
no_retry,
|
|
243
|
+
timeout_override,
|
|
244
|
+
},
|
|
245
|
+
send_heartbeat,
|
|
246
|
+
)
|
|
224
247
|
.await
|
|
225
248
|
}
|
|
226
249
|
};
|
|
@@ -228,7 +251,12 @@ impl LongPollBuffer<PollNexusTaskQueueResponse, NexusSlotKind> {
|
|
|
228
251
|
poll_fn,
|
|
229
252
|
permit_dealer,
|
|
230
253
|
shutdown.clone(),
|
|
231
|
-
PollScaler::new(
|
|
254
|
+
PollScaler::new(
|
|
255
|
+
poller_behavior,
|
|
256
|
+
num_pollers_handler,
|
|
257
|
+
shutdown,
|
|
258
|
+
last_successful_poll_time,
|
|
259
|
+
),
|
|
232
260
|
None::<fn() -> BoxFuture<'static, ()>>,
|
|
233
261
|
None::<fn(&PollNexusTaskQueueResponse)>,
|
|
234
262
|
)
|
|
@@ -413,6 +441,7 @@ where
|
|
|
413
441
|
behavior: PollerBehavior,
|
|
414
442
|
num_pollers_handler: Option<F>,
|
|
415
443
|
shutdown: CancellationToken,
|
|
444
|
+
last_successful_poll_time: Arc<AtomicCell<Option<SystemTime>>>,
|
|
416
445
|
) -> Self {
|
|
417
446
|
let (active_tx, active_rx) = watch::channel(0);
|
|
418
447
|
let num_pollers_handler = num_pollers_handler.map(Arc::new);
|
|
@@ -433,6 +462,7 @@ where
|
|
|
433
462
|
ingested_this_period: Default::default(),
|
|
434
463
|
ingested_last_period: Default::default(),
|
|
435
464
|
scale_up_allowed: AtomicBool::new(true),
|
|
465
|
+
last_successful_poll_time,
|
|
436
466
|
});
|
|
437
467
|
let rhc = report_handle.clone();
|
|
438
468
|
let ingestor_task = if behavior.is_autoscaling() {
|
|
@@ -495,6 +525,7 @@ struct PollScalerReportHandle {
|
|
|
495
525
|
ingested_this_period: AtomicUsize,
|
|
496
526
|
ingested_last_period: AtomicUsize,
|
|
497
527
|
scale_up_allowed: AtomicBool,
|
|
528
|
+
last_successful_poll_time: Arc<AtomicCell<Option<SystemTime>>>,
|
|
498
529
|
}
|
|
499
530
|
|
|
500
531
|
impl PollScalerReportHandle {
|
|
@@ -502,6 +533,8 @@ impl PollScalerReportHandle {
|
|
|
502
533
|
fn poll_result(&self, res: &Result<impl TaskPollerResult, tonic::Status>) -> bool {
|
|
503
534
|
match res {
|
|
504
535
|
Ok(res) => {
|
|
536
|
+
self.last_successful_poll_time
|
|
537
|
+
.store(Some(SystemTime::now()));
|
|
505
538
|
if let PollerBehavior::SimpleMaximum(_) = self.behavior {
|
|
506
539
|
// We don't do auto-scaling with the simple max
|
|
507
540
|
return true;
|
|
@@ -666,14 +699,14 @@ impl TaskPollerResult for PollNexusTaskQueueResponse {
|
|
|
666
699
|
}
|
|
667
700
|
}
|
|
668
701
|
|
|
669
|
-
#[cfg(test)]
|
|
702
|
+
#[cfg(any(feature = "test-utilities", test))]
|
|
670
703
|
#[derive(derive_more::Constructor)]
|
|
671
704
|
pub(crate) struct MockPermittedPollBuffer<PT, SK: SlotKind> {
|
|
672
705
|
sem: Arc<MeteredPermitDealer<SK>>,
|
|
673
706
|
inner: PT,
|
|
674
707
|
}
|
|
675
708
|
|
|
676
|
-
#[cfg(test)]
|
|
709
|
+
#[cfg(any(feature = "test-utilities", test))]
|
|
677
710
|
#[async_trait::async_trait]
|
|
678
711
|
impl<T, PT, SK> Poller<(T, OwnedMeteredSemPermit<SK>)> for MockPermittedPollBuffer<PT, SK>
|
|
679
712
|
where
|
|
@@ -735,6 +768,7 @@ mod tests {
|
|
|
735
768
|
WorkflowTaskOptions {
|
|
736
769
|
wft_poller_shared: Some(Arc::new(WFTPollerShared::new(Some(10)))),
|
|
737
770
|
},
|
|
771
|
+
Arc::new(AtomicCell::new(None)),
|
|
738
772
|
);
|
|
739
773
|
|
|
740
774
|
// Poll a bunch of times, "interrupting" it each time, we should only actually have polled
|
|
@@ -790,6 +824,7 @@ mod tests {
|
|
|
790
824
|
WorkflowTaskOptions {
|
|
791
825
|
wft_poller_shared: Some(Arc::new(WFTPollerShared::new(Some(1)))),
|
|
792
826
|
},
|
|
827
|
+
Arc::new(AtomicCell::new(None)),
|
|
793
828
|
);
|
|
794
829
|
|
|
795
830
|
// Should not see error, unwraps should get empty response
|