@temporalio/core-bridge 1.11.6 → 1.11.8
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 +902 -468
- package/package.json +3 -3
- 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 +5 -0
- package/sdk-core/.github/workflows/per-pr.yml +59 -5
- package/sdk-core/Cargo.toml +3 -2
- package/sdk-core/client/Cargo.toml +3 -3
- package/sdk-core/client/src/lib.rs +154 -161
- package/sdk-core/client/src/metrics.rs +15 -8
- package/sdk-core/client/src/proxy.rs +1 -1
- package/sdk-core/client/src/raw.rs +176 -33
- package/sdk-core/client/src/retry.rs +102 -465
- package/sdk-core/client/src/worker_registry/mod.rs +2 -2
- package/sdk-core/client/src/workflow_handle/mod.rs +19 -1
- package/sdk-core/core/Cargo.toml +12 -14
- package/sdk-core/core/benches/workflow_replay.rs +1 -1
- package/sdk-core/core/src/abstractions.rs +2 -2
- package/sdk-core/core/src/core_tests/activity_tasks.rs +99 -46
- package/sdk-core/core/src/core_tests/child_workflows.rs +68 -9
- package/sdk-core/core/src/core_tests/determinism.rs +2 -2
- package/sdk-core/core/src/core_tests/local_activities.rs +20 -33
- package/sdk-core/core/src/core_tests/mod.rs +7 -8
- package/sdk-core/core/src/core_tests/queries.rs +79 -79
- package/sdk-core/core/src/core_tests/replay_flag.rs +5 -5
- package/sdk-core/core/src/core_tests/updates.rs +6 -6
- package/sdk-core/core/src/core_tests/workers.rs +19 -22
- package/sdk-core/core/src/core_tests/workflow_cancels.rs +3 -3
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +154 -106
- package/sdk-core/core/src/ephemeral_server/mod.rs +66 -10
- package/sdk-core/core/src/internal_flags.rs +103 -12
- package/sdk-core/core/src/lib.rs +21 -13
- package/sdk-core/core/src/pollers/mod.rs +200 -6
- package/sdk-core/core/src/pollers/poll_buffer.rs +32 -8
- package/sdk-core/core/src/protosext/mod.rs +7 -7
- package/sdk-core/core/src/protosext/protocol_messages.rs +2 -2
- package/sdk-core/core/src/replay/mod.rs +8 -9
- package/sdk-core/core/src/retry_logic.rs +8 -6
- package/sdk-core/core/src/telemetry/log_export.rs +4 -4
- package/sdk-core/core/src/telemetry/metrics.rs +111 -25
- package/sdk-core/core/src/telemetry/mod.rs +11 -4
- package/sdk-core/core/src/telemetry/otel.rs +108 -144
- package/sdk-core/core/src/telemetry/prometheus_server.rs +1 -4
- package/sdk-core/core/src/test_help/mod.rs +27 -21
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +7 -5
- package/sdk-core/core/src/worker/activities/local_activities.rs +9 -9
- package/sdk-core/core/src/worker/activities.rs +34 -46
- package/sdk-core/core/src/worker/client/mocks.rs +24 -2
- package/sdk-core/core/src/worker/client.rs +169 -33
- package/sdk-core/core/src/worker/mod.rs +132 -56
- package/sdk-core/core/src/worker/nexus.rs +410 -0
- package/sdk-core/core/src/worker/tuner/resource_based.rs +27 -5
- package/sdk-core/core/src/worker/tuner.rs +29 -2
- package/sdk-core/core/src/worker/workflow/driven_workflow.rs +8 -3
- package/sdk-core/core/src/worker/workflow/history_update.rs +5 -8
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +83 -87
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +38 -38
- package/sdk-core/core/src/worker/workflow/machines/cancel_nexus_op_state_machine.rs +117 -0
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +8 -18
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +114 -108
- package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +16 -31
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +7 -14
- package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +8 -15
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +34 -75
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +26 -48
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +10 -17
- package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +543 -0
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +22 -31
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +53 -51
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +40 -45
- package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +2 -2
- package/sdk-core/core/src/worker/workflow/machines/update_state_machine.rs +8 -10
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +24 -30
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +182 -116
- package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +4 -8
- package/sdk-core/core/src/worker/workflow/managed_run.rs +75 -45
- package/sdk-core/core/src/worker/workflow/mod.rs +104 -55
- package/sdk-core/core/src/worker/workflow/run_cache.rs +23 -4
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +4 -4
- package/sdk-core/core/src/worker/workflow/wft_poller.rs +3 -3
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +32 -13
- package/sdk-core/core-api/Cargo.toml +2 -3
- package/sdk-core/core-api/src/errors.rs +22 -20
- package/sdk-core/core-api/src/lib.rs +24 -5
- package/sdk-core/core-api/src/telemetry/metrics.rs +27 -1
- package/sdk-core/core-api/src/telemetry.rs +37 -3
- package/sdk-core/core-api/src/worker.rs +36 -3
- package/sdk-core/docker/docker-compose-ci.yaml +25 -0
- package/sdk-core/etc/otel-collector-ci.yaml +36 -0
- package/sdk-core/etc/otel-collector-config.yaml +3 -3
- package/sdk-core/etc/prometheus.yaml +1 -1
- package/sdk-core/fsm/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +3 -4
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- package/sdk-core/fsm/rustfsm_trait/Cargo.toml +1 -1
- package/sdk-core/sdk/Cargo.toml +1 -2
- package/sdk-core/sdk/src/activity_context.rs +1 -1
- package/sdk-core/sdk/src/interceptors.rs +1 -1
- package/sdk-core/sdk/src/lib.rs +126 -54
- package/sdk-core/sdk/src/workflow_context/options.rs +184 -74
- package/sdk-core/sdk/src/workflow_context.rs +193 -79
- package/sdk-core/sdk/src/workflow_future.rs +151 -131
- package/sdk-core/sdk-core-protos/Cargo.toml +3 -4
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +1 -1
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/account/v1/message.proto +46 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +254 -5
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +108 -2
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +94 -15
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +102 -4
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +84 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +25 -10
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +14 -1
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/resource/v1/message.proto +25 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/sink/v1/message.proto +41 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/usage/v1/message.proto +59 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/create-release.yml +135 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/push-to-buf.yml +20 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-delete-release.yml +13 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-publish-release.yml +13 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +13 -21
- package/sdk-core/sdk-core-protos/protos/api_upstream/Makefile +2 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +1 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +3386 -1047
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +3529 -1144
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/batch/v1/message.proto +39 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +39 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +252 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +1 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/deployment.proto +96 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/nexus.proto +42 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/workflow.proto +43 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/errordetails/v1/message.proto +13 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +14 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +70 -12
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +12 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/query/v1/message.proto +9 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +46 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +206 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +482 -97
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +230 -43
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/core_interface.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/nexus/nexus.proto +71 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +46 -2
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +55 -9
- package/sdk-core/sdk-core-protos/src/history_builder.rs +5 -5
- package/sdk-core/sdk-core-protos/src/history_info.rs +5 -6
- package/sdk-core/sdk-core-protos/src/lib.rs +414 -34
- package/sdk-core/sdk-core-protos/src/task_token.rs +1 -1
- package/sdk-core/test-utils/Cargo.toml +3 -11
- package/sdk-core/test-utils/src/canned_histories.rs +1 -1
- package/sdk-core/test-utils/src/lib.rs +159 -85
- package/sdk-core/tests/fuzzy_workflow.rs +3 -3
- package/sdk-core/tests/heavy_tests.rs +3 -3
- package/sdk-core/tests/integ_tests/client_tests.rs +171 -20
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +45 -39
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +7 -6
- package/sdk-core/tests/integ_tests/metrics_tests.rs +492 -35
- package/sdk-core/tests/integ_tests/polling_tests.rs +7 -5
- package/sdk-core/tests/integ_tests/queries_tests.rs +14 -17
- package/sdk-core/tests/integ_tests/update_tests.rs +47 -44
- package/sdk-core/tests/integ_tests/visibility_tests.rs +4 -3
- package/sdk-core/tests/integ_tests/worker_tests.rs +5 -5
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +15 -13
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +28 -14
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +7 -1
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +57 -4
- package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +24 -18
- package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +506 -0
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/priority.rs +104 -0
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +34 -31
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -7
- package/sdk-core/tests/integ_tests/workflow_tests.rs +152 -116
- package/sdk-core/tests/main.rs +36 -6
- package/sdk-core/tests/runner.rs +30 -9
- package/src/conversions/slot_supplier_bridge.rs +4 -0
- package/src/conversions.rs +1 -0
- package/src/worker.rs +5 -7
- package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +0 -78
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
use crate::worker::workflow::{
|
|
2
|
+
WFMachinesError,
|
|
3
|
+
machines::{
|
|
4
|
+
EventInfo, HistEventData, NewMachineWithCommand, OnEventWrapper, WFMachinesAdapter,
|
|
5
|
+
workflow_machines::MachineResponse,
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
use itertools::Itertools;
|
|
9
|
+
use rustfsm::{MachineError, StateMachine, TransitionResult, fsm};
|
|
10
|
+
use temporal_sdk_core_protos::{
|
|
11
|
+
coresdk::{
|
|
12
|
+
nexus::{NexusOperationResult, nexus_operation_result},
|
|
13
|
+
workflow_activation::{
|
|
14
|
+
ResolveNexusOperation, ResolveNexusOperationStart, resolve_nexus_operation_start,
|
|
15
|
+
},
|
|
16
|
+
workflow_commands::ScheduleNexusOperation,
|
|
17
|
+
},
|
|
18
|
+
temporal::api::{
|
|
19
|
+
command::v1::{RequestCancelNexusOperationCommandAttributes, command},
|
|
20
|
+
common::v1::Payload,
|
|
21
|
+
enums::v1::{CommandType, EventType},
|
|
22
|
+
failure::v1::{self as failure, Failure, failure::FailureInfo},
|
|
23
|
+
history::v1::{
|
|
24
|
+
NexusOperationCanceledEventAttributes, NexusOperationCompletedEventAttributes,
|
|
25
|
+
NexusOperationFailedEventAttributes, NexusOperationStartedEventAttributes,
|
|
26
|
+
NexusOperationTimedOutEventAttributes, history_event,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
fsm! {
|
|
32
|
+
pub(super) name NexusOperationMachine;
|
|
33
|
+
command NexusOperationCommand;
|
|
34
|
+
error WFMachinesError;
|
|
35
|
+
shared_state SharedState;
|
|
36
|
+
|
|
37
|
+
ScheduleCommandCreated --(CommandScheduleNexusOperation)--> ScheduleCommandCreated;
|
|
38
|
+
ScheduleCommandCreated
|
|
39
|
+
--(NexusOperationScheduled(NexusOpScheduledData), shared on_scheduled)--> ScheduledEventRecorded;
|
|
40
|
+
ScheduleCommandCreated --(Cancel, shared on_cancelled)--> Cancelled;
|
|
41
|
+
|
|
42
|
+
ScheduledEventRecorded --(Cancel, shared on_issue_cancel)--> ScheduledEventRecorded;
|
|
43
|
+
ScheduledEventRecorded --(CommandRequestCancelNexusOperation)--> ScheduledEventRecorded;
|
|
44
|
+
ScheduledEventRecorded --(NexusOperationCancelRequested)--> ScheduledEventRecorded;
|
|
45
|
+
ScheduledEventRecorded
|
|
46
|
+
--(NexusOperationCompleted(NexusOperationCompletedEventAttributes), on_completed)--> Completed;
|
|
47
|
+
ScheduledEventRecorded
|
|
48
|
+
--(NexusOperationFailed(NexusOperationFailedEventAttributes), on_failed)--> Failed;
|
|
49
|
+
ScheduledEventRecorded
|
|
50
|
+
--(NexusOperationCanceled(NexusOperationCanceledEventAttributes), on_canceled)--> Cancelled;
|
|
51
|
+
ScheduledEventRecorded
|
|
52
|
+
--(NexusOperationTimedOut(NexusOperationTimedOutEventAttributes), on_timed_out)--> TimedOut;
|
|
53
|
+
ScheduledEventRecorded
|
|
54
|
+
--(NexusOperationStarted(NexusOperationStartedEventAttributes), on_started)--> Started;
|
|
55
|
+
|
|
56
|
+
Started --(Cancel, shared on_issue_cancel)--> Started;
|
|
57
|
+
Started --(CommandRequestCancelNexusOperation)--> Started;
|
|
58
|
+
Started --(NexusOperationCancelRequested)--> Started;
|
|
59
|
+
Started
|
|
60
|
+
--(NexusOperationCompleted(NexusOperationCompletedEventAttributes), on_completed)--> Completed;
|
|
61
|
+
Started
|
|
62
|
+
--(NexusOperationFailed(NexusOperationFailedEventAttributes), on_failed)--> Failed;
|
|
63
|
+
Started
|
|
64
|
+
--(NexusOperationCanceled(NexusOperationCanceledEventAttributes), on_canceled)--> Cancelled;
|
|
65
|
+
Started
|
|
66
|
+
--(NexusOperationTimedOut(NexusOperationTimedOutEventAttributes), on_timed_out)--> TimedOut;
|
|
67
|
+
|
|
68
|
+
// Ignore cancels in all terminal states
|
|
69
|
+
Completed --(Cancel)--> Completed;
|
|
70
|
+
Failed --(Cancel)--> Failed;
|
|
71
|
+
Cancelled --(Cancel)--> Cancelled;
|
|
72
|
+
TimedOut --(Cancel)--> TimedOut;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#[derive(Debug, derive_more::Display)]
|
|
76
|
+
pub(super) enum NexusOperationCommand {
|
|
77
|
+
#[display("Start")]
|
|
78
|
+
Start { operation_id: String },
|
|
79
|
+
#[display("CancelBeforeStart")]
|
|
80
|
+
CancelBeforeStart,
|
|
81
|
+
#[display("Complete")]
|
|
82
|
+
Complete(Option<Payload>),
|
|
83
|
+
#[display("Fail")]
|
|
84
|
+
Fail(Failure),
|
|
85
|
+
#[display("Cancel")]
|
|
86
|
+
Cancel(Failure),
|
|
87
|
+
#[display("TimedOut")]
|
|
88
|
+
TimedOut(Failure),
|
|
89
|
+
#[display("IssueCancel")]
|
|
90
|
+
IssueCancel,
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#[derive(Clone, Debug)]
|
|
94
|
+
pub(super) struct SharedState {
|
|
95
|
+
lang_seq_num: u32,
|
|
96
|
+
pub(super) scheduled_event_id: i64,
|
|
97
|
+
endpoint: String,
|
|
98
|
+
service: String,
|
|
99
|
+
operation: String,
|
|
100
|
+
|
|
101
|
+
cancelled_before_sent: bool,
|
|
102
|
+
cancel_sent: bool,
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
impl NexusOperationMachine {
|
|
106
|
+
pub(super) fn new_scheduled(attribs: ScheduleNexusOperation) -> NewMachineWithCommand {
|
|
107
|
+
let s = Self::from_parts(
|
|
108
|
+
ScheduleCommandCreated.into(),
|
|
109
|
+
SharedState {
|
|
110
|
+
lang_seq_num: attribs.seq,
|
|
111
|
+
scheduled_event_id: 0,
|
|
112
|
+
endpoint: attribs.endpoint.clone(),
|
|
113
|
+
service: attribs.service.clone(),
|
|
114
|
+
operation: attribs.operation.clone(),
|
|
115
|
+
cancelled_before_sent: false,
|
|
116
|
+
cancel_sent: false,
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
NewMachineWithCommand {
|
|
120
|
+
command: attribs.into(),
|
|
121
|
+
machine: s.into(),
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
pub(super) fn cancel(&mut self) -> Result<Vec<MachineResponse>, MachineError<WFMachinesError>> {
|
|
126
|
+
let event = NexusOperationMachineEvents::Cancel;
|
|
127
|
+
let cmds = OnEventWrapper::on_event_mut(self, event)?;
|
|
128
|
+
let mach_resps = cmds
|
|
129
|
+
.into_iter()
|
|
130
|
+
.map(|mc| self.adapt_response(mc, None))
|
|
131
|
+
.flatten_ok()
|
|
132
|
+
.try_collect()?;
|
|
133
|
+
Ok(mach_resps)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
pub(super) fn was_cancelled_before_sent_to_server(&self) -> bool {
|
|
137
|
+
self.shared_state.cancelled_before_sent
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#[derive(Default, Clone)]
|
|
142
|
+
pub(super) struct ScheduleCommandCreated;
|
|
143
|
+
|
|
144
|
+
pub(super) struct NexusOpScheduledData {
|
|
145
|
+
event_id: i64,
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
impl ScheduleCommandCreated {
|
|
149
|
+
pub(super) fn on_scheduled(
|
|
150
|
+
self,
|
|
151
|
+
state: &mut SharedState,
|
|
152
|
+
event_dat: NexusOpScheduledData,
|
|
153
|
+
) -> NexusOperationMachineTransition<ScheduledEventRecorded> {
|
|
154
|
+
state.scheduled_event_id = event_dat.event_id;
|
|
155
|
+
NexusOperationMachineTransition::default()
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
pub(super) fn on_cancelled(
|
|
159
|
+
self,
|
|
160
|
+
state: &mut SharedState,
|
|
161
|
+
) -> NexusOperationMachineTransition<Cancelled> {
|
|
162
|
+
state.cancelled_before_sent = true;
|
|
163
|
+
NexusOperationMachineTransition::commands([NexusOperationCommand::CancelBeforeStart])
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#[derive(Default, Clone)]
|
|
168
|
+
pub(super) struct ScheduledEventRecorded;
|
|
169
|
+
|
|
170
|
+
impl ScheduledEventRecorded {
|
|
171
|
+
pub(crate) fn on_issue_cancel(
|
|
172
|
+
&self,
|
|
173
|
+
ss: &mut SharedState,
|
|
174
|
+
) -> NexusOperationMachineTransition<ScheduledEventRecorded> {
|
|
175
|
+
if !ss.cancel_sent {
|
|
176
|
+
ss.cancel_sent = true;
|
|
177
|
+
NexusOperationMachineTransition::commands([NexusOperationCommand::IssueCancel])
|
|
178
|
+
} else {
|
|
179
|
+
NexusOperationMachineTransition::default()
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
pub(super) fn on_completed(
|
|
184
|
+
self,
|
|
185
|
+
ca: NexusOperationCompletedEventAttributes,
|
|
186
|
+
) -> NexusOperationMachineTransition<Completed> {
|
|
187
|
+
NexusOperationMachineTransition::commands([
|
|
188
|
+
NexusOperationCommand::Start {
|
|
189
|
+
operation_id: String::default(),
|
|
190
|
+
},
|
|
191
|
+
NexusOperationCommand::Complete(ca.result),
|
|
192
|
+
])
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
pub(super) fn on_failed(
|
|
196
|
+
self,
|
|
197
|
+
fa: NexusOperationFailedEventAttributes,
|
|
198
|
+
) -> NexusOperationMachineTransition<Failed> {
|
|
199
|
+
NexusOperationMachineTransition::commands([
|
|
200
|
+
NexusOperationCommand::Start {
|
|
201
|
+
operation_id: String::default(),
|
|
202
|
+
},
|
|
203
|
+
NexusOperationCommand::Fail(fa.failure.unwrap_or_else(|| Failure {
|
|
204
|
+
message: "Nexus operation failed but failure field was not populated".to_owned(),
|
|
205
|
+
..Default::default()
|
|
206
|
+
})),
|
|
207
|
+
])
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
pub(super) fn on_canceled(
|
|
211
|
+
self,
|
|
212
|
+
ca: NexusOperationCanceledEventAttributes,
|
|
213
|
+
) -> NexusOperationMachineTransition<Cancelled> {
|
|
214
|
+
NexusOperationMachineTransition::commands([
|
|
215
|
+
NexusOperationCommand::Start {
|
|
216
|
+
operation_id: String::default(),
|
|
217
|
+
},
|
|
218
|
+
NexusOperationCommand::Cancel(ca.failure.unwrap_or_else(|| Failure {
|
|
219
|
+
message:
|
|
220
|
+
"Nexus operation was cancelled but failure field was not populated".to_owned(),
|
|
221
|
+
..Default::default()
|
|
222
|
+
})),
|
|
223
|
+
])
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
pub(super) fn on_timed_out(
|
|
227
|
+
self,
|
|
228
|
+
toa: NexusOperationTimedOutEventAttributes,
|
|
229
|
+
) -> NexusOperationMachineTransition<TimedOut> {
|
|
230
|
+
NexusOperationMachineTransition::commands([
|
|
231
|
+
NexusOperationCommand::Start {
|
|
232
|
+
operation_id: String::default(),
|
|
233
|
+
},
|
|
234
|
+
NexusOperationCommand::TimedOut(toa.failure.unwrap_or_else(|| Failure {
|
|
235
|
+
message: "Nexus operation timed out but failure field was not populated".to_owned(),
|
|
236
|
+
..Default::default()
|
|
237
|
+
})),
|
|
238
|
+
])
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
pub(super) fn on_started(
|
|
242
|
+
self,
|
|
243
|
+
sa: NexusOperationStartedEventAttributes,
|
|
244
|
+
) -> NexusOperationMachineTransition<Started> {
|
|
245
|
+
NexusOperationMachineTransition::commands([NexusOperationCommand::Start {
|
|
246
|
+
operation_id: sa.operation_id,
|
|
247
|
+
}])
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
#[derive(Default, Clone)]
|
|
252
|
+
pub(super) struct Started;
|
|
253
|
+
|
|
254
|
+
impl Started {
|
|
255
|
+
pub(crate) fn on_issue_cancel(
|
|
256
|
+
&self,
|
|
257
|
+
ss: &mut SharedState,
|
|
258
|
+
) -> NexusOperationMachineTransition<Started> {
|
|
259
|
+
if !ss.cancel_sent {
|
|
260
|
+
ss.cancel_sent = true;
|
|
261
|
+
NexusOperationMachineTransition::commands([NexusOperationCommand::IssueCancel])
|
|
262
|
+
} else {
|
|
263
|
+
NexusOperationMachineTransition::default()
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
pub(super) fn on_completed(
|
|
268
|
+
self,
|
|
269
|
+
ca: NexusOperationCompletedEventAttributes,
|
|
270
|
+
) -> NexusOperationMachineTransition<Completed> {
|
|
271
|
+
NexusOperationMachineTransition::commands([NexusOperationCommand::Complete(ca.result)])
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
pub(super) fn on_failed(
|
|
275
|
+
self,
|
|
276
|
+
fa: NexusOperationFailedEventAttributes,
|
|
277
|
+
) -> NexusOperationMachineTransition<Failed> {
|
|
278
|
+
NexusOperationMachineTransition::commands([NexusOperationCommand::Fail(
|
|
279
|
+
fa.failure.unwrap_or_else(|| Failure {
|
|
280
|
+
message: "Nexus operation failed but failure field was not populated".to_owned(),
|
|
281
|
+
..Default::default()
|
|
282
|
+
}),
|
|
283
|
+
)])
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
pub(super) fn on_canceled(
|
|
287
|
+
self,
|
|
288
|
+
ca: NexusOperationCanceledEventAttributes,
|
|
289
|
+
) -> NexusOperationMachineTransition<Cancelled> {
|
|
290
|
+
NexusOperationMachineTransition::commands([NexusOperationCommand::Cancel(
|
|
291
|
+
ca.failure.unwrap_or_else(|| Failure {
|
|
292
|
+
message: "Nexus operation was cancelled but failure field was not populated"
|
|
293
|
+
.to_owned(),
|
|
294
|
+
..Default::default()
|
|
295
|
+
}),
|
|
296
|
+
)])
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
pub(super) fn on_timed_out(
|
|
300
|
+
self,
|
|
301
|
+
toa: NexusOperationTimedOutEventAttributes,
|
|
302
|
+
) -> NexusOperationMachineTransition<TimedOut> {
|
|
303
|
+
NexusOperationMachineTransition::commands([NexusOperationCommand::TimedOut(
|
|
304
|
+
toa.failure.unwrap_or_else(|| Failure {
|
|
305
|
+
message: "Nexus operation timed out but failure field was not populated".to_owned(),
|
|
306
|
+
..Default::default()
|
|
307
|
+
}),
|
|
308
|
+
)])
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
#[derive(Default, Clone)]
|
|
313
|
+
pub(super) struct Completed;
|
|
314
|
+
|
|
315
|
+
#[derive(Default, Clone)]
|
|
316
|
+
pub(super) struct Failed;
|
|
317
|
+
|
|
318
|
+
#[derive(Default, Clone)]
|
|
319
|
+
pub(super) struct TimedOut;
|
|
320
|
+
|
|
321
|
+
#[derive(Default, Clone)]
|
|
322
|
+
pub(super) struct Cancelled;
|
|
323
|
+
|
|
324
|
+
impl TryFrom<HistEventData> for NexusOperationMachineEvents {
|
|
325
|
+
type Error = WFMachinesError;
|
|
326
|
+
|
|
327
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
|
328
|
+
let e = e.event;
|
|
329
|
+
Ok(match EventType::try_from(e.event_type) {
|
|
330
|
+
Ok(EventType::NexusOperationScheduled) => {
|
|
331
|
+
if let Some(history_event::Attributes::NexusOperationScheduledEventAttributes(_)) =
|
|
332
|
+
e.attributes
|
|
333
|
+
{
|
|
334
|
+
Self::NexusOperationScheduled(NexusOpScheduledData {
|
|
335
|
+
event_id: e.event_id,
|
|
336
|
+
})
|
|
337
|
+
} else {
|
|
338
|
+
return Err(WFMachinesError::Nondeterminism(
|
|
339
|
+
"NexusOperationScheduled attributes were unset or malformed".to_string(),
|
|
340
|
+
));
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
Ok(EventType::NexusOperationStarted) => {
|
|
344
|
+
if let Some(history_event::Attributes::NexusOperationStartedEventAttributes(sa)) =
|
|
345
|
+
e.attributes
|
|
346
|
+
{
|
|
347
|
+
Self::NexusOperationStarted(sa)
|
|
348
|
+
} else {
|
|
349
|
+
return Err(WFMachinesError::Nondeterminism(
|
|
350
|
+
"NexusOperationStarted attributes were unset or malformed".to_string(),
|
|
351
|
+
));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
Ok(EventType::NexusOperationCompleted) => {
|
|
355
|
+
if let Some(history_event::Attributes::NexusOperationCompletedEventAttributes(ca)) =
|
|
356
|
+
e.attributes
|
|
357
|
+
{
|
|
358
|
+
Self::NexusOperationCompleted(ca)
|
|
359
|
+
} else {
|
|
360
|
+
return Err(WFMachinesError::Nondeterminism(
|
|
361
|
+
"NexusOperationCompleted attributes were unset or malformed".to_string(),
|
|
362
|
+
));
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
Ok(EventType::NexusOperationFailed) => {
|
|
366
|
+
if let Some(history_event::Attributes::NexusOperationFailedEventAttributes(fa)) =
|
|
367
|
+
e.attributes
|
|
368
|
+
{
|
|
369
|
+
Self::NexusOperationFailed(fa)
|
|
370
|
+
} else {
|
|
371
|
+
return Err(WFMachinesError::Nondeterminism(
|
|
372
|
+
"NexusOperationFailed attributes were unset or malformed".to_string(),
|
|
373
|
+
));
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
Ok(EventType::NexusOperationCanceled) => {
|
|
377
|
+
if let Some(history_event::Attributes::NexusOperationCanceledEventAttributes(ca)) =
|
|
378
|
+
e.attributes
|
|
379
|
+
{
|
|
380
|
+
Self::NexusOperationCanceled(ca)
|
|
381
|
+
} else {
|
|
382
|
+
return Err(WFMachinesError::Nondeterminism(
|
|
383
|
+
"NexusOperationCanceled attributes were unset or malformed".to_string(),
|
|
384
|
+
));
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
Ok(EventType::NexusOperationTimedOut) => {
|
|
388
|
+
if let Some(history_event::Attributes::NexusOperationTimedOutEventAttributes(toa)) =
|
|
389
|
+
e.attributes
|
|
390
|
+
{
|
|
391
|
+
Self::NexusOperationTimedOut(toa)
|
|
392
|
+
} else {
|
|
393
|
+
return Err(WFMachinesError::Nondeterminism(
|
|
394
|
+
"NexusOperationTimedOut attributes were unset or malformed".to_string(),
|
|
395
|
+
));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
Ok(EventType::NexusOperationCancelRequested) => Self::NexusOperationCancelRequested,
|
|
399
|
+
_ => {
|
|
400
|
+
return Err(WFMachinesError::Nondeterminism(format!(
|
|
401
|
+
"Nexus operation machine does not handle this event: {e:?}"
|
|
402
|
+
)));
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
impl WFMachinesAdapter for NexusOperationMachine {
|
|
409
|
+
fn adapt_response(
|
|
410
|
+
&self,
|
|
411
|
+
my_command: Self::Command,
|
|
412
|
+
_: Option<EventInfo>,
|
|
413
|
+
) -> Result<Vec<MachineResponse>, WFMachinesError> {
|
|
414
|
+
Ok(match my_command {
|
|
415
|
+
NexusOperationCommand::Start { operation_id } => {
|
|
416
|
+
vec![
|
|
417
|
+
ResolveNexusOperationStart {
|
|
418
|
+
seq: self.shared_state.lang_seq_num,
|
|
419
|
+
status: Some(resolve_nexus_operation_start::Status::OperationId(
|
|
420
|
+
operation_id,
|
|
421
|
+
)),
|
|
422
|
+
}
|
|
423
|
+
.into(),
|
|
424
|
+
]
|
|
425
|
+
}
|
|
426
|
+
NexusOperationCommand::CancelBeforeStart => {
|
|
427
|
+
vec![
|
|
428
|
+
ResolveNexusOperationStart {
|
|
429
|
+
seq: self.shared_state.lang_seq_num,
|
|
430
|
+
status: Some(resolve_nexus_operation_start::Status::CancelledBeforeStart(
|
|
431
|
+
self.cancelled_failure(
|
|
432
|
+
"Nexus Operation cancelled before scheduled".to_owned(),
|
|
433
|
+
),
|
|
434
|
+
)),
|
|
435
|
+
}
|
|
436
|
+
.into(),
|
|
437
|
+
ResolveNexusOperation {
|
|
438
|
+
seq: self.shared_state.lang_seq_num,
|
|
439
|
+
result: Some(NexusOperationResult {
|
|
440
|
+
status: Some(nexus_operation_result::Status::Cancelled(
|
|
441
|
+
self.cancelled_failure(
|
|
442
|
+
"Nexus Operation cancelled before scheduled".to_owned(),
|
|
443
|
+
),
|
|
444
|
+
)),
|
|
445
|
+
}),
|
|
446
|
+
}
|
|
447
|
+
.into(),
|
|
448
|
+
]
|
|
449
|
+
}
|
|
450
|
+
NexusOperationCommand::Complete(c) => {
|
|
451
|
+
vec![
|
|
452
|
+
ResolveNexusOperation {
|
|
453
|
+
seq: self.shared_state.lang_seq_num,
|
|
454
|
+
result: Some(NexusOperationResult {
|
|
455
|
+
status: Some(nexus_operation_result::Status::Completed(
|
|
456
|
+
c.unwrap_or_default(),
|
|
457
|
+
)),
|
|
458
|
+
}),
|
|
459
|
+
}
|
|
460
|
+
.into(),
|
|
461
|
+
]
|
|
462
|
+
}
|
|
463
|
+
NexusOperationCommand::Fail(f) => {
|
|
464
|
+
vec![
|
|
465
|
+
ResolveNexusOperation {
|
|
466
|
+
seq: self.shared_state.lang_seq_num,
|
|
467
|
+
result: Some(NexusOperationResult {
|
|
468
|
+
status: Some(nexus_operation_result::Status::Failed(f)),
|
|
469
|
+
}),
|
|
470
|
+
}
|
|
471
|
+
.into(),
|
|
472
|
+
]
|
|
473
|
+
}
|
|
474
|
+
NexusOperationCommand::Cancel(f) => {
|
|
475
|
+
vec![
|
|
476
|
+
ResolveNexusOperation {
|
|
477
|
+
seq: self.shared_state.lang_seq_num,
|
|
478
|
+
result: Some(NexusOperationResult {
|
|
479
|
+
status: Some(nexus_operation_result::Status::Cancelled(f)),
|
|
480
|
+
}),
|
|
481
|
+
}
|
|
482
|
+
.into(),
|
|
483
|
+
]
|
|
484
|
+
}
|
|
485
|
+
NexusOperationCommand::TimedOut(f) => {
|
|
486
|
+
vec![
|
|
487
|
+
ResolveNexusOperation {
|
|
488
|
+
seq: self.shared_state.lang_seq_num,
|
|
489
|
+
result: Some(NexusOperationResult {
|
|
490
|
+
status: Some(nexus_operation_result::Status::TimedOut(f)),
|
|
491
|
+
}),
|
|
492
|
+
}
|
|
493
|
+
.into(),
|
|
494
|
+
]
|
|
495
|
+
}
|
|
496
|
+
NexusOperationCommand::IssueCancel => {
|
|
497
|
+
vec![MachineResponse::IssueNewCommand(
|
|
498
|
+
command::Attributes::RequestCancelNexusOperationCommandAttributes(
|
|
499
|
+
RequestCancelNexusOperationCommandAttributes {
|
|
500
|
+
scheduled_event_id: self.shared_state.scheduled_event_id,
|
|
501
|
+
},
|
|
502
|
+
)
|
|
503
|
+
.into(),
|
|
504
|
+
)]
|
|
505
|
+
}
|
|
506
|
+
})
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
impl TryFrom<CommandType> for NexusOperationMachineEvents {
|
|
511
|
+
type Error = ();
|
|
512
|
+
|
|
513
|
+
fn try_from(c: CommandType) -> Result<Self, Self::Error> {
|
|
514
|
+
Ok(match c {
|
|
515
|
+
CommandType::ScheduleNexusOperation => Self::CommandScheduleNexusOperation,
|
|
516
|
+
CommandType::RequestCancelNexusOperation => Self::CommandRequestCancelNexusOperation,
|
|
517
|
+
_ => return Err(()),
|
|
518
|
+
})
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
impl NexusOperationMachine {
|
|
523
|
+
fn cancelled_failure(&self, message: String) -> Failure {
|
|
524
|
+
Failure {
|
|
525
|
+
message,
|
|
526
|
+
cause: Some(Box::new(Failure {
|
|
527
|
+
failure_info: Some(FailureInfo::CanceledFailureInfo(Default::default())),
|
|
528
|
+
..Default::default()
|
|
529
|
+
})),
|
|
530
|
+
failure_info: Some(FailureInfo::NexusOperationExecutionFailureInfo(
|
|
531
|
+
failure::NexusOperationFailureInfo {
|
|
532
|
+
scheduled_event_id: self.shared_state.scheduled_event_id,
|
|
533
|
+
endpoint: self.shared_state.endpoint.clone(),
|
|
534
|
+
service: self.shared_state.service.clone(),
|
|
535
|
+
operation: self.shared_state.operation.clone(),
|
|
536
|
+
operation_id: "".to_string(),
|
|
537
|
+
operation_token: "".to_string(),
|
|
538
|
+
},
|
|
539
|
+
)),
|
|
540
|
+
..Default::default()
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
@@ -18,31 +18,31 @@
|
|
|
18
18
|
//! | replaying, no marker | deprecate_patch | Call allowed |
|
|
19
19
|
|
|
20
20
|
use super::{
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
EventInfo, NewMachineWithCommand, OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
|
22
|
+
workflow_machines::MachineResponse,
|
|
23
23
|
};
|
|
24
24
|
use crate::{
|
|
25
25
|
internal_flags::CoreInternalFlags,
|
|
26
26
|
protosext::HistoryEventExt,
|
|
27
27
|
worker::workflow::{
|
|
28
|
+
InternalFlagsRef,
|
|
28
29
|
machines::{
|
|
29
|
-
upsert_search_attributes_state_machine::MAX_SEARCH_ATTR_PAYLOAD_SIZE,
|
|
30
|
+
HistEventData, upsert_search_attributes_state_machine::MAX_SEARCH_ATTR_PAYLOAD_SIZE,
|
|
30
31
|
},
|
|
31
|
-
InternalFlagsRef,
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
use anyhow::Context;
|
|
35
|
-
use rustfsm::{
|
|
35
|
+
use rustfsm::{StateMachine, TransitionResult, fsm};
|
|
36
36
|
use std::{
|
|
37
37
|
collections::{BTreeSet, HashMap},
|
|
38
38
|
convert::TryFrom,
|
|
39
39
|
};
|
|
40
40
|
use temporal_sdk_core_protos::{
|
|
41
41
|
constants::PATCH_MARKER_NAME,
|
|
42
|
-
coresdk::{common::build_has_change_marker_details
|
|
42
|
+
coresdk::{AsJsonPayloadExt, common::build_has_change_marker_details},
|
|
43
43
|
temporal::api::{
|
|
44
44
|
command::v1::{
|
|
45
|
-
|
|
45
|
+
RecordMarkerCommandAttributes, UpsertWorkflowSearchAttributesCommandAttributes,
|
|
46
46
|
},
|
|
47
47
|
common::v1::SearchAttributes,
|
|
48
48
|
enums::v1::CommandType,
|
|
@@ -102,20 +102,14 @@ pub(super) fn has_change<'a>(
|
|
|
102
102
|
} else {
|
|
103
103
|
Executing {}.into()
|
|
104
104
|
};
|
|
105
|
-
let command =
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
failure: None,
|
|
114
|
-
}
|
|
115
|
-
.into(),
|
|
116
|
-
),
|
|
117
|
-
user_metadata: Default::default(),
|
|
118
|
-
};
|
|
105
|
+
let command = RecordMarkerCommandAttributes {
|
|
106
|
+
marker_name: PATCH_MARKER_NAME.to_string(),
|
|
107
|
+
details: build_has_change_marker_details(&shared_state.patch_id, deprecated)
|
|
108
|
+
.context("While encoding patch marker details")?,
|
|
109
|
+
header: None,
|
|
110
|
+
failure: None,
|
|
111
|
+
}
|
|
112
|
+
.into();
|
|
119
113
|
let mut machine = PatchMachine::from_parts(initial_state, shared_state);
|
|
120
114
|
|
|
121
115
|
OnEventWrapper::on_event_mut(&mut machine, PatchMachineEvents::Schedule)
|
|
@@ -239,8 +233,6 @@ impl WFMachinesAdapter for PatchMachine {
|
|
|
239
233
|
}
|
|
240
234
|
}
|
|
241
235
|
|
|
242
|
-
impl Cancellable for PatchMachine {}
|
|
243
|
-
|
|
244
236
|
impl TryFrom<CommandType> for PatchMachineEvents {
|
|
245
237
|
type Error = ();
|
|
246
238
|
|
|
@@ -278,27 +270,27 @@ mod tests {
|
|
|
278
270
|
use crate::{
|
|
279
271
|
internal_flags::CoreInternalFlags,
|
|
280
272
|
replay::TestHistoryBuilder,
|
|
281
|
-
test_help::{
|
|
273
|
+
test_help::{MockPollCfg, ResponseType, build_fake_sdk},
|
|
282
274
|
worker::workflow::machines::patch_state_machine::VERSION_SEARCH_ATTR_KEY,
|
|
283
275
|
};
|
|
284
276
|
use rstest::rstest;
|
|
285
277
|
use std::{
|
|
286
|
-
collections::{
|
|
278
|
+
collections::{HashSet, VecDeque, hash_map::RandomState},
|
|
287
279
|
time::Duration,
|
|
288
280
|
};
|
|
289
281
|
use temporal_sdk::{ActivityOptions, WfContext};
|
|
290
282
|
use temporal_sdk_core_protos::{
|
|
283
|
+
DEFAULT_WORKFLOW_TYPE,
|
|
291
284
|
constants::PATCH_MARKER_NAME,
|
|
292
285
|
coresdk::{
|
|
293
|
-
common::decode_change_marker_details,
|
|
294
|
-
workflow_activation::{workflow_activation_job, NotifyHasPatch, WorkflowActivationJob},
|
|
295
286
|
AsJsonPayloadExt, FromJsonPayloadExt,
|
|
287
|
+
common::decode_change_marker_details,
|
|
288
|
+
workflow_activation::{NotifyHasPatch, WorkflowActivationJob, workflow_activation_job},
|
|
296
289
|
},
|
|
297
290
|
temporal::api::{
|
|
298
291
|
command::v1::{
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
UpsertWorkflowSearchAttributesCommandAttributes,
|
|
292
|
+
RecordMarkerCommandAttributes, ScheduleActivityTaskCommandAttributes,
|
|
293
|
+
UpsertWorkflowSearchAttributesCommandAttributes, command::Attributes,
|
|
302
294
|
},
|
|
303
295
|
common::v1::ActivityType,
|
|
304
296
|
enums::v1::{CommandType, EventType},
|
|
@@ -307,7 +299,6 @@ mod tests {
|
|
|
307
299
|
ActivityTaskStartedEventAttributes, TimerFiredEventAttributes,
|
|
308
300
|
},
|
|
309
301
|
},
|
|
310
|
-
DEFAULT_WORKFLOW_TYPE,
|
|
311
302
|
};
|
|
312
303
|
use temporal_sdk_core_test_utils::interceptors::ActivationAssertionsInterceptor;
|
|
313
304
|
|