@temporalio/core-bridge 1.14.2-canary-release-testing.0 → 1.16.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 +794 -650
- package/bridge-macros/src/derive_tryintojs.rs +40 -0
- package/lib/native.d.ts +24 -3
- package/package.json +4 -4
- 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/.github/workflows/per-pr.yml +6 -6
- package/sdk-core/AGENTS.md +42 -31
- package/sdk-core/Cargo.toml +4 -1
- package/sdk-core/README.md +19 -13
- package/sdk-core/crates/client/Cargo.toml +4 -0
- package/sdk-core/crates/client/README.md +139 -0
- package/sdk-core/crates/client/src/async_activity_handle.rs +297 -0
- package/sdk-core/crates/client/src/callback_based.rs +7 -0
- package/sdk-core/crates/client/src/errors.rs +294 -0
- package/sdk-core/crates/client/src/{raw.rs → grpc.rs} +370 -159
- package/sdk-core/crates/client/src/lib.rs +920 -1326
- package/sdk-core/crates/client/src/metrics.rs +24 -33
- package/sdk-core/crates/client/src/options_structs.rs +457 -0
- package/sdk-core/crates/client/src/replaceable.rs +5 -4
- package/sdk-core/crates/client/src/request_extensions.rs +8 -9
- package/sdk-core/crates/client/src/retry.rs +99 -54
- package/sdk-core/crates/client/src/{worker/mod.rs → worker.rs} +104 -29
- package/sdk-core/crates/client/src/workflow_handle.rs +826 -0
- package/sdk-core/crates/common/Cargo.toml +62 -3
- package/sdk-core/crates/common/build.rs +742 -12
- package/sdk-core/crates/common/protos/api_upstream/.github/workflows/ci.yml +2 -0
- package/sdk-core/crates/common/protos/api_upstream/.github/workflows/create-release.yml +0 -5
- package/sdk-core/crates/common/protos/api_upstream/Makefile +2 -1
- package/sdk-core/crates/common/protos/api_upstream/README.md +8 -0
- package/sdk-core/crates/common/protos/api_upstream/cmd/check-path-conflicts/main.go +137 -0
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv2.json +3329 -2647
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv3.yaml +2734 -708
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/activity/v1/message.proto +155 -3
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/command/v1/message.proto +26 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/common/v1/message.proto +8 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/deployment/v1/message.proto +27 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/activity.proto +81 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/event_type.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +15 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/workflow.proto +63 -15
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/errordetails/v1/message.proto +8 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/failure/v1/message.proto +1 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/history/v1/message.proto +111 -17
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/namespace/v1/message.proto +21 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/nexus/v1/message.proto +20 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/schedule/v1/message.proto +2 -2
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +2 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/worker/v1/message.proto +4 -7
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflow/v1/message.proto +80 -22
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +347 -23
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +242 -43
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/core_interface.proto +15 -0
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/nexus/nexus.proto +9 -2
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +8 -0
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +22 -5
- package/sdk-core/crates/common/src/activity_definition.rs +20 -0
- package/sdk-core/crates/common/src/data_converters.rs +770 -0
- package/sdk-core/crates/common/src/envconfig.rs +5 -0
- package/sdk-core/crates/common/src/lib.rs +15 -211
- package/sdk-core/crates/common/src/payload_visitor.rs +648 -0
- package/sdk-core/crates/common/src/priority.rs +110 -0
- package/sdk-core/crates/common/src/protos/canned_histories.rs +19 -0
- package/sdk-core/crates/common/src/protos/history_builder.rs +45 -0
- package/sdk-core/crates/common/src/protos/history_info.rs +2 -0
- package/sdk-core/crates/common/src/protos/mod.rs +134 -27
- package/sdk-core/crates/common/src/protos/task_token.rs +3 -3
- package/sdk-core/crates/common/src/protos/utilities.rs +11 -0
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/log_export.rs +11 -16
- package/sdk-core/crates/common/src/telemetry/metrics/core.rs +125 -0
- package/sdk-core/crates/common/src/telemetry/metrics.rs +272 -225
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/otel.rs +8 -13
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_meter.rs +49 -50
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_server.rs +2 -3
- package/sdk-core/crates/common/src/telemetry.rs +278 -19
- package/sdk-core/crates/common/src/worker.rs +68 -636
- package/sdk-core/crates/common/src/workflow_definition.rs +60 -0
- package/sdk-core/crates/macros/Cargo.toml +5 -1
- package/sdk-core/crates/macros/src/activities_definitions.rs +585 -0
- package/sdk-core/crates/macros/src/fsm_impl.rs +507 -0
- package/sdk-core/crates/macros/src/lib.rs +138 -512
- package/sdk-core/crates/macros/src/macro_utils.rs +106 -0
- package/sdk-core/crates/macros/src/workflow_definitions.rs +1224 -0
- package/sdk-core/crates/sdk/Cargo.toml +19 -6
- package/sdk-core/crates/sdk/README.md +415 -0
- package/sdk-core/crates/sdk/src/activities.rs +417 -0
- package/sdk-core/crates/sdk/src/interceptors.rs +1 -1
- package/sdk-core/crates/sdk/src/lib.rs +759 -442
- package/sdk-core/crates/sdk/src/workflow_context/options.rs +64 -35
- package/sdk-core/crates/sdk/src/workflow_context.rs +1033 -289
- package/sdk-core/crates/sdk/src/workflow_future.rs +277 -213
- package/sdk-core/crates/sdk/src/workflows.rs +711 -0
- package/sdk-core/crates/sdk-core/Cargo.toml +59 -65
- package/sdk-core/crates/sdk-core/benches/workflow_replay_bench.rs +45 -54
- package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +1 -1
- package/sdk-core/crates/sdk-core/src/abstractions.rs +6 -10
- package/sdk-core/crates/sdk-core/src/core_tests/activity_tasks.rs +6 -5
- package/sdk-core/crates/sdk-core/src/core_tests/mod.rs +22 -21
- package/sdk-core/crates/sdk-core/src/core_tests/queries.rs +21 -25
- package/sdk-core/crates/sdk-core/src/core_tests/replay_flag.rs +7 -10
- package/sdk-core/crates/sdk-core/src/core_tests/updates.rs +14 -17
- package/sdk-core/crates/sdk-core/src/core_tests/workers.rs +647 -27
- package/sdk-core/crates/sdk-core/src/core_tests/workflow_tasks.rs +46 -41
- package/sdk-core/crates/sdk-core/src/ephemeral_server/mod.rs +13 -16
- package/sdk-core/crates/sdk-core/src/histfetch.rs +20 -10
- package/sdk-core/crates/sdk-core/src/lib.rs +60 -123
- package/sdk-core/crates/sdk-core/src/pollers/mod.rs +4 -9
- package/sdk-core/crates/sdk-core/src/pollers/poll_buffer.rs +411 -32
- package/sdk-core/crates/sdk-core/src/protosext/mod.rs +2 -2
- package/sdk-core/crates/sdk-core/src/replay/mod.rs +14 -5
- package/sdk-core/crates/sdk-core/src/telemetry/metrics.rs +183 -198
- package/sdk-core/crates/sdk-core/src/telemetry/mod.rs +3 -281
- package/sdk-core/crates/sdk-core/src/test_help/integ_helpers.rs +35 -16
- package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +3 -6
- package/sdk-core/crates/sdk-core/src/worker/activities/activity_heartbeat_manager.rs +1 -0
- package/sdk-core/crates/sdk-core/src/worker/activities/local_activities.rs +11 -14
- package/sdk-core/crates/sdk-core/src/worker/activities.rs +16 -19
- package/sdk-core/crates/sdk-core/src/worker/client/mocks.rs +11 -5
- package/sdk-core/crates/sdk-core/src/worker/client.rs +104 -86
- package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +10 -14
- package/sdk-core/crates/sdk-core/src/worker/mod.rs +1175 -241
- package/sdk-core/crates/sdk-core/src/worker/nexus.rs +150 -23
- package/sdk-core/crates/sdk-core/src/worker/slot_provider.rs +2 -2
- package/sdk-core/crates/sdk-core/src/worker/tuner/fixed_size.rs +2 -2
- package/sdk-core/crates/sdk-core/src/worker/tuner/resource_based.rs +25 -27
- package/sdk-core/crates/sdk-core/src/worker/tuner.rs +64 -44
- package/sdk-core/crates/sdk-core/src/worker/workflow/driven_workflow.rs +9 -3
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/patch_state_machine.rs +5 -8
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +21 -22
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/workflow_machines.rs +28 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/managed_run.rs +20 -41
- package/sdk-core/crates/sdk-core/src/worker/workflow/mod.rs +50 -9
- package/sdk-core/crates/sdk-core/src/worker/workflow/run_cache.rs +4 -7
- package/sdk-core/crates/sdk-core/src/worker/workflow/wft_extraction.rs +2 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/wft_poller.rs +8 -9
- package/sdk-core/crates/sdk-core/src/worker/workflow/workflow_stream.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/activities_procmacro.rs +6 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/basic_pass.rs +54 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.rs +18 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.rs +14 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/multi_arg_pass.rs +48 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_input_pass.rs +14 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_return_type_pass.rs +19 -0
- package/sdk-core/crates/sdk-core/tests/cloud_tests.rs +14 -5
- package/sdk-core/crates/sdk-core/tests/common/activity_functions.rs +55 -0
- package/sdk-core/crates/sdk-core/tests/common/mod.rs +281 -236
- package/sdk-core/crates/sdk-core/tests/common/workflows.rs +41 -28
- package/sdk-core/crates/sdk-core/tests/global_metric_tests.rs +9 -14
- package/sdk-core/crates/sdk-core/tests/heavy_tests/fuzzy_workflow.rs +73 -66
- package/sdk-core/crates/sdk-core/tests/heavy_tests.rs +306 -268
- package/sdk-core/crates/sdk-core/tests/integ_tests/async_activity_client_tests.rs +230 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/client_tests.rs +94 -57
- package/sdk-core/crates/sdk-core/tests/integ_tests/data_converter_tests.rs +381 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +37 -38
- package/sdk-core/crates/sdk-core/tests/integ_tests/heartbeat_tests.rs +49 -40
- package/sdk-core/crates/sdk-core/tests/integ_tests/metrics_tests.rs +447 -300
- package/sdk-core/crates/sdk-core/tests/integ_tests/pagination_tests.rs +50 -45
- package/sdk-core/crates/sdk-core/tests/integ_tests/polling_tests.rs +157 -157
- package/sdk-core/crates/sdk-core/tests/integ_tests/queries_tests.rs +103 -89
- package/sdk-core/crates/sdk-core/tests/integ_tests/update_tests.rs +609 -463
- package/sdk-core/crates/sdk-core/tests/integ_tests/visibility_tests.rs +80 -62
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +389 -265
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +250 -185
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_versioning_tests.rs +52 -49
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_client_tests.rs +180 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/activities.rs +437 -327
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +82 -58
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +56 -30
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +364 -251
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/client_interactions.rs +552 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +110 -46
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +243 -149
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/eager.rs +98 -32
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1475 -1040
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +73 -43
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +402 -245
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +343 -207
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/queries.rs +415 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/replay.rs +96 -36
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/resets.rs +155 -140
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +183 -113
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +85 -44
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +142 -48
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +73 -56
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests.rs +365 -242
- package/sdk-core/crates/sdk-core/tests/main.rs +22 -16
- package/sdk-core/crates/sdk-core/tests/manual_tests.rs +233 -187
- package/sdk-core/crates/sdk-core/tests/runner.rs +4 -6
- package/sdk-core/crates/sdk-core/tests/shared_tests/mod.rs +73 -27
- package/sdk-core/crates/sdk-core/tests/shared_tests/priority.rs +107 -84
- package/sdk-core/crates/sdk-core/tests/workflows_procmacro.rs +6 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.rs +26 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/basic_pass.rs +49 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/minimal_pass.rs +21 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.rs +26 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.rs +21 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core-c-bridge/Cargo.toml +8 -1
- package/sdk-core/crates/sdk-core-c-bridge/include/temporal-sdk-core-c-bridge.h +37 -26
- package/sdk-core/crates/sdk-core-c-bridge/src/client.rs +180 -87
- package/sdk-core/crates/sdk-core-c-bridge/src/lib.rs +89 -5
- package/sdk-core/crates/sdk-core-c-bridge/src/metric.rs +10 -16
- package/sdk-core/crates/sdk-core-c-bridge/src/runtime.rs +59 -67
- package/sdk-core/crates/sdk-core-c-bridge/src/testing.rs +10 -10
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/context.rs +57 -22
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/mod.rs +108 -12
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/utils.rs +9 -52
- package/sdk-core/crates/sdk-core-c-bridge/src/worker.rs +74 -91
- package/sdk-core/rustfmt.toml +2 -1
- package/src/client.rs +206 -289
- package/src/helpers/try_into_js.rs +88 -2
- package/src/metrics.rs +277 -35
- package/src/runtime.rs +94 -45
- package/src/testing.rs +9 -16
- package/src/worker.rs +86 -68
- package/ts/native.ts +39 -3
- package/sdk-core/crates/client/src/workflow_handle/mod.rs +0 -212
- package/sdk-core/crates/common/src/errors.rs +0 -85
- package/sdk-core/crates/common/tests/worker_task_types_test.rs +0 -129
- package/sdk-core/crates/macros/LICENSE.txt +0 -21
- package/sdk-core/crates/sdk/src/activity_context.rs +0 -238
- package/sdk-core/crates/sdk/src/app_data.rs +0 -37
- package/sdk-core/crates/sdk-core/tests/integ_tests/activity_functions.rs +0 -5
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +0 -61
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
use crate::protos::temporal::api::common;
|
|
2
|
+
|
|
3
|
+
/// Priority contains metadata that controls relative ordering of task processing
|
|
4
|
+
/// when tasks are backlogged in a queue. Initially, Priority will be used in
|
|
5
|
+
/// activity and workflow task queues, which are typically where backlogs exist.
|
|
6
|
+
/// Other queues in the server (such as transfer and timer queues) and rate
|
|
7
|
+
/// limiting decisions do not use Priority, but may in the future.
|
|
8
|
+
///
|
|
9
|
+
/// Priority is attached to workflows and activities. Activities and child
|
|
10
|
+
/// workflows inherit Priority from the workflow that created them, but may
|
|
11
|
+
/// override fields when they are started or modified.
|
|
12
|
+
///
|
|
13
|
+
/// All fields default to `None`, which means "inherit from the calling workflow"
|
|
14
|
+
/// or, if there is no calling workflow, "use the server default."
|
|
15
|
+
///
|
|
16
|
+
/// Despite being named "Priority", this type also contains fields that
|
|
17
|
+
/// control "fairness" mechanisms.
|
|
18
|
+
///
|
|
19
|
+
/// The overall semantics of Priority are:
|
|
20
|
+
/// (more will be added here later)
|
|
21
|
+
/// 1. First, consider "priority_key": lower number goes first.
|
|
22
|
+
#[derive(Debug, Clone, Default, PartialEq)]
|
|
23
|
+
pub struct Priority {
|
|
24
|
+
/// Priority key is a positive integer from 1 to n, where smaller integers
|
|
25
|
+
/// correspond to higher priorities (tasks run sooner). In general, tasks in
|
|
26
|
+
/// a queue should be processed in close to priority order, although small
|
|
27
|
+
/// deviations are possible.
|
|
28
|
+
///
|
|
29
|
+
/// The maximum priority value (minimum priority) is determined by server
|
|
30
|
+
/// configuration, and defaults to 5.
|
|
31
|
+
///
|
|
32
|
+
/// The server default priority is `(min + max) / 2`. With the default max
|
|
33
|
+
/// of 5 and min of 1, that comes out to 3.
|
|
34
|
+
///
|
|
35
|
+
/// `None` means inherit from the calling workflow or use the server default.
|
|
36
|
+
pub priority_key: Option<u32>,
|
|
37
|
+
|
|
38
|
+
/// Fairness key is a short string that's used as a key for a fairness
|
|
39
|
+
/// balancing mechanism. It may correspond to a tenant id, or to a fixed
|
|
40
|
+
/// string like "high" or "low".
|
|
41
|
+
///
|
|
42
|
+
/// The fairness mechanism attempts to dispatch tasks for a given key in
|
|
43
|
+
/// proportion to its weight. For example, using a thousand distinct tenant
|
|
44
|
+
/// ids, each with a weight of 1.0 (the default) will result in each tenant
|
|
45
|
+
/// getting a roughly equal share of task dispatch throughput.
|
|
46
|
+
///
|
|
47
|
+
/// (Note: this does not imply equal share of worker capacity! Fairness
|
|
48
|
+
/// decisions are made based on queue statistics, not current worker load.)
|
|
49
|
+
///
|
|
50
|
+
/// As another example, using keys "high" and "low" with weight 9.0 and 1.0
|
|
51
|
+
/// respectively will prefer dispatching "high" tasks over "low" tasks at a
|
|
52
|
+
/// 9:1 ratio, while allowing either key to use all worker capacity if the
|
|
53
|
+
/// other is not present.
|
|
54
|
+
///
|
|
55
|
+
/// All fairness mechanisms, including rate limits, are best-effort and
|
|
56
|
+
/// probabilistic. The results may not match what a "perfect" algorithm with
|
|
57
|
+
/// infinite resources would produce. The more unique keys are used, the less
|
|
58
|
+
/// accurate the results will be.
|
|
59
|
+
///
|
|
60
|
+
/// Fairness keys are limited to 64 bytes.
|
|
61
|
+
///
|
|
62
|
+
/// `None` means inherit from the calling workflow or use the server default
|
|
63
|
+
/// (empty string).
|
|
64
|
+
pub fairness_key: Option<String>,
|
|
65
|
+
|
|
66
|
+
/// Fairness weight for a task can come from multiple sources for
|
|
67
|
+
/// flexibility. From highest to lowest precedence:
|
|
68
|
+
/// 1. Weights for a small set of keys can be overridden in task queue
|
|
69
|
+
/// configuration with an API.
|
|
70
|
+
/// 2. It can be attached to the workflow/activity in this field.
|
|
71
|
+
/// 3. The server default weight of 1.0 will be used.
|
|
72
|
+
///
|
|
73
|
+
/// Weight values are clamped by the server to the range \[0.001, 1000\].
|
|
74
|
+
///
|
|
75
|
+
/// `None` means inherit from the calling workflow or use the server default
|
|
76
|
+
/// (1.0).
|
|
77
|
+
pub fairness_weight: Option<f32>,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
impl From<Priority> for common::v1::Priority {
|
|
81
|
+
fn from(priority: Priority) -> Self {
|
|
82
|
+
common::v1::Priority {
|
|
83
|
+
priority_key: priority.priority_key.unwrap_or(0) as i32,
|
|
84
|
+
fairness_key: priority.fairness_key.unwrap_or_default(),
|
|
85
|
+
fairness_weight: priority.fairness_weight.unwrap_or(0.0),
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
impl From<common::v1::Priority> for Priority {
|
|
91
|
+
fn from(priority: common::v1::Priority) -> Self {
|
|
92
|
+
Self {
|
|
93
|
+
priority_key: if priority.priority_key == 0 {
|
|
94
|
+
None
|
|
95
|
+
} else {
|
|
96
|
+
Some(priority.priority_key as u32)
|
|
97
|
+
},
|
|
98
|
+
fairness_key: if priority.fairness_key.is_empty() {
|
|
99
|
+
None
|
|
100
|
+
} else {
|
|
101
|
+
Some(priority.fairness_key)
|
|
102
|
+
},
|
|
103
|
+
fairness_weight: if priority.fairness_weight == 0.0 {
|
|
104
|
+
None
|
|
105
|
+
} else {
|
|
106
|
+
Some(priority.fairness_weight)
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -30,6 +30,7 @@ pub fn single_timer(timer_id: &str) -> TestHistoryBuilder {
|
|
|
30
30
|
t
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/// Like [`single_timer`] but also completes the workflow.
|
|
33
34
|
pub fn single_timer_wf_completes(timer_id: &str) -> TestHistoryBuilder {
|
|
34
35
|
let mut t = single_timer(timer_id);
|
|
35
36
|
t.add_workflow_task_completed();
|
|
@@ -272,6 +273,7 @@ pub fn cancel_scheduled_activity(activity_id: &str, signal_id: &str) -> TestHist
|
|
|
272
273
|
vec![Payload {
|
|
273
274
|
metadata: Default::default(),
|
|
274
275
|
data: b"hello ".to_vec(),
|
|
276
|
+
external_payloads: Default::default(),
|
|
275
277
|
}],
|
|
276
278
|
);
|
|
277
279
|
t.add_full_wf_task();
|
|
@@ -343,6 +345,7 @@ pub fn scheduled_cancelled_activity_timeout(
|
|
|
343
345
|
vec![Payload {
|
|
344
346
|
metadata: Default::default(),
|
|
345
347
|
data: b"hello ".to_vec(),
|
|
348
|
+
external_payloads: Default::default(),
|
|
346
349
|
}],
|
|
347
350
|
);
|
|
348
351
|
t.add_full_wf_task();
|
|
@@ -421,6 +424,7 @@ pub fn cancel_scheduled_activity_abandon(activity_id: &str, signal_id: &str) ->
|
|
|
421
424
|
vec![Payload {
|
|
422
425
|
metadata: Default::default(),
|
|
423
426
|
data: b"hello ".to_vec(),
|
|
427
|
+
external_payloads: Default::default(),
|
|
424
428
|
}],
|
|
425
429
|
);
|
|
426
430
|
t.add_full_wf_task();
|
|
@@ -453,6 +457,7 @@ pub fn cancel_started_activity_abandon(activity_id: &str, signal_id: &str) -> Te
|
|
|
453
457
|
vec![Payload {
|
|
454
458
|
metadata: Default::default(),
|
|
455
459
|
data: b"hello ".to_vec(),
|
|
460
|
+
external_payloads: Default::default(),
|
|
456
461
|
}],
|
|
457
462
|
);
|
|
458
463
|
t.add_full_wf_task();
|
|
@@ -492,6 +497,7 @@ pub fn cancel_scheduled_activity_with_signal_and_activity_task_cancel(
|
|
|
492
497
|
vec![Payload {
|
|
493
498
|
metadata: Default::default(),
|
|
494
499
|
data: b"hello ".to_vec(),
|
|
500
|
+
external_payloads: Default::default(),
|
|
495
501
|
}],
|
|
496
502
|
);
|
|
497
503
|
t.add_full_wf_task();
|
|
@@ -508,6 +514,7 @@ pub fn cancel_scheduled_activity_with_signal_and_activity_task_cancel(
|
|
|
508
514
|
vec![Payload {
|
|
509
515
|
metadata: Default::default(),
|
|
510
516
|
data: b"hello ".to_vec(),
|
|
517
|
+
external_payloads: Default::default(),
|
|
511
518
|
}],
|
|
512
519
|
);
|
|
513
520
|
t.add_full_wf_task();
|
|
@@ -561,6 +568,7 @@ pub fn cancel_started_activity_with_signal_and_activity_task_cancel(
|
|
|
561
568
|
vec![Payload {
|
|
562
569
|
metadata: Default::default(),
|
|
563
570
|
data: b"hello ".to_vec(),
|
|
571
|
+
external_payloads: Default::default(),
|
|
564
572
|
}],
|
|
565
573
|
);
|
|
566
574
|
t.add_full_wf_task();
|
|
@@ -577,6 +585,7 @@ pub fn cancel_started_activity_with_signal_and_activity_task_cancel(
|
|
|
577
585
|
vec![Payload {
|
|
578
586
|
metadata: Default::default(),
|
|
579
587
|
data: b"hello ".to_vec(),
|
|
588
|
+
external_payloads: Default::default(),
|
|
580
589
|
}],
|
|
581
590
|
);
|
|
582
591
|
t.add_full_wf_task();
|
|
@@ -621,6 +630,7 @@ pub fn cancel_scheduled_activity_with_activity_task_cancel(
|
|
|
621
630
|
vec![Payload {
|
|
622
631
|
metadata: Default::default(),
|
|
623
632
|
data: b"hello ".to_vec(),
|
|
633
|
+
external_payloads: Default::default(),
|
|
624
634
|
}],
|
|
625
635
|
);
|
|
626
636
|
t.add_full_wf_task();
|
|
@@ -678,6 +688,7 @@ pub fn cancel_started_activity_with_activity_task_cancel(
|
|
|
678
688
|
vec![Payload {
|
|
679
689
|
metadata: Default::default(),
|
|
680
690
|
data: b"hello ".to_vec(),
|
|
691
|
+
external_payloads: Default::default(),
|
|
681
692
|
}],
|
|
682
693
|
);
|
|
683
694
|
t.add_full_wf_task();
|
|
@@ -720,6 +731,7 @@ pub fn two_signals(sig_1_id: &str, sig_2_id: &str) -> TestHistoryBuilder {
|
|
|
720
731
|
vec![Payload {
|
|
721
732
|
metadata: Default::default(),
|
|
722
733
|
data: b"hello ".to_vec(),
|
|
734
|
+
external_payloads: Default::default(),
|
|
723
735
|
}],
|
|
724
736
|
);
|
|
725
737
|
t.add_we_signaled(
|
|
@@ -727,6 +739,7 @@ pub fn two_signals(sig_1_id: &str, sig_2_id: &str) -> TestHistoryBuilder {
|
|
|
727
739
|
vec![Payload {
|
|
728
740
|
metadata: Default::default(),
|
|
729
741
|
data: b"world".to_vec(),
|
|
742
|
+
external_payloads: Default::default(),
|
|
730
743
|
}],
|
|
731
744
|
);
|
|
732
745
|
t.add_workflow_task_scheduled_and_started();
|
|
@@ -777,6 +790,7 @@ pub fn lots_of_big_signals(num_tasks: usize) -> TestHistoryBuilder {
|
|
|
777
790
|
vec![Payload {
|
|
778
791
|
metadata: Default::default(),
|
|
779
792
|
data: dat.into(),
|
|
793
|
+
external_payloads: Default::default(),
|
|
780
794
|
}],
|
|
781
795
|
);
|
|
782
796
|
}
|
|
@@ -846,6 +860,7 @@ pub fn cancel_not_sent_when_also_complete_repro() -> TestHistoryBuilder {
|
|
|
846
860
|
vec![Payload {
|
|
847
861
|
metadata: Default::default(),
|
|
848
862
|
data: b"hello ".to_vec(),
|
|
863
|
+
external_payloads: Default::default(),
|
|
849
864
|
}],
|
|
850
865
|
);
|
|
851
866
|
t.add_full_wf_task();
|
|
@@ -896,6 +911,7 @@ pub fn wft_timeout_repro() -> TestHistoryBuilder {
|
|
|
896
911
|
vec![Payload {
|
|
897
912
|
metadata: Default::default(),
|
|
898
913
|
data: b"hello ".to_vec(),
|
|
914
|
+
external_payloads: Default::default(),
|
|
899
915
|
}],
|
|
900
916
|
);
|
|
901
917
|
t.add_workflow_task_scheduled();
|
|
@@ -904,6 +920,7 @@ pub fn wft_timeout_repro() -> TestHistoryBuilder {
|
|
|
904
920
|
vec![Payload {
|
|
905
921
|
metadata: Default::default(),
|
|
906
922
|
data: b"hello ".to_vec(),
|
|
923
|
+
external_payloads: Default::default(),
|
|
907
924
|
}],
|
|
908
925
|
);
|
|
909
926
|
let started_event_id = t.add(ActivityTaskStartedEventAttributes {
|
|
@@ -958,12 +975,14 @@ pub fn timer_then_continue_as_new(timer_id: &str) -> TestHistoryBuilder {
|
|
|
958
975
|
pub fn timer_wf_cancel_req_cancelled(timer_id: &str) -> TestHistoryBuilder {
|
|
959
976
|
timer_cancel_req_then(timer_id, TestHistoryBuilder::add_cancelled)
|
|
960
977
|
}
|
|
978
|
+
/// Timer with cancel request followed by workflow execution completed.
|
|
961
979
|
pub fn timer_wf_cancel_req_completed(timer_id: &str) -> TestHistoryBuilder {
|
|
962
980
|
timer_cancel_req_then(
|
|
963
981
|
timer_id,
|
|
964
982
|
TestHistoryBuilder::add_workflow_execution_completed,
|
|
965
983
|
)
|
|
966
984
|
}
|
|
985
|
+
/// Timer with cancel request followed by workflow execution failed.
|
|
967
986
|
pub fn timer_wf_cancel_req_failed(timer_id: &str) -> TestHistoryBuilder {
|
|
968
987
|
timer_cancel_req_then(timer_id, TestHistoryBuilder::add_workflow_execution_failed)
|
|
969
988
|
}
|
|
@@ -30,11 +30,14 @@ use std::{
|
|
|
30
30
|
};
|
|
31
31
|
use uuid::Uuid;
|
|
32
32
|
|
|
33
|
+
/// The workflow type name used by default in test histories.
|
|
33
34
|
pub static DEFAULT_WORKFLOW_TYPE: &str = "default_wf_type";
|
|
35
|
+
/// The activity type name used by default in test histories.
|
|
34
36
|
pub static DEFAULT_ACTIVITY_TYPE: &str = "default_act_type";
|
|
35
37
|
|
|
36
38
|
type Result<T, E = anyhow::Error> = std::result::Result<T, E>;
|
|
37
39
|
|
|
40
|
+
/// Builder for constructing synthetic workflow histories for testing.
|
|
38
41
|
#[derive(Default, Clone, Debug)]
|
|
39
42
|
pub struct TestHistoryBuilder {
|
|
40
43
|
events: Vec<HistoryEvent>,
|
|
@@ -48,6 +51,7 @@ pub struct TestHistoryBuilder {
|
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
impl TestHistoryBuilder {
|
|
54
|
+
/// Construct from a pre-existing list of history events.
|
|
51
55
|
pub fn from_history(events: Vec<HistoryEvent>) -> Self {
|
|
52
56
|
let find_matching_id = |etype: EventType| {
|
|
53
57
|
events
|
|
@@ -96,15 +100,18 @@ impl TestHistoryBuilder {
|
|
|
96
100
|
self.add_workflow_task_completed();
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
/// Add workflow task scheduled and started events.
|
|
99
104
|
pub fn add_workflow_task_scheduled_and_started(&mut self) {
|
|
100
105
|
self.add_workflow_task_scheduled();
|
|
101
106
|
self.add_workflow_task_started();
|
|
102
107
|
}
|
|
103
108
|
|
|
109
|
+
/// Add a workflow task scheduled event.
|
|
104
110
|
pub fn add_workflow_task_scheduled(&mut self) {
|
|
105
111
|
self.workflow_task_scheduled_event_id = self.add_by_type(EventType::WorkflowTaskScheduled);
|
|
106
112
|
}
|
|
107
113
|
|
|
114
|
+
/// Add a workflow task started event.
|
|
108
115
|
pub fn add_workflow_task_started(&mut self) {
|
|
109
116
|
self.final_workflow_task_started_event_id = self.add(WorkflowTaskStartedEventAttributes {
|
|
110
117
|
scheduled_event_id: self.workflow_task_scheduled_event_id,
|
|
@@ -113,6 +120,7 @@ impl TestHistoryBuilder {
|
|
|
113
120
|
});
|
|
114
121
|
}
|
|
115
122
|
|
|
123
|
+
/// Add a workflow task completed event.
|
|
116
124
|
pub fn add_workflow_task_completed(&mut self) {
|
|
117
125
|
let id = self.add(WorkflowTaskCompletedEventAttributes {
|
|
118
126
|
scheduled_event_id: self.workflow_task_scheduled_event_id,
|
|
@@ -121,6 +129,7 @@ impl TestHistoryBuilder {
|
|
|
121
129
|
self.previous_task_completed_id = id;
|
|
122
130
|
}
|
|
123
131
|
|
|
132
|
+
/// Add a workflow task timed out event.
|
|
124
133
|
pub fn add_workflow_task_timed_out(&mut self) {
|
|
125
134
|
let attrs = WorkflowTaskTimedOutEventAttributes {
|
|
126
135
|
scheduled_event_id: self.workflow_task_scheduled_event_id,
|
|
@@ -129,6 +138,7 @@ impl TestHistoryBuilder {
|
|
|
129
138
|
self.build_and_push_event(EventType::WorkflowTaskTimedOut, attrs.into());
|
|
130
139
|
}
|
|
131
140
|
|
|
141
|
+
/// Add a workflow execution completed event.
|
|
132
142
|
pub fn add_workflow_execution_completed(&mut self) {
|
|
133
143
|
let attrs = WorkflowExecutionCompletedEventAttributes {
|
|
134
144
|
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
@@ -137,6 +147,7 @@ impl TestHistoryBuilder {
|
|
|
137
147
|
self.build_and_push_event(EventType::WorkflowExecutionCompleted, attrs.into());
|
|
138
148
|
}
|
|
139
149
|
|
|
150
|
+
/// Add a workflow execution terminated event.
|
|
140
151
|
pub fn add_workflow_execution_terminated(&mut self) {
|
|
141
152
|
let attrs = WorkflowExecutionTerminatedEventAttributes {
|
|
142
153
|
..Default::default()
|
|
@@ -144,6 +155,7 @@ impl TestHistoryBuilder {
|
|
|
144
155
|
self.build_and_push_event(EventType::WorkflowExecutionTerminated, attrs.into());
|
|
145
156
|
}
|
|
146
157
|
|
|
158
|
+
/// Add a workflow execution timed out event.
|
|
147
159
|
pub fn add_workflow_execution_timed_out(&mut self) {
|
|
148
160
|
let attrs = WorkflowExecutionTimedOutEventAttributes {
|
|
149
161
|
..Default::default()
|
|
@@ -151,6 +163,7 @@ impl TestHistoryBuilder {
|
|
|
151
163
|
self.build_and_push_event(EventType::WorkflowExecutionTimedOut, attrs.into());
|
|
152
164
|
}
|
|
153
165
|
|
|
166
|
+
/// Add a workflow execution failed event.
|
|
154
167
|
pub fn add_workflow_execution_failed(&mut self) {
|
|
155
168
|
let attrs = WorkflowExecutionFailedEventAttributes {
|
|
156
169
|
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
@@ -159,21 +172,25 @@ impl TestHistoryBuilder {
|
|
|
159
172
|
self.build_and_push_event(EventType::WorkflowExecutionFailed, attrs.into());
|
|
160
173
|
}
|
|
161
174
|
|
|
175
|
+
/// Add a workflow execution continued-as-new event.
|
|
162
176
|
pub fn add_continued_as_new(&mut self) {
|
|
163
177
|
let attrs = WorkflowExecutionContinuedAsNewEventAttributes::default();
|
|
164
178
|
self.build_and_push_event(EventType::WorkflowExecutionContinuedAsNew, attrs.into());
|
|
165
179
|
}
|
|
166
180
|
|
|
181
|
+
/// Add a workflow execution cancel-requested event.
|
|
167
182
|
pub fn add_cancel_requested(&mut self) {
|
|
168
183
|
let attrs = WorkflowExecutionCancelRequestedEventAttributes::default();
|
|
169
184
|
self.build_and_push_event(EventType::WorkflowExecutionCancelRequested, attrs.into());
|
|
170
185
|
}
|
|
171
186
|
|
|
187
|
+
/// Add a workflow execution canceled event.
|
|
172
188
|
pub fn add_cancelled(&mut self) {
|
|
173
189
|
let attrs = WorkflowExecutionCanceledEventAttributes::default();
|
|
174
190
|
self.build_and_push_event(EventType::WorkflowExecutionCanceled, attrs.into());
|
|
175
191
|
}
|
|
176
192
|
|
|
193
|
+
/// Add an activity task scheduled event, returning the event ID.
|
|
177
194
|
pub fn add_activity_task_scheduled(&mut self, activity_id: impl Into<String>) -> i64 {
|
|
178
195
|
self.add(ActivityTaskScheduledEventAttributes {
|
|
179
196
|
activity_id: activity_id.into(),
|
|
@@ -184,6 +201,7 @@ impl TestHistoryBuilder {
|
|
|
184
201
|
})
|
|
185
202
|
}
|
|
186
203
|
|
|
204
|
+
/// Add an activity task started event, returning the event ID.
|
|
187
205
|
pub fn add_activity_task_started(&mut self, scheduled_event_id: i64) -> i64 {
|
|
188
206
|
self.add(Attributes::ActivityTaskStartedEventAttributes(
|
|
189
207
|
ActivityTaskStartedEventAttributes {
|
|
@@ -193,6 +211,7 @@ impl TestHistoryBuilder {
|
|
|
193
211
|
))
|
|
194
212
|
}
|
|
195
213
|
|
|
214
|
+
/// Add an activity task completed event.
|
|
196
215
|
pub fn add_activity_task_completed(
|
|
197
216
|
&mut self,
|
|
198
217
|
scheduled_event_id: i64,
|
|
@@ -207,6 +226,7 @@ impl TestHistoryBuilder {
|
|
|
207
226
|
});
|
|
208
227
|
}
|
|
209
228
|
|
|
229
|
+
/// Add an activity task cancel-requested event.
|
|
210
230
|
pub fn add_activity_task_cancel_requested(&mut self, scheduled_event_id: i64) {
|
|
211
231
|
let attrs = ActivityTaskCancelRequestedEventAttributes {
|
|
212
232
|
scheduled_event_id,
|
|
@@ -215,6 +235,7 @@ impl TestHistoryBuilder {
|
|
|
215
235
|
self.build_and_push_event(EventType::ActivityTaskCancelRequested, attrs.into());
|
|
216
236
|
}
|
|
217
237
|
|
|
238
|
+
/// Add a workflow task failed event with a specific failure.
|
|
218
239
|
pub fn add_workflow_task_failed_with_failure(
|
|
219
240
|
&mut self,
|
|
220
241
|
cause: WorkflowTaskFailedCause,
|
|
@@ -229,6 +250,7 @@ impl TestHistoryBuilder {
|
|
|
229
250
|
self.build_and_push_event(EventType::WorkflowTaskFailed, attrs.into());
|
|
230
251
|
}
|
|
231
252
|
|
|
253
|
+
/// Add a workflow task failed event with a new run ID.
|
|
232
254
|
pub fn add_workflow_task_failed_new_id(
|
|
233
255
|
&mut self,
|
|
234
256
|
cause: WorkflowTaskFailedCause,
|
|
@@ -243,6 +265,7 @@ impl TestHistoryBuilder {
|
|
|
243
265
|
self.build_and_push_event(EventType::WorkflowTaskFailed, attrs.into());
|
|
244
266
|
}
|
|
245
267
|
|
|
268
|
+
/// Add a timer started event, returning the event ID.
|
|
246
269
|
pub fn add_timer_started(&mut self, timer_id: String) -> i64 {
|
|
247
270
|
self.add(TimerStartedEventAttributes {
|
|
248
271
|
timer_id,
|
|
@@ -251,6 +274,7 @@ impl TestHistoryBuilder {
|
|
|
251
274
|
})
|
|
252
275
|
}
|
|
253
276
|
|
|
277
|
+
/// Add a timer fired event.
|
|
254
278
|
pub fn add_timer_fired(&mut self, timer_started_evt_id: i64, timer_id: String) {
|
|
255
279
|
self.add(TimerFiredEventAttributes {
|
|
256
280
|
started_event_id: timer_started_evt_id,
|
|
@@ -258,6 +282,7 @@ impl TestHistoryBuilder {
|
|
|
258
282
|
});
|
|
259
283
|
}
|
|
260
284
|
|
|
285
|
+
/// Add a workflow execution signaled event.
|
|
261
286
|
pub fn add_we_signaled(&mut self, signal_name: &str, payloads: Vec<Payload>) {
|
|
262
287
|
let attrs = WorkflowExecutionSignaledEventAttributes {
|
|
263
288
|
signal_name: signal_name.to_string(),
|
|
@@ -267,6 +292,7 @@ impl TestHistoryBuilder {
|
|
|
267
292
|
self.build_and_push_event(EventType::WorkflowExecutionSignaled, attrs.into());
|
|
268
293
|
}
|
|
269
294
|
|
|
295
|
+
/// Add a patch (has-change) marker event.
|
|
270
296
|
pub fn add_has_change_marker(&mut self, patch_id: &str, deprecated: bool) {
|
|
271
297
|
let attrs = MarkerRecordedEventAttributes {
|
|
272
298
|
marker_name: PATCH_MARKER_NAME.to_string(),
|
|
@@ -277,6 +303,7 @@ impl TestHistoryBuilder {
|
|
|
277
303
|
self.build_and_push_event(EventType::MarkerRecorded, attrs.into());
|
|
278
304
|
}
|
|
279
305
|
|
|
306
|
+
/// Add a local activity marker event with optional payload/failure.
|
|
280
307
|
pub fn add_local_activity_marker(
|
|
281
308
|
&mut self,
|
|
282
309
|
seq: u32,
|
|
@@ -305,6 +332,7 @@ impl TestHistoryBuilder {
|
|
|
305
332
|
self.build_and_push_event(EventType::MarkerRecorded, attrs.into());
|
|
306
333
|
}
|
|
307
334
|
|
|
335
|
+
/// Add a local activity result marker with a successful payload.
|
|
308
336
|
pub fn add_local_activity_result_marker(
|
|
309
337
|
&mut self,
|
|
310
338
|
seq: u32,
|
|
@@ -314,6 +342,7 @@ impl TestHistoryBuilder {
|
|
|
314
342
|
self.add_local_activity_marker(seq, activity_id, Some(payload), None, |_| {});
|
|
315
343
|
}
|
|
316
344
|
|
|
345
|
+
/// Add a local activity result marker with a specific completion time.
|
|
317
346
|
pub fn add_local_activity_result_marker_with_time(
|
|
318
347
|
&mut self,
|
|
319
348
|
seq: u32,
|
|
@@ -326,6 +355,7 @@ impl TestHistoryBuilder {
|
|
|
326
355
|
});
|
|
327
356
|
}
|
|
328
357
|
|
|
358
|
+
/// Add a local activity failure marker.
|
|
329
359
|
pub fn add_local_activity_fail_marker(
|
|
330
360
|
&mut self,
|
|
331
361
|
seq: u32,
|
|
@@ -335,6 +365,7 @@ impl TestHistoryBuilder {
|
|
|
335
365
|
self.add_local_activity_marker(seq, activity_id, None, Some(failure), |_| {});
|
|
336
366
|
}
|
|
337
367
|
|
|
368
|
+
/// Add a local activity cancellation marker.
|
|
338
369
|
pub fn add_local_activity_cancel_marker(&mut self, seq: u32, activity_id: &str) {
|
|
339
370
|
self.add_local_activity_marker(
|
|
340
371
|
seq,
|
|
@@ -354,6 +385,7 @@ impl TestHistoryBuilder {
|
|
|
354
385
|
);
|
|
355
386
|
}
|
|
356
387
|
|
|
388
|
+
/// Add an external signal workflow initiation event, returning the event ID.
|
|
357
389
|
pub fn add_signal_wf(
|
|
358
390
|
&mut self,
|
|
359
391
|
signal_name: impl Into<String>,
|
|
@@ -371,6 +403,7 @@ impl TestHistoryBuilder {
|
|
|
371
403
|
})
|
|
372
404
|
}
|
|
373
405
|
|
|
406
|
+
/// Add an external workflow execution signaled event.
|
|
374
407
|
pub fn add_external_signal_completed(&mut self, initiated_id: i64) {
|
|
375
408
|
let attrs = ExternalWorkflowExecutionSignaledEventAttributes {
|
|
376
409
|
initiated_event_id: initiated_id,
|
|
@@ -379,6 +412,7 @@ impl TestHistoryBuilder {
|
|
|
379
412
|
self.build_and_push_event(EventType::ExternalWorkflowExecutionSignaled, attrs.into());
|
|
380
413
|
}
|
|
381
414
|
|
|
415
|
+
/// Add a signal external workflow execution failed event.
|
|
382
416
|
pub fn add_external_signal_failed(&mut self, initiated_id: i64) {
|
|
383
417
|
let attrs = SignalExternalWorkflowExecutionFailedEventAttributes {
|
|
384
418
|
initiated_event_id: initiated_id,
|
|
@@ -390,6 +424,7 @@ impl TestHistoryBuilder {
|
|
|
390
424
|
);
|
|
391
425
|
}
|
|
392
426
|
|
|
427
|
+
/// Add a cancel external workflow initiation event, returning the event ID.
|
|
393
428
|
pub fn add_cancel_external_wf(&mut self, execution: NamespacedWorkflowExecution) -> i64 {
|
|
394
429
|
self.add(
|
|
395
430
|
RequestCancelExternalWorkflowExecutionInitiatedEventAttributes {
|
|
@@ -404,6 +439,7 @@ impl TestHistoryBuilder {
|
|
|
404
439
|
)
|
|
405
440
|
}
|
|
406
441
|
|
|
442
|
+
/// Add a cancel external workflow completed event.
|
|
407
443
|
pub fn add_cancel_external_wf_completed(&mut self, initiated_id: i64) {
|
|
408
444
|
let attrs = ExternalWorkflowExecutionCancelRequestedEventAttributes {
|
|
409
445
|
initiated_event_id: initiated_id,
|
|
@@ -415,6 +451,7 @@ impl TestHistoryBuilder {
|
|
|
415
451
|
);
|
|
416
452
|
}
|
|
417
453
|
|
|
454
|
+
/// Add a cancel external workflow failed event.
|
|
418
455
|
pub fn add_cancel_external_wf_failed(&mut self, initiated_id: i64) {
|
|
419
456
|
let attrs = RequestCancelExternalWorkflowExecutionFailedEventAttributes {
|
|
420
457
|
initiated_event_id: initiated_id,
|
|
@@ -426,12 +463,14 @@ impl TestHistoryBuilder {
|
|
|
426
463
|
);
|
|
427
464
|
}
|
|
428
465
|
|
|
466
|
+
/// Add a workflow execution started event with a custom workflow task timeout.
|
|
429
467
|
pub fn add_wfe_started_with_wft_timeout(&mut self, dur: Duration) {
|
|
430
468
|
let mut wesattrs = default_wes_attribs();
|
|
431
469
|
wesattrs.workflow_task_timeout = Some(dur.try_into().unwrap());
|
|
432
470
|
self.add(wesattrs);
|
|
433
471
|
}
|
|
434
472
|
|
|
473
|
+
/// Add an upsert search attributes event for a patch marker.
|
|
435
474
|
pub fn add_upsert_search_attrs_for_patch(&mut self, attribs: &[String]) {
|
|
436
475
|
let mut indexed_fields = HashMap::new();
|
|
437
476
|
indexed_fields.insert(
|
|
@@ -445,6 +484,7 @@ impl TestHistoryBuilder {
|
|
|
445
484
|
self.build_and_push_event(EventType::UpsertWorkflowSearchAttributes, attrs.into());
|
|
446
485
|
}
|
|
447
486
|
|
|
487
|
+
/// Add a workflow execution update accepted event, returning the event ID.
|
|
448
488
|
pub fn add_update_accepted(
|
|
449
489
|
&mut self,
|
|
450
490
|
instance_id: impl Into<String>,
|
|
@@ -482,6 +522,7 @@ impl TestHistoryBuilder {
|
|
|
482
522
|
self.build_and_push_event(EventType::WorkflowExecutionUpdateAccepted, attrs.into())
|
|
483
523
|
}
|
|
484
524
|
|
|
525
|
+
/// Add a workflow execution update completed event.
|
|
485
526
|
pub fn add_update_completed(&mut self, accepted_event_id: i64) {
|
|
486
527
|
let attrs = WorkflowExecutionUpdateCompletedEventAttributes {
|
|
487
528
|
meta: None,
|
|
@@ -493,6 +534,7 @@ impl TestHistoryBuilder {
|
|
|
493
534
|
self.build_and_push_event(EventType::WorkflowExecutionUpdateCompleted, attrs.into());
|
|
494
535
|
}
|
|
495
536
|
|
|
537
|
+
/// Returns the original run ID from the workflow execution started event.
|
|
496
538
|
pub fn get_orig_run_id(&self) -> &str {
|
|
497
539
|
&self.original_run_id
|
|
498
540
|
}
|
|
@@ -509,6 +551,7 @@ impl TestHistoryBuilder {
|
|
|
509
551
|
HistoryInfo::new_from_history(&self.events.clone().into(), None)
|
|
510
552
|
}
|
|
511
553
|
|
|
554
|
+
/// Returns a single incremental workflow task's worth of history.
|
|
512
555
|
pub fn get_one_wft(&self, from_wft_number: usize) -> Result<HistoryInfo, anyhow::Error> {
|
|
513
556
|
let mut histinfo =
|
|
514
557
|
HistoryInfo::new_from_history(&self.events.clone().into(), Some(from_wft_number))?;
|
|
@@ -625,6 +668,7 @@ fn default_attribs(et: EventType) -> Result<Attributes> {
|
|
|
625
668
|
})
|
|
626
669
|
}
|
|
627
670
|
|
|
671
|
+
/// Returns default workflow execution started attributes for testing.
|
|
628
672
|
pub fn default_wes_attribs() -> WorkflowExecutionStartedEventAttributes {
|
|
629
673
|
WorkflowExecutionStartedEventAttributes {
|
|
630
674
|
original_execution_run_id: Uuid::new_v4().to_string(),
|
|
@@ -645,6 +689,7 @@ pub fn default_wes_attribs() -> WorkflowExecutionStartedEventAttributes {
|
|
|
645
689
|
}
|
|
646
690
|
}
|
|
647
691
|
|
|
692
|
+
/// Returns a default schedule-activity command for testing.
|
|
648
693
|
pub fn default_act_sched() -> ScheduleActivity {
|
|
649
694
|
ScheduleActivity {
|
|
650
695
|
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
@@ -131,10 +131,12 @@ impl HistoryInfo {
|
|
|
131
131
|
self.events.drain(0..last_complete_ix);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
/// Returns a slice of all events in this history.
|
|
134
135
|
pub fn events(&self) -> &[HistoryEvent] {
|
|
135
136
|
&self.events
|
|
136
137
|
}
|
|
137
138
|
|
|
139
|
+
/// Consumes this instance and returns the underlying events.
|
|
138
140
|
pub fn into_events(self) -> Vec<HistoryEvent> {
|
|
139
141
|
self.events
|
|
140
142
|
}
|