@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
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
//! Worker-specific client needs
|
|
2
2
|
|
|
3
3
|
pub(crate) mod mocks;
|
|
4
|
-
use crate::abstractions::dbg_panic;
|
|
5
4
|
use crate::protosext::legacy_query_failure;
|
|
6
|
-
use
|
|
7
|
-
use
|
|
8
|
-
use std::
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
SlotManager, WorkflowService,
|
|
5
|
+
use parking_lot::Mutex;
|
|
6
|
+
use prost_types::Duration as PbDuration;
|
|
7
|
+
use std::{
|
|
8
|
+
collections::HashMap,
|
|
9
|
+
sync::Arc,
|
|
10
|
+
time::{Duration, SystemTime},
|
|
13
11
|
};
|
|
14
|
-
use
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
use temporalio_client::{
|
|
13
|
+
Client, Namespace, NamespacedClient, RetryClient, RetryOptions, SharedReplaceableClient,
|
|
14
|
+
WorkflowService,
|
|
15
|
+
request_extensions::{IsWorkerTaskLongPoll, NoRetryOnMatching, RetryConfigForCall},
|
|
16
|
+
worker::ClientWorkerSet,
|
|
17
|
+
};
|
|
18
|
+
use temporalio_common::{
|
|
19
|
+
protos::{
|
|
20
|
+
TaskToken,
|
|
21
|
+
coresdk::{workflow_commands::QueryResult, workflow_completion},
|
|
22
|
+
temporal::api::{
|
|
23
|
+
command::v1::Command,
|
|
24
|
+
common::v1::{
|
|
25
|
+
MeteringMetadata, Payloads, WorkerVersionCapabilities, WorkerVersionStamp,
|
|
26
|
+
WorkflowExecution,
|
|
27
|
+
},
|
|
28
|
+
deployment,
|
|
29
|
+
enums::v1::{
|
|
30
|
+
TaskQueueKind, VersioningBehavior, WorkerStatus, WorkerVersioningMode,
|
|
31
|
+
WorkflowTaskFailedCause,
|
|
32
|
+
},
|
|
33
|
+
failure::v1::Failure,
|
|
34
|
+
nexus,
|
|
35
|
+
protocol::v1::Message as ProtocolMessage,
|
|
36
|
+
query::v1::WorkflowQueryResult,
|
|
37
|
+
sdk::v1::WorkflowTaskCompletedMetadata,
|
|
38
|
+
taskqueue::v1::{StickyExecutionAttributes, TaskQueue, TaskQueueMetadata},
|
|
39
|
+
worker::v1::{WorkerHeartbeat, WorkerSlotsInfo},
|
|
40
|
+
workflowservice::v1::{get_system_info_response::Capabilities, *},
|
|
28
41
|
},
|
|
29
|
-
failure::v1::Failure,
|
|
30
|
-
nexus,
|
|
31
|
-
protocol::v1::Message as ProtocolMessage,
|
|
32
|
-
query::v1::WorkflowQueryResult,
|
|
33
|
-
sdk::v1::WorkflowTaskCompletedMetadata,
|
|
34
|
-
taskqueue::v1::{StickyExecutionAttributes, TaskQueue, TaskQueueMetadata},
|
|
35
|
-
workflowservice::v1::{get_system_info_response::Capabilities, *},
|
|
36
42
|
},
|
|
43
|
+
worker::WorkerVersioningStrategy,
|
|
37
44
|
};
|
|
38
45
|
use tonic::IntoRequest;
|
|
46
|
+
use uuid::Uuid;
|
|
39
47
|
|
|
40
48
|
type Result<T, E = tonic::Status> = std::result::Result<T, E>;
|
|
41
49
|
|
|
@@ -46,34 +54,29 @@ pub enum LegacyQueryResult {
|
|
|
46
54
|
|
|
47
55
|
/// Contains everything a worker needs to interact with the server
|
|
48
56
|
pub(crate) struct WorkerClientBag {
|
|
49
|
-
|
|
57
|
+
client: RetryClient<SharedReplaceableClient<Client>>,
|
|
50
58
|
namespace: String,
|
|
51
59
|
identity: String,
|
|
52
60
|
worker_versioning_strategy: WorkerVersioningStrategy,
|
|
53
|
-
|
|
61
|
+
worker_heartbeat_map: Arc<Mutex<HashMap<String, ClientHeartbeatData>>>,
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
impl WorkerClientBag {
|
|
57
65
|
pub(crate) fn new(
|
|
58
|
-
client: RetryClient<Client
|
|
66
|
+
client: RetryClient<SharedReplaceableClient<Client>>,
|
|
59
67
|
namespace: String,
|
|
60
68
|
identity: String,
|
|
61
69
|
worker_versioning_strategy: WorkerVersioningStrategy,
|
|
62
|
-
heartbeat_data: Option<Arc<OnceLock<HeartbeatFn>>>,
|
|
63
70
|
) -> Self {
|
|
64
71
|
Self {
|
|
65
|
-
|
|
72
|
+
client,
|
|
66
73
|
namespace,
|
|
67
74
|
identity,
|
|
68
75
|
worker_versioning_strategy,
|
|
69
|
-
|
|
76
|
+
worker_heartbeat_map: Arc::new(Mutex::new(HashMap::new())),
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
79
|
|
|
73
|
-
fn cloned_client(&self) -> RetryClient<Client> {
|
|
74
|
-
self.replaceable_client.read().clone()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
80
|
fn default_capabilities(&self) -> Capabilities {
|
|
78
81
|
self.capabilities().unwrap_or_default()
|
|
79
82
|
}
|
|
@@ -127,24 +130,11 @@ impl WorkerClientBag {
|
|
|
127
130
|
None
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
|
-
|
|
131
|
-
fn capture_heartbeat(&self) -> Option<WorkerHeartbeat> {
|
|
132
|
-
if let Some(heartbeat_data) = self.heartbeat_data.as_ref() {
|
|
133
|
-
if let Some(hb) = heartbeat_data.get() {
|
|
134
|
-
hb()
|
|
135
|
-
} else {
|
|
136
|
-
dbg_panic!("Heartbeat function never set");
|
|
137
|
-
None
|
|
138
|
-
}
|
|
139
|
-
} else {
|
|
140
|
-
None
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
133
|
}
|
|
144
134
|
|
|
145
135
|
/// This trait contains everything workers need to interact with Temporal, and hence provides a
|
|
146
|
-
/// minimal mocking surface.
|
|
147
|
-
#[cfg_attr(test, mockall::automock)]
|
|
136
|
+
/// minimal mocking surface.
|
|
137
|
+
#[cfg_attr(any(feature = "test-utilities", test), mockall::automock)]
|
|
148
138
|
#[async_trait::async_trait]
|
|
149
139
|
pub trait WorkerClient: Sync + Send {
|
|
150
140
|
/// Poll workflow tasks
|
|
@@ -163,6 +153,7 @@ pub trait WorkerClient: Sync + Send {
|
|
|
163
153
|
async fn poll_nexus_task(
|
|
164
154
|
&self,
|
|
165
155
|
poll_options: PollOptions,
|
|
156
|
+
send_heartbeat: bool,
|
|
166
157
|
) -> Result<PollNexusTaskQueueResponse>;
|
|
167
158
|
/// Complete a workflow task
|
|
168
159
|
async fn complete_workflow_task(
|
|
@@ -228,25 +219,35 @@ pub trait WorkerClient: Sync + Send {
|
|
|
228
219
|
/// Describe the namespace
|
|
229
220
|
async fn describe_namespace(&self) -> Result<DescribeNamespaceResponse>;
|
|
230
221
|
/// Shutdown the worker
|
|
231
|
-
async fn shutdown_worker(
|
|
222
|
+
async fn shutdown_worker(
|
|
223
|
+
&self,
|
|
224
|
+
sticky_task_queue: String,
|
|
225
|
+
final_heartbeat: Option<WorkerHeartbeat>,
|
|
226
|
+
) -> Result<ShutdownWorkerResponse>;
|
|
232
227
|
/// Record a worker heartbeat
|
|
233
228
|
async fn record_worker_heartbeat(
|
|
234
229
|
&self,
|
|
235
|
-
|
|
230
|
+
namespace: String,
|
|
231
|
+
worker_heartbeat: Vec<WorkerHeartbeat>,
|
|
236
232
|
) -> Result<RecordWorkerHeartbeatResponse>;
|
|
237
233
|
|
|
238
234
|
/// Replace the underlying client
|
|
239
|
-
fn replace_client(&self, new_client:
|
|
235
|
+
fn replace_client(&self, new_client: Client);
|
|
240
236
|
/// Return server capabilities
|
|
241
237
|
fn capabilities(&self) -> Option<Capabilities>;
|
|
242
238
|
/// Return workers using this client
|
|
243
|
-
fn workers(&self) -> Arc<
|
|
239
|
+
fn workers(&self) -> Arc<ClientWorkerSet>;
|
|
244
240
|
/// Indicates if this is a mock client
|
|
245
241
|
fn is_mock(&self) -> bool;
|
|
246
242
|
/// Return name and version of the SDK
|
|
247
243
|
fn sdk_name_and_version(&self) -> (String, String);
|
|
248
244
|
/// Get worker identity
|
|
249
|
-
fn
|
|
245
|
+
fn identity(&self) -> String;
|
|
246
|
+
/// Get worker grouping key
|
|
247
|
+
fn worker_grouping_key(&self) -> Uuid;
|
|
248
|
+
/// Sets the client-reliant fields for WorkerHeartbeat. This also updates client-level tracking
|
|
249
|
+
/// of heartbeat fields, like last heartbeat timestamp.
|
|
250
|
+
fn set_heartbeat_client_fields(&self, heartbeat: &mut WorkerHeartbeat);
|
|
250
251
|
}
|
|
251
252
|
|
|
252
253
|
/// Configuration options shared by workflow, activity, and Nexus polling calls
|
|
@@ -312,7 +313,8 @@ impl WorkerClient for WorkerClientBag {
|
|
|
312
313
|
}
|
|
313
314
|
|
|
314
315
|
Ok(self
|
|
315
|
-
.
|
|
316
|
+
.client
|
|
317
|
+
.clone()
|
|
316
318
|
.poll_workflow_task_queue(request)
|
|
317
319
|
.await?
|
|
318
320
|
.into_inner())
|
|
@@ -349,7 +351,8 @@ impl WorkerClient for WorkerClientBag {
|
|
|
349
351
|
}
|
|
350
352
|
|
|
351
353
|
Ok(self
|
|
352
|
-
.
|
|
354
|
+
.client
|
|
355
|
+
.clone()
|
|
353
356
|
.poll_activity_task_queue(request)
|
|
354
357
|
.await?
|
|
355
358
|
.into_inner())
|
|
@@ -358,6 +361,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
358
361
|
async fn poll_nexus_task(
|
|
359
362
|
&self,
|
|
360
363
|
poll_options: PollOptions,
|
|
364
|
+
_send_heartbeat: bool,
|
|
361
365
|
) -> Result<PollNexusTaskQueueResponse> {
|
|
362
366
|
#[allow(deprecated)] // want to list all fields explicitly
|
|
363
367
|
let mut request = PollNexusTaskQueueRequest {
|
|
@@ -370,7 +374,7 @@ impl WorkerClient for WorkerClientBag {
|
|
|
370
374
|
identity: self.identity.clone(),
|
|
371
375
|
worker_version_capabilities: self.worker_version_capabilities(),
|
|
372
376
|
deployment_options: self.deployment_options(),
|
|
373
|
-
worker_heartbeat:
|
|
377
|
+
worker_heartbeat: Vec::new(),
|
|
374
378
|
}
|
|
375
379
|
.into_request();
|
|
376
380
|
request.extensions_mut().insert(IsWorkerTaskLongPoll);
|
|
@@ -382,7 +386,8 @@ impl WorkerClient for WorkerClientBag {
|
|
|
382
386
|
}
|
|
383
387
|
|
|
384
388
|
Ok(self
|
|
385
|
-
.
|
|
389
|
+
.client
|
|
390
|
+
.clone()
|
|
386
391
|
.poll_nexus_task_queue(request)
|
|
387
392
|
.await?
|
|
388
393
|
.into_inner())
|
|
@@ -432,8 +437,9 @@ impl WorkerClient for WorkerClientBag {
|
|
|
432
437
|
deployment_options: self.deployment_options(),
|
|
433
438
|
};
|
|
434
439
|
Ok(self
|
|
435
|
-
.
|
|
436
|
-
.
|
|
440
|
+
.client
|
|
441
|
+
.clone()
|
|
442
|
+
.respond_workflow_task_completed(request.into_request())
|
|
437
443
|
.await?
|
|
438
444
|
.into_inner())
|
|
439
445
|
}
|
|
@@ -444,7 +450,8 @@ impl WorkerClient for WorkerClientBag {
|
|
|
444
450
|
result: Option<Payloads>,
|
|
445
451
|
) -> Result<RespondActivityTaskCompletedResponse> {
|
|
446
452
|
Ok(self
|
|
447
|
-
.
|
|
453
|
+
.client
|
|
454
|
+
.clone()
|
|
448
455
|
.respond_activity_task_completed(
|
|
449
456
|
#[allow(deprecated)] // want to list all fields explicitly
|
|
450
457
|
RespondActivityTaskCompletedRequest {
|
|
@@ -456,7 +463,8 @@ impl WorkerClient for WorkerClientBag {
|
|
|
456
463
|
// Will never be set, deprecated.
|
|
457
464
|
deployment: None,
|
|
458
465
|
deployment_options: self.deployment_options(),
|
|
459
|
-
}
|
|
466
|
+
}
|
|
467
|
+
.into_request(),
|
|
460
468
|
)
|
|
461
469
|
.await?
|
|
462
470
|
.into_inner())
|
|
@@ -468,13 +476,17 @@ impl WorkerClient for WorkerClientBag {
|
|
|
468
476
|
response: nexus::v1::Response,
|
|
469
477
|
) -> Result<RespondNexusTaskCompletedResponse> {
|
|
470
478
|
Ok(self
|
|
471
|
-
.
|
|
472
|
-
.
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
479
|
+
.client
|
|
480
|
+
.clone()
|
|
481
|
+
.respond_nexus_task_completed(
|
|
482
|
+
RespondNexusTaskCompletedRequest {
|
|
483
|
+
namespace: self.namespace.clone(),
|
|
484
|
+
identity: self.identity.clone(),
|
|
485
|
+
task_token: task_token.0,
|
|
486
|
+
response: Some(response),
|
|
487
|
+
}
|
|
488
|
+
.into_request(),
|
|
489
|
+
)
|
|
478
490
|
.await?
|
|
479
491
|
.into_inner())
|
|
480
492
|
}
|
|
@@ -485,13 +497,17 @@ impl WorkerClient for WorkerClientBag {
|
|
|
485
497
|
details: Option<Payloads>,
|
|
486
498
|
) -> Result<RecordActivityTaskHeartbeatResponse> {
|
|
487
499
|
Ok(self
|
|
488
|
-
.
|
|
489
|
-
.
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
500
|
+
.client
|
|
501
|
+
.clone()
|
|
502
|
+
.record_activity_task_heartbeat(
|
|
503
|
+
RecordActivityTaskHeartbeatRequest {
|
|
504
|
+
task_token: task_token.0,
|
|
505
|
+
details,
|
|
506
|
+
identity: self.identity.clone(),
|
|
507
|
+
namespace: self.namespace.clone(),
|
|
508
|
+
}
|
|
509
|
+
.into_request(),
|
|
510
|
+
)
|
|
495
511
|
.await?
|
|
496
512
|
.into_inner())
|
|
497
513
|
}
|
|
@@ -502,7 +518,8 @@ impl WorkerClient for WorkerClientBag {
|
|
|
502
518
|
details: Option<Payloads>,
|
|
503
519
|
) -> Result<RespondActivityTaskCanceledResponse> {
|
|
504
520
|
Ok(self
|
|
505
|
-
.
|
|
521
|
+
.client
|
|
522
|
+
.clone()
|
|
506
523
|
.respond_activity_task_canceled(
|
|
507
524
|
#[allow(deprecated)] // want to list all fields explicitly
|
|
508
525
|
RespondActivityTaskCanceledRequest {
|
|
@@ -514,7 +531,8 @@ impl WorkerClient for WorkerClientBag {
|
|
|
514
531
|
// Will never be set, deprecated.
|
|
515
532
|
deployment: None,
|
|
516
533
|
deployment_options: self.deployment_options(),
|
|
517
|
-
}
|
|
534
|
+
}
|
|
535
|
+
.into_request(),
|
|
518
536
|
)
|
|
519
537
|
.await?
|
|
520
538
|
.into_inner())
|
|
@@ -526,7 +544,8 @@ impl WorkerClient for WorkerClientBag {
|
|
|
526
544
|
failure: Option<Failure>,
|
|
527
545
|
) -> Result<RespondActivityTaskFailedResponse> {
|
|
528
546
|
Ok(self
|
|
529
|
-
.
|
|
547
|
+
.client
|
|
548
|
+
.clone()
|
|
530
549
|
.respond_activity_task_failed(
|
|
531
550
|
#[allow(deprecated)] // want to list all fields explicitly
|
|
532
551
|
RespondActivityTaskFailedRequest {
|
|
@@ -540,7 +559,8 @@ impl WorkerClient for WorkerClientBag {
|
|
|
540
559
|
// Will never be set, deprecated.
|
|
541
560
|
deployment: None,
|
|
542
561
|
deployment_options: self.deployment_options(),
|
|
543
|
-
}
|
|
562
|
+
}
|
|
563
|
+
.into_request(),
|
|
544
564
|
)
|
|
545
565
|
.await?
|
|
546
566
|
.into_inner())
|
|
@@ -567,8 +587,9 @@ impl WorkerClient for WorkerClientBag {
|
|
|
567
587
|
deployment_options: self.deployment_options(),
|
|
568
588
|
};
|
|
569
589
|
Ok(self
|
|
570
|
-
.
|
|
571
|
-
.
|
|
590
|
+
.client
|
|
591
|
+
.clone()
|
|
592
|
+
.respond_workflow_task_failed(request.into_request())
|
|
572
593
|
.await?
|
|
573
594
|
.into_inner())
|
|
574
595
|
}
|
|
@@ -579,13 +600,17 @@ impl WorkerClient for WorkerClientBag {
|
|
|
579
600
|
error: nexus::v1::HandlerError,
|
|
580
601
|
) -> Result<RespondNexusTaskFailedResponse> {
|
|
581
602
|
Ok(self
|
|
582
|
-
.
|
|
583
|
-
.
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
603
|
+
.client
|
|
604
|
+
.clone()
|
|
605
|
+
.respond_nexus_task_failed(
|
|
606
|
+
RespondNexusTaskFailedRequest {
|
|
607
|
+
namespace: self.namespace.clone(),
|
|
608
|
+
identity: self.identity.clone(),
|
|
609
|
+
task_token: task_token.0,
|
|
610
|
+
error: Some(error),
|
|
611
|
+
}
|
|
612
|
+
.into_request(),
|
|
613
|
+
)
|
|
589
614
|
.await?
|
|
590
615
|
.into_inner())
|
|
591
616
|
}
|
|
@@ -597,16 +622,20 @@ impl WorkerClient for WorkerClientBag {
|
|
|
597
622
|
page_token: Vec<u8>,
|
|
598
623
|
) -> Result<GetWorkflowExecutionHistoryResponse> {
|
|
599
624
|
Ok(self
|
|
600
|
-
.
|
|
601
|
-
.
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
625
|
+
.client
|
|
626
|
+
.clone()
|
|
627
|
+
.get_workflow_execution_history(
|
|
628
|
+
GetWorkflowExecutionHistoryRequest {
|
|
629
|
+
namespace: self.namespace.clone(),
|
|
630
|
+
execution: Some(WorkflowExecution {
|
|
631
|
+
workflow_id,
|
|
632
|
+
run_id: run_id.unwrap_or_default(),
|
|
633
|
+
}),
|
|
634
|
+
next_page_token: page_token,
|
|
635
|
+
..Default::default()
|
|
636
|
+
}
|
|
637
|
+
.into_request(),
|
|
638
|
+
)
|
|
610
639
|
.await?
|
|
611
640
|
.into_inner())
|
|
612
641
|
}
|
|
@@ -629,74 +658,99 @@ impl WorkerClient for WorkerClientBag {
|
|
|
629
658
|
let (_, completed_type, query_result, error_message) = query_result.into_components();
|
|
630
659
|
|
|
631
660
|
Ok(self
|
|
632
|
-
.
|
|
633
|
-
.
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
661
|
+
.client
|
|
662
|
+
.clone()
|
|
663
|
+
.respond_query_task_completed(
|
|
664
|
+
RespondQueryTaskCompletedRequest {
|
|
665
|
+
task_token: task_token.into(),
|
|
666
|
+
completed_type: completed_type as i32,
|
|
667
|
+
query_result,
|
|
668
|
+
error_message,
|
|
669
|
+
namespace: self.namespace.clone(),
|
|
670
|
+
failure,
|
|
671
|
+
cause: cause.into(),
|
|
672
|
+
}
|
|
673
|
+
.into_request(),
|
|
674
|
+
)
|
|
642
675
|
.await?
|
|
643
676
|
.into_inner())
|
|
644
677
|
}
|
|
645
678
|
|
|
646
679
|
async fn describe_namespace(&self) -> Result<DescribeNamespaceResponse> {
|
|
647
680
|
Ok(self
|
|
648
|
-
.
|
|
681
|
+
.client
|
|
682
|
+
.clone()
|
|
649
683
|
.describe_namespace(
|
|
650
|
-
Namespace::Name(self.namespace.clone())
|
|
684
|
+
Namespace::Name(self.namespace.clone())
|
|
685
|
+
.into_describe_namespace_request()
|
|
686
|
+
.into_request(),
|
|
651
687
|
)
|
|
652
688
|
.await?
|
|
653
689
|
.into_inner())
|
|
654
690
|
}
|
|
655
691
|
|
|
656
|
-
async fn shutdown_worker(
|
|
657
|
-
|
|
692
|
+
async fn shutdown_worker(
|
|
693
|
+
&self,
|
|
694
|
+
sticky_task_queue: String,
|
|
695
|
+
final_heartbeat: Option<WorkerHeartbeat>,
|
|
696
|
+
) -> Result<ShutdownWorkerResponse> {
|
|
697
|
+
let mut final_heartbeat = final_heartbeat;
|
|
698
|
+
if let Some(w) = final_heartbeat.as_mut() {
|
|
699
|
+
w.status = WorkerStatus::Shutdown.into();
|
|
700
|
+
self.set_heartbeat_client_fields(w);
|
|
701
|
+
}
|
|
702
|
+
let mut request = ShutdownWorkerRequest {
|
|
658
703
|
namespace: self.namespace.clone(),
|
|
659
704
|
identity: self.identity.clone(),
|
|
660
705
|
sticky_task_queue,
|
|
661
706
|
reason: "graceful shutdown".to_string(),
|
|
662
|
-
worker_heartbeat:
|
|
663
|
-
}
|
|
707
|
+
worker_heartbeat: final_heartbeat,
|
|
708
|
+
}
|
|
709
|
+
.into_request();
|
|
710
|
+
request
|
|
711
|
+
.extensions_mut()
|
|
712
|
+
.insert(RetryConfigForCall(RetryOptions::no_retries()));
|
|
664
713
|
|
|
665
714
|
Ok(
|
|
666
|
-
WorkflowService::shutdown_worker(&mut self.
|
|
715
|
+
WorkflowService::shutdown_worker(&mut self.client.clone(), request)
|
|
667
716
|
.await?
|
|
668
717
|
.into_inner(),
|
|
669
718
|
)
|
|
670
719
|
}
|
|
671
720
|
|
|
672
|
-
fn replace_client(&self, new_client: RetryClient<Client>) {
|
|
673
|
-
let mut replaceable_client = self.replaceable_client.write();
|
|
674
|
-
*replaceable_client = new_client;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
721
|
async fn record_worker_heartbeat(
|
|
678
722
|
&self,
|
|
679
|
-
|
|
723
|
+
namespace: String,
|
|
724
|
+
worker_heartbeat: Vec<WorkerHeartbeat>,
|
|
680
725
|
) -> Result<RecordWorkerHeartbeatResponse> {
|
|
726
|
+
let request = RecordWorkerHeartbeatRequest {
|
|
727
|
+
namespace,
|
|
728
|
+
identity: self.identity.clone(),
|
|
729
|
+
worker_heartbeat,
|
|
730
|
+
};
|
|
681
731
|
Ok(self
|
|
682
|
-
.
|
|
683
|
-
.
|
|
684
|
-
|
|
685
|
-
identity: self.identity.clone(),
|
|
686
|
-
worker_heartbeat: vec![heartbeat],
|
|
687
|
-
})
|
|
732
|
+
.client
|
|
733
|
+
.clone()
|
|
734
|
+
.record_worker_heartbeat(request.into_request())
|
|
688
735
|
.await?
|
|
689
736
|
.into_inner())
|
|
690
737
|
}
|
|
691
738
|
|
|
739
|
+
fn replace_client(&self, new_client: Client) {
|
|
740
|
+
self.client.get_client().replace_client(new_client);
|
|
741
|
+
}
|
|
742
|
+
|
|
692
743
|
fn capabilities(&self) -> Option<Capabilities> {
|
|
693
|
-
|
|
694
|
-
|
|
744
|
+
self.client
|
|
745
|
+
.get_client()
|
|
746
|
+
.inner_cow()
|
|
747
|
+
.inner()
|
|
748
|
+
.capabilities()
|
|
749
|
+
.cloned()
|
|
695
750
|
}
|
|
696
751
|
|
|
697
|
-
fn workers(&self) -> Arc<
|
|
698
|
-
|
|
699
|
-
client.get_client().inner().workers()
|
|
752
|
+
fn workers(&self) -> Arc<ClientWorkerSet> {
|
|
753
|
+
self.client.get_client().inner_cow().inner().workers()
|
|
700
754
|
}
|
|
701
755
|
|
|
702
756
|
fn is_mock(&self) -> bool {
|
|
@@ -704,23 +758,71 @@ impl WorkerClient for WorkerClientBag {
|
|
|
704
758
|
}
|
|
705
759
|
|
|
706
760
|
fn sdk_name_and_version(&self) -> (String, String) {
|
|
707
|
-
let
|
|
708
|
-
let opts =
|
|
761
|
+
let inner = self.client.get_client().inner_cow();
|
|
762
|
+
let opts = inner.options();
|
|
709
763
|
(opts.client_name.clone(), opts.client_version.clone())
|
|
710
764
|
}
|
|
711
765
|
|
|
712
|
-
fn
|
|
766
|
+
fn identity(&self) -> String {
|
|
713
767
|
self.identity.clone()
|
|
714
768
|
}
|
|
769
|
+
|
|
770
|
+
fn worker_grouping_key(&self) -> Uuid {
|
|
771
|
+
self.client.get_client().inner_cow().worker_grouping_key()
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
fn set_heartbeat_client_fields(&self, heartbeat: &mut WorkerHeartbeat) {
|
|
775
|
+
if let Some(host_info) = heartbeat.host_info.as_mut() {
|
|
776
|
+
host_info.process_key = self.worker_grouping_key().to_string();
|
|
777
|
+
}
|
|
778
|
+
heartbeat.worker_identity = WorkerClient::identity(self);
|
|
779
|
+
let sdk_name_and_ver = self.sdk_name_and_version();
|
|
780
|
+
heartbeat.sdk_name = sdk_name_and_ver.0;
|
|
781
|
+
heartbeat.sdk_version = sdk_name_and_ver.1;
|
|
782
|
+
|
|
783
|
+
let now = SystemTime::now();
|
|
784
|
+
heartbeat.heartbeat_time = Some(now.into());
|
|
785
|
+
let mut heartbeat_map = self.worker_heartbeat_map.lock();
|
|
786
|
+
let client_heartbeat_data = heartbeat_map
|
|
787
|
+
.entry(heartbeat.worker_instance_key.clone())
|
|
788
|
+
.or_default();
|
|
789
|
+
let elapsed_since_last_heartbeat =
|
|
790
|
+
client_heartbeat_data.last_heartbeat_time.map(|hb_time| {
|
|
791
|
+
let dur = now.duration_since(hb_time).unwrap_or(Duration::ZERO);
|
|
792
|
+
PbDuration {
|
|
793
|
+
seconds: dur.as_secs() as i64,
|
|
794
|
+
nanos: dur.subsec_nanos() as i32,
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
heartbeat.elapsed_since_last_heartbeat = elapsed_since_last_heartbeat;
|
|
798
|
+
client_heartbeat_data.last_heartbeat_time = Some(now);
|
|
799
|
+
|
|
800
|
+
update_slots(
|
|
801
|
+
&mut heartbeat.workflow_task_slots_info,
|
|
802
|
+
&mut client_heartbeat_data.workflow_task_slots_info,
|
|
803
|
+
);
|
|
804
|
+
update_slots(
|
|
805
|
+
&mut heartbeat.activity_task_slots_info,
|
|
806
|
+
&mut client_heartbeat_data.activity_task_slots_info,
|
|
807
|
+
);
|
|
808
|
+
update_slots(
|
|
809
|
+
&mut heartbeat.nexus_task_slots_info,
|
|
810
|
+
&mut client_heartbeat_data.nexus_task_slots_info,
|
|
811
|
+
);
|
|
812
|
+
update_slots(
|
|
813
|
+
&mut heartbeat.local_activity_slots_info,
|
|
814
|
+
&mut client_heartbeat_data.local_activity_slots_info,
|
|
815
|
+
);
|
|
816
|
+
}
|
|
715
817
|
}
|
|
716
818
|
|
|
717
819
|
impl NamespacedClient for WorkerClientBag {
|
|
718
|
-
fn namespace(&self) ->
|
|
719
|
-
|
|
820
|
+
fn namespace(&self) -> String {
|
|
821
|
+
self.namespace.clone()
|
|
720
822
|
}
|
|
721
823
|
|
|
722
|
-
fn
|
|
723
|
-
|
|
824
|
+
fn identity(&self) -> String {
|
|
825
|
+
self.identity.clone()
|
|
724
826
|
}
|
|
725
827
|
}
|
|
726
828
|
|
|
@@ -749,3 +851,31 @@ pub struct WorkflowTaskCompletion {
|
|
|
749
851
|
/// Versioning behavior of the workflow, if any.
|
|
750
852
|
pub versioning_behavior: VersioningBehavior,
|
|
751
853
|
}
|
|
854
|
+
|
|
855
|
+
#[derive(Clone, Default)]
|
|
856
|
+
struct SlotsInfo {
|
|
857
|
+
total_processed_tasks: i32,
|
|
858
|
+
total_failed_tasks: i32,
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
#[derive(Clone, Default)]
|
|
862
|
+
struct ClientHeartbeatData {
|
|
863
|
+
last_heartbeat_time: Option<SystemTime>,
|
|
864
|
+
|
|
865
|
+
workflow_task_slots_info: SlotsInfo,
|
|
866
|
+
activity_task_slots_info: SlotsInfo,
|
|
867
|
+
nexus_task_slots_info: SlotsInfo,
|
|
868
|
+
local_activity_slots_info: SlotsInfo,
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
fn update_slots(slots_info: &mut Option<WorkerSlotsInfo>, client_heartbeat_data: &mut SlotsInfo) {
|
|
872
|
+
if let Some(wft_slot_info) = slots_info.as_mut() {
|
|
873
|
+
wft_slot_info.last_interval_processed_tasks =
|
|
874
|
+
wft_slot_info.total_processed_tasks - client_heartbeat_data.total_processed_tasks;
|
|
875
|
+
wft_slot_info.last_interval_failure_tasks =
|
|
876
|
+
wft_slot_info.total_failed_tasks - client_heartbeat_data.total_failed_tasks;
|
|
877
|
+
|
|
878
|
+
client_heartbeat_data.total_processed_tasks = wft_slot_info.total_processed_tasks;
|
|
879
|
+
client_heartbeat_data.total_failed_tasks = wft_slot_info.total_failed_tasks;
|
|
880
|
+
}
|
|
881
|
+
}
|