temporalio 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -23
- data/bridge/Cargo.lock +168 -59
- data/bridge/Cargo.toml +4 -2
- data/bridge/sdk-core/README.md +19 -6
- data/bridge/sdk-core/client/src/lib.rs +215 -39
- data/bridge/sdk-core/client/src/metrics.rs +17 -8
- data/bridge/sdk-core/client/src/raw.rs +4 -4
- data/bridge/sdk-core/client/src/retry.rs +32 -20
- data/bridge/sdk-core/core/Cargo.toml +22 -9
- data/bridge/sdk-core/core/src/abstractions.rs +203 -14
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +76 -41
- data/bridge/sdk-core/core/src/core_tests/determinism.rs +165 -2
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +204 -83
- data/bridge/sdk-core/core/src/core_tests/queries.rs +3 -4
- data/bridge/sdk-core/core/src/core_tests/workers.rs +1 -3
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +397 -54
- data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +106 -12
- data/bridge/sdk-core/core/src/internal_flags.rs +136 -0
- data/bridge/sdk-core/core/src/lib.rs +16 -9
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +1 -1
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +69 -35
- data/bridge/sdk-core/core/src/telemetry/mod.rs +29 -13
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +17 -12
- data/bridge/sdk-core/core/src/test_help/mod.rs +62 -12
- data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +112 -156
- data/bridge/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +89 -0
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +352 -122
- data/bridge/sdk-core/core/src/worker/activities.rs +233 -157
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +22 -2
- data/bridge/sdk-core/core/src/worker/client.rs +18 -2
- data/bridge/sdk-core/core/src/worker/mod.rs +165 -58
- data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +1 -3
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +3 -5
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +856 -277
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +100 -43
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +7 -7
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +5 -4
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +87 -27
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +5 -4
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +5 -4
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +5 -4
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +137 -62
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +25 -17
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +7 -6
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +103 -152
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +7 -7
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +9 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +2 -2
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +14 -7
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +5 -16
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +201 -121
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +11 -14
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +30 -15
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +1026 -376
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +460 -384
- data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +40 -57
- data/bridge/sdk-core/core/src/worker/workflow/wft_extraction.rs +125 -0
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +1 -4
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +117 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +24 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +448 -718
- data/bridge/sdk-core/core-api/Cargo.toml +2 -1
- data/bridge/sdk-core/core-api/src/errors.rs +1 -34
- data/bridge/sdk-core/core-api/src/lib.rs +6 -2
- data/bridge/sdk-core/core-api/src/telemetry.rs +0 -6
- data/bridge/sdk-core/core-api/src/worker.rs +14 -1
- data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +18 -15
- data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +8 -3
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-16_history.bin +0 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +5 -17
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +11 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +1 -6
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +6 -6
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +5 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +22 -6
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +48 -19
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +2 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +3 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/{enums/v1/interaction_type.proto → protocol/v1/message.proto} +29 -11
- data/bridge/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +63 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +111 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +59 -28
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +2 -2
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +7 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +6 -0
- data/bridge/sdk-core/sdk/Cargo.toml +3 -2
- data/bridge/sdk-core/sdk/src/lib.rs +87 -20
- data/bridge/sdk-core/sdk/src/workflow_future.rs +9 -8
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +5 -2
- data/bridge/sdk-core/sdk-core-protos/build.rs +36 -1
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +100 -87
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +5 -1
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +175 -57
- data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +12 -2
- data/bridge/sdk-core/test-utils/Cargo.toml +3 -1
- data/bridge/sdk-core/test-utils/src/canned_histories.rs +106 -296
- data/bridge/sdk-core/test-utils/src/histfetch.rs +1 -1
- data/bridge/sdk-core/test-utils/src/lib.rs +82 -23
- data/bridge/sdk-core/test-utils/src/wf_input_saver.rs +50 -0
- data/bridge/sdk-core/test-utils/src/workflows.rs +29 -0
- data/bridge/sdk-core/tests/fuzzy_workflow.rs +130 -0
- data/bridge/sdk-core/tests/{load_tests.rs → heavy_tests.rs} +125 -51
- data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +25 -3
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +5 -3
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +218 -16
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +4 -47
- data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +5 -128
- data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +83 -25
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +93 -69
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +6 -13
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +6 -2
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -10
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +72 -191
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +7 -28
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +12 -7
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +18 -14
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +6 -20
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -21
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +6 -4
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +10 -11
- data/bridge/sdk-core/tests/main.rs +3 -13
- data/bridge/sdk-core/tests/runner.rs +75 -36
- data/bridge/sdk-core/tests/wf_input_replay.rs +32 -0
- data/bridge/src/connection.rs +41 -25
- data/bridge/src/lib.rs +269 -14
- data/bridge/src/runtime.rs +1 -1
- data/bridge/src/test_server.rs +153 -0
- data/bridge/src/worker.rs +89 -16
- data/lib/gen/temporal/api/command/v1/message_pb.rb +4 -18
- data/lib/gen/temporal/api/common/v1/message_pb.rb +4 -0
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +1 -3
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +3 -3
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +2 -0
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +6 -4
- data/lib/gen/temporal/api/history/v1/message_pb.rb +27 -19
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +1 -0
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +3 -0
- data/lib/gen/temporal/api/protocol/v1/message_pb.rb +30 -0
- data/lib/gen/temporal/api/sdk/v1/task_complete_metadata_pb.rb +23 -0
- data/lib/gen/temporal/api/testservice/v1/request_response_pb.rb +49 -0
- data/lib/gen/temporal/api/testservice/v1/service_pb.rb +21 -0
- data/lib/gen/temporal/api/update/v1/message_pb.rb +72 -0
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +26 -16
- data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +13 -9
- data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +10 -6
- data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +13 -9
- data/lib/gen/temporal/sdk/core/common/common_pb.rb +7 -3
- data/lib/gen/temporal/sdk/core/core_interface_pb.rb +9 -3
- data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +7 -3
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +27 -21
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +28 -24
- data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +12 -5
- data/lib/temporalio/activity/context.rb +13 -8
- data/lib/temporalio/activity/info.rb +1 -1
- data/lib/temporalio/bridge/connect_options.rb +15 -0
- data/lib/temporalio/bridge/retry_config.rb +24 -0
- data/lib/temporalio/bridge/tls_options.rb +19 -0
- data/lib/temporalio/client/implementation.rb +8 -8
- data/lib/temporalio/connection/retry_config.rb +44 -0
- data/lib/temporalio/connection/service.rb +20 -0
- data/lib/temporalio/connection/test_service.rb +92 -0
- data/lib/temporalio/connection/tls_options.rb +51 -0
- data/lib/temporalio/connection/workflow_service.rb +731 -0
- data/lib/temporalio/connection.rb +55 -720
- data/lib/temporalio/interceptor/activity_inbound.rb +22 -0
- data/lib/temporalio/interceptor/activity_outbound.rb +24 -0
- data/lib/temporalio/interceptor/chain.rb +5 -5
- data/lib/temporalio/interceptor/client.rb +8 -4
- data/lib/temporalio/interceptor.rb +22 -0
- data/lib/temporalio/retry_policy.rb +13 -3
- data/lib/temporalio/testing/time_skipping_handle.rb +32 -0
- data/lib/temporalio/testing/time_skipping_interceptor.rb +23 -0
- data/lib/temporalio/testing/workflow_environment.rb +112 -0
- data/lib/temporalio/testing.rb +175 -0
- data/lib/temporalio/version.rb +1 -1
- data/lib/temporalio/worker/activity_runner.rb +26 -4
- data/lib/temporalio/worker/activity_worker.rb +44 -18
- data/lib/temporalio/worker/sync_worker.rb +47 -11
- data/lib/temporalio/worker.rb +27 -21
- data/lib/temporalio/workflow/async.rb +46 -0
- data/lib/temporalio/workflow/future.rb +138 -0
- data/lib/temporalio/workflow/info.rb +76 -0
- data/temporalio.gemspec +4 -3
- metadata +67 -17
- data/bridge/sdk-core/Cargo.lock +0 -2606
- data/bridge/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +0 -87
- data/lib/bridge.so +0 -0
- data/lib/gen/temporal/api/enums/v1/interaction_type_pb.rb +0 -25
- data/lib/gen/temporal/api/interaction/v1/message_pb.rb +0 -49
- data/lib/gen/temporal/sdk/core/bridge/bridge_pb.rb +0 -222
@@ -4,6 +4,10 @@ use super::{
|
|
4
4
|
workflow_machines::MachineResponse, Cancellable, EventInfo, NewMachineWithCommand,
|
5
5
|
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
6
6
|
};
|
7
|
+
use crate::{
|
8
|
+
internal_flags::CoreInternalFlags,
|
9
|
+
worker::workflow::{machines::HistEventData, InternalFlagsRef},
|
10
|
+
};
|
7
11
|
use rustfsm::{fsm, MachineError, StateMachine, TransitionResult};
|
8
12
|
use std::convert::{TryFrom, TryInto};
|
9
13
|
use temporal_sdk_core_protos::{
|
@@ -37,7 +41,7 @@ fsm! {
|
|
37
41
|
Created --(Schedule, on_schedule)--> ScheduleCommandCreated;
|
38
42
|
|
39
43
|
ScheduleCommandCreated --(CommandScheduleActivityTask) --> ScheduleCommandCreated;
|
40
|
-
ScheduleCommandCreated --(ActivityTaskScheduled(
|
44
|
+
ScheduleCommandCreated --(ActivityTaskScheduled(ActTaskScheduledData),
|
41
45
|
shared on_activity_task_scheduled) --> ScheduledEventRecorded;
|
42
46
|
ScheduleCommandCreated --(Cancel, shared on_canceled) --> Canceled;
|
43
47
|
|
@@ -94,34 +98,41 @@ pub(super) enum ActivityMachineCommand {
|
|
94
98
|
RequestCancellation(Command),
|
95
99
|
}
|
96
100
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
machine: activity.into(),
|
103
|
-
}
|
101
|
+
pub(super) struct ActTaskScheduledData {
|
102
|
+
event_id: i64,
|
103
|
+
act_type: String,
|
104
|
+
act_id: String,
|
105
|
+
last_task_in_history: bool,
|
104
106
|
}
|
105
107
|
|
106
108
|
impl ActivityMachine {
|
107
109
|
/// Create a new activity and immediately schedule it.
|
108
|
-
|
110
|
+
pub(super) fn new_scheduled(
|
111
|
+
attrs: ScheduleActivity,
|
112
|
+
internal_flags: InternalFlagsRef,
|
113
|
+
) -> NewMachineWithCommand {
|
109
114
|
let mut s = Self {
|
110
115
|
state: Created {}.into(),
|
111
116
|
shared_state: SharedState {
|
112
|
-
cancellation_type: ActivityCancellationType::from_i32(
|
117
|
+
cancellation_type: ActivityCancellationType::from_i32(attrs.cancellation_type)
|
113
118
|
.unwrap(),
|
114
|
-
attrs
|
115
|
-
|
119
|
+
attrs,
|
120
|
+
internal_flags,
|
121
|
+
scheduled_event_id: 0,
|
122
|
+
started_event_id: 0,
|
123
|
+
cancelled_before_sent: false,
|
116
124
|
},
|
117
125
|
};
|
118
126
|
OnEventWrapper::on_event_mut(&mut s, ActivityMachineEvents::Schedule)
|
119
127
|
.expect("Scheduling activities doesn't fail");
|
120
|
-
let
|
128
|
+
let command = Command {
|
121
129
|
command_type: CommandType::ScheduleActivityTask as i32,
|
122
130
|
attributes: Some(s.shared_state().attrs.clone().into()),
|
123
131
|
};
|
124
|
-
|
132
|
+
NewMachineWithCommand {
|
133
|
+
command,
|
134
|
+
machine: s.into(),
|
135
|
+
}
|
125
136
|
}
|
126
137
|
|
127
138
|
fn machine_responses_from_cancel_request(&self, cancel_cmd: Command) -> Vec<MachineResponse> {
|
@@ -169,12 +180,30 @@ impl ActivityMachine {
|
|
169
180
|
}
|
170
181
|
}
|
171
182
|
|
172
|
-
impl TryFrom<
|
183
|
+
impl TryFrom<HistEventData> for ActivityMachineEvents {
|
173
184
|
type Error = WFMachinesError;
|
174
185
|
|
175
|
-
fn try_from(e:
|
186
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
187
|
+
let last_task_in_history = e.current_task_is_last_in_history;
|
188
|
+
let e = e.event;
|
176
189
|
Ok(match e.event_type() {
|
177
|
-
EventType::ActivityTaskScheduled =>
|
190
|
+
EventType::ActivityTaskScheduled => {
|
191
|
+
if let Some(history_event::Attributes::ActivityTaskScheduledEventAttributes(
|
192
|
+
attrs,
|
193
|
+
)) = e.attributes
|
194
|
+
{
|
195
|
+
Self::ActivityTaskScheduled(ActTaskScheduledData {
|
196
|
+
event_id: e.event_id,
|
197
|
+
act_id: attrs.activity_id,
|
198
|
+
act_type: attrs.activity_type.unwrap_or_default().name,
|
199
|
+
last_task_in_history,
|
200
|
+
})
|
201
|
+
} else {
|
202
|
+
return Err(WFMachinesError::Fatal(format!(
|
203
|
+
"Activity scheduled attributes were unset: {e}"
|
204
|
+
)));
|
205
|
+
}
|
206
|
+
}
|
178
207
|
EventType::ActivityTaskStarted => Self::ActivityTaskStarted(e.event_id),
|
179
208
|
EventType::ActivityTaskCompleted => {
|
180
209
|
if let Some(history_event::Attributes::ActivityTaskCompletedEventAttributes(
|
@@ -184,8 +213,7 @@ impl TryFrom<HistoryEvent> for ActivityMachineEvents {
|
|
184
213
|
Self::ActivityTaskCompleted(attrs)
|
185
214
|
} else {
|
186
215
|
return Err(WFMachinesError::Fatal(format!(
|
187
|
-
"Activity completion attributes were unset: {}"
|
188
|
-
e
|
216
|
+
"Activity completion attributes were unset: {e}"
|
189
217
|
)));
|
190
218
|
}
|
191
219
|
}
|
@@ -196,8 +224,7 @@ impl TryFrom<HistoryEvent> for ActivityMachineEvents {
|
|
196
224
|
Self::ActivityTaskFailed(attrs)
|
197
225
|
} else {
|
198
226
|
return Err(WFMachinesError::Fatal(format!(
|
199
|
-
"Activity failure attributes were unset: {}"
|
200
|
-
e
|
227
|
+
"Activity failure attributes were unset: {e}"
|
201
228
|
)));
|
202
229
|
}
|
203
230
|
}
|
@@ -208,8 +235,7 @@ impl TryFrom<HistoryEvent> for ActivityMachineEvents {
|
|
208
235
|
Self::ActivityTaskTimedOut(attrs)
|
209
236
|
} else {
|
210
237
|
return Err(WFMachinesError::Fatal(format!(
|
211
|
-
"Activity timeout attributes were unset: {}"
|
212
|
-
e
|
238
|
+
"Activity timeout attributes were unset: {e}"
|
213
239
|
)));
|
214
240
|
}
|
215
241
|
}
|
@@ -221,15 +247,13 @@ impl TryFrom<HistoryEvent> for ActivityMachineEvents {
|
|
221
247
|
Self::ActivityTaskCanceled(attrs)
|
222
248
|
} else {
|
223
249
|
return Err(WFMachinesError::Fatal(format!(
|
224
|
-
"Activity cancellation attributes were unset: {}"
|
225
|
-
e
|
250
|
+
"Activity cancellation attributes were unset: {e}"
|
226
251
|
)));
|
227
252
|
}
|
228
253
|
}
|
229
254
|
_ => {
|
230
255
|
return Err(WFMachinesError::Nondeterminism(format!(
|
231
|
-
"Activity machine does not handle this event: {}"
|
232
|
-
e
|
256
|
+
"Activity machine does not handle this event: {e}"
|
233
257
|
)))
|
234
258
|
}
|
235
259
|
})
|
@@ -339,7 +363,7 @@ impl Cancellable for ActivityMachine {
|
|
339
363
|
)
|
340
364
|
.into()]
|
341
365
|
}
|
342
|
-
x => panic!("Invalid cancel event response {:?}"
|
366
|
+
x => panic!("Invalid cancel event response {x:?}"),
|
343
367
|
})
|
344
368
|
.collect();
|
345
369
|
Ok(res)
|
@@ -350,13 +374,14 @@ impl Cancellable for ActivityMachine {
|
|
350
374
|
}
|
351
375
|
}
|
352
376
|
|
353
|
-
#[derive(
|
377
|
+
#[derive(Clone)]
|
354
378
|
pub(super) struct SharedState {
|
355
379
|
scheduled_event_id: i64,
|
356
380
|
started_event_id: i64,
|
357
381
|
attrs: ScheduleActivity,
|
358
382
|
cancellation_type: ActivityCancellationType,
|
359
383
|
cancelled_before_sent: bool,
|
384
|
+
internal_flags: InternalFlagsRef,
|
360
385
|
}
|
361
386
|
|
362
387
|
#[derive(Default, Clone)]
|
@@ -376,17 +401,37 @@ impl ScheduleCommandCreated {
|
|
376
401
|
pub(super) fn on_activity_task_scheduled(
|
377
402
|
self,
|
378
403
|
dat: SharedState,
|
379
|
-
|
404
|
+
sched_dat: ActTaskScheduledData,
|
380
405
|
) -> ActivityMachineTransition<ScheduledEventRecorded> {
|
406
|
+
if dat.internal_flags.borrow_mut().try_use(
|
407
|
+
CoreInternalFlags::IdAndTypeDeterminismChecks,
|
408
|
+
sched_dat.last_task_in_history,
|
409
|
+
) {
|
410
|
+
if sched_dat.act_id != dat.attrs.activity_id {
|
411
|
+
return TransitionResult::Err(WFMachinesError::Nondeterminism(format!(
|
412
|
+
"Activity id of scheduled event '{}' does not \
|
413
|
+
match activity id of activity command '{}'",
|
414
|
+
sched_dat.act_id, dat.attrs.activity_id
|
415
|
+
)));
|
416
|
+
}
|
417
|
+
if sched_dat.act_type != dat.attrs.activity_type {
|
418
|
+
return TransitionResult::Err(WFMachinesError::Nondeterminism(format!(
|
419
|
+
"Activity type of scheduled event '{}' does not \
|
420
|
+
match activity type of activity command '{}'",
|
421
|
+
sched_dat.act_type, dat.attrs.activity_type
|
422
|
+
)));
|
423
|
+
}
|
424
|
+
}
|
381
425
|
ActivityMachineTransition::ok_shared(
|
382
426
|
vec![],
|
383
427
|
ScheduledEventRecorded::default(),
|
384
428
|
SharedState {
|
385
|
-
scheduled_event_id,
|
429
|
+
scheduled_event_id: sched_dat.event_id,
|
386
430
|
..dat
|
387
431
|
},
|
388
432
|
)
|
389
433
|
}
|
434
|
+
|
390
435
|
pub(super) fn on_canceled(self, dat: SharedState) -> ActivityMachineTransition<Canceled> {
|
391
436
|
let canceled_state = SharedState {
|
392
437
|
cancelled_before_sent: true,
|
@@ -648,8 +693,7 @@ impl Canceled {
|
|
648
693
|
} else {
|
649
694
|
TransitionResult::Err(WFMachinesError::Nondeterminism(format!(
|
650
695
|
"Non-Abandon cancel mode activities cannot be started after being cancelled. \
|
651
|
-
Seq: {:?}"
|
652
|
-
seq_num
|
696
|
+
Seq: {seq_num:?}"
|
653
697
|
)))
|
654
698
|
}
|
655
699
|
}
|
@@ -663,8 +707,7 @@ impl Canceled {
|
|
663
707
|
TransitionResult::default()
|
664
708
|
} else {
|
665
709
|
TransitionResult::Err(WFMachinesError::Nondeterminism(format!(
|
666
|
-
"Non-Abandon cancel mode activities cannot be completed after being cancelled: {:?}"
|
667
|
-
attrs
|
710
|
+
"Non-Abandon cancel mode activities cannot be completed after being cancelled: {attrs:?}"
|
668
711
|
)))
|
669
712
|
}
|
670
713
|
}
|
@@ -769,8 +812,7 @@ fn convert_payloads(
|
|
769
812
|
) -> Result<Option<Payload>, WFMachinesError> {
|
770
813
|
result.map(TryInto::try_into).transpose().map_err(|pe| {
|
771
814
|
WFMachinesError::Fatal(format!(
|
772
|
-
"Not exactly one payload in activity result ({}) for event: {:?}"
|
773
|
-
pe, event_info
|
815
|
+
"Not exactly one payload in activity result ({pe}) for event: {event_info:?}"
|
774
816
|
))
|
775
817
|
})
|
776
818
|
}
|
@@ -779,15 +821,17 @@ fn convert_payloads(
|
|
779
821
|
mod test {
|
780
822
|
use super::*;
|
781
823
|
use crate::{
|
782
|
-
replay::TestHistoryBuilder, test_help::canned_histories,
|
824
|
+
internal_flags::InternalFlags, replay::TestHistoryBuilder, test_help::canned_histories,
|
825
|
+
worker::workflow::ManagedWFFunc,
|
783
826
|
};
|
784
827
|
use rstest::{fixture, rstest};
|
785
|
-
use std::mem::discriminant;
|
828
|
+
use std::{cell::RefCell, mem::discriminant, rc::Rc};
|
786
829
|
use temporal_sdk::{
|
787
830
|
ActivityOptions, CancellableFuture, WfContext, WorkflowFunction, WorkflowResult,
|
788
831
|
};
|
789
|
-
use temporal_sdk_core_protos::
|
790
|
-
workflow_activation_job, WorkflowActivationJob,
|
832
|
+
use temporal_sdk_core_protos::{
|
833
|
+
coresdk::workflow_activation::{workflow_activation_job, WorkflowActivationJob},
|
834
|
+
DEFAULT_ACTIVITY_TYPE,
|
791
835
|
};
|
792
836
|
|
793
837
|
#[fixture]
|
@@ -807,7 +851,13 @@ mod test {
|
|
807
851
|
}
|
808
852
|
|
809
853
|
async fn activity_wf(command_sink: WfContext) -> WorkflowResult<()> {
|
810
|
-
command_sink
|
854
|
+
command_sink
|
855
|
+
.activity(ActivityOptions {
|
856
|
+
activity_id: Some("activity-id-1".to_string()),
|
857
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
858
|
+
..Default::default()
|
859
|
+
})
|
860
|
+
.await;
|
811
861
|
Ok(().into())
|
812
862
|
}
|
813
863
|
|
@@ -897,7 +947,14 @@ mod test {
|
|
897
947
|
] {
|
898
948
|
let mut s = ActivityMachine {
|
899
949
|
state: state.clone(),
|
900
|
-
shared_state:
|
950
|
+
shared_state: SharedState {
|
951
|
+
scheduled_event_id: 0,
|
952
|
+
started_event_id: 0,
|
953
|
+
attrs: Default::default(),
|
954
|
+
cancellation_type: Default::default(),
|
955
|
+
cancelled_before_sent: false,
|
956
|
+
internal_flags: Rc::new(RefCell::new(InternalFlags::new(&Default::default()))),
|
957
|
+
},
|
901
958
|
};
|
902
959
|
let cmds = s.cancel().unwrap();
|
903
960
|
assert_eq!(cmds.len(), 0);
|
@@ -2,6 +2,7 @@ use super::{
|
|
2
2
|
workflow_machines::MachineResponse, Cancellable, EventInfo, NewMachineWithCommand,
|
3
3
|
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
4
4
|
};
|
5
|
+
use crate::worker::workflow::machines::HistEventData;
|
5
6
|
use rustfsm::{fsm, TransitionResult};
|
6
7
|
use std::convert::TryFrom;
|
7
8
|
use temporal_sdk_core_protos::{
|
@@ -145,10 +146,11 @@ impl TryFrom<CommandType> for CancelExternalMachineEvents {
|
|
145
146
|
}
|
146
147
|
}
|
147
148
|
|
148
|
-
impl TryFrom<
|
149
|
+
impl TryFrom<HistEventData> for CancelExternalMachineEvents {
|
149
150
|
type Error = WFMachinesError;
|
150
151
|
|
151
|
-
fn try_from(e:
|
152
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
153
|
+
let e = e.event;
|
152
154
|
Ok(match e.event_type() {
|
153
155
|
EventType::ExternalWorkflowExecutionCancelRequested => {
|
154
156
|
Self::ExternalWorkflowExecutionCancelRequested
|
@@ -161,15 +163,13 @@ impl TryFrom<HistoryEvent> for CancelExternalMachineEvents {
|
|
161
163
|
Self::RequestCancelExternalWorkflowExecutionFailed(attrs.cause())
|
162
164
|
} else {
|
163
165
|
return Err(WFMachinesError::Fatal(format!(
|
164
|
-
"Cancelworkflow failed attributes were unset: {}"
|
165
|
-
e
|
166
|
+
"Cancelworkflow failed attributes were unset: {e}"
|
166
167
|
)));
|
167
168
|
}
|
168
169
|
}
|
169
170
|
_ => {
|
170
171
|
return Err(WFMachinesError::Nondeterminism(format!(
|
171
|
-
"Cancel external WF machine does not handle this event: {}"
|
172
|
-
e
|
172
|
+
"Cancel external WF machine does not handle this event: {e}"
|
173
173
|
)))
|
174
174
|
}
|
175
175
|
})
|
@@ -199,7 +199,7 @@ impl WFMachinesAdapter for CancelExternalMachine {
|
|
199
199
|
vec![ResolveRequestCancelExternalWorkflow {
|
200
200
|
seq: self.shared_state.seq,
|
201
201
|
failure: Some(Failure {
|
202
|
-
message: format!("Unable to cancel external workflow because {}"
|
202
|
+
message: format!("Unable to cancel external workflow because {reason}"),
|
203
203
|
failure_info: Some(FailureInfo::ApplicationFailureInfo(
|
204
204
|
ApplicationFailureInfo {
|
205
205
|
r#type: f.to_string(),
|
@@ -2,6 +2,7 @@ use super::{
|
|
2
2
|
workflow_machines::MachineResponse, Cancellable, EventInfo, HistoryEvent,
|
3
3
|
NewMachineWithCommand, OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
4
4
|
};
|
5
|
+
use crate::worker::workflow::machines::HistEventData;
|
5
6
|
use rustfsm::{fsm, TransitionResult};
|
6
7
|
use std::convert::TryFrom;
|
7
8
|
use temporal_sdk_core_protos::{
|
@@ -72,16 +73,16 @@ impl Created {
|
|
72
73
|
}
|
73
74
|
}
|
74
75
|
|
75
|
-
impl TryFrom<
|
76
|
+
impl TryFrom<HistEventData> for CancelWorkflowMachineEvents {
|
76
77
|
type Error = WFMachinesError;
|
77
78
|
|
78
|
-
fn try_from(e:
|
79
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
80
|
+
let e = e.event;
|
79
81
|
Ok(match EventType::from_i32(e.event_type) {
|
80
82
|
Some(EventType::WorkflowExecutionCanceled) => Self::WorkflowExecutionCanceled,
|
81
83
|
_ => {
|
82
84
|
return Err(WFMachinesError::Nondeterminism(format!(
|
83
|
-
"Cancel workflow machine does not handle this event: {}"
|
84
|
-
e
|
85
|
+
"Cancel workflow machine does not handle this event: {e}"
|
85
86
|
)))
|
86
87
|
}
|
87
88
|
})
|
@@ -2,6 +2,10 @@ use super::{
|
|
2
2
|
workflow_machines::MachineResponse, Cancellable, EventInfo, NewMachineWithCommand,
|
3
3
|
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
4
4
|
};
|
5
|
+
use crate::{
|
6
|
+
internal_flags::CoreInternalFlags,
|
7
|
+
worker::workflow::{machines::HistEventData, InternalFlagsRef},
|
8
|
+
};
|
5
9
|
use rustfsm::{fsm, MachineError, TransitionResult};
|
6
10
|
use std::convert::{TryFrom, TryInto};
|
7
11
|
use temporal_sdk_core_protos::{
|
@@ -41,7 +45,7 @@ fsm! {
|
|
41
45
|
|
42
46
|
Created --(Schedule, on_schedule) --> StartCommandCreated;
|
43
47
|
StartCommandCreated --(CommandStartChildWorkflowExecution) --> StartCommandCreated;
|
44
|
-
StartCommandCreated --(StartChildWorkflowExecutionInitiated(
|
48
|
+
StartCommandCreated --(StartChildWorkflowExecutionInitiated(ChildWorkflowInitiatedData),
|
45
49
|
shared on_start_child_workflow_execution_initiated) --> StartEventRecorded;
|
46
50
|
StartCommandCreated --(Cancel, shared on_cancelled) --> Cancelled;
|
47
51
|
|
@@ -99,6 +103,13 @@ pub(super) enum ChildWorkflowCommand {
|
|
99
103
|
IssueCancelAfterStarted { reason: String },
|
100
104
|
}
|
101
105
|
|
106
|
+
pub(super) struct ChildWorkflowInitiatedData {
|
107
|
+
event_id: i64,
|
108
|
+
wf_type: String,
|
109
|
+
wf_id: String,
|
110
|
+
last_task_in_history: bool,
|
111
|
+
}
|
112
|
+
|
102
113
|
#[derive(Default, Clone)]
|
103
114
|
pub(super) struct Cancelled {}
|
104
115
|
|
@@ -124,13 +135,32 @@ impl StartCommandCreated {
|
|
124
135
|
pub(super) fn on_start_child_workflow_execution_initiated(
|
125
136
|
self,
|
126
137
|
state: SharedState,
|
127
|
-
|
138
|
+
event_dat: ChildWorkflowInitiatedData,
|
128
139
|
) -> ChildWorkflowMachineTransition<StartEventRecorded> {
|
140
|
+
if state.internal_flags.borrow_mut().try_use(
|
141
|
+
CoreInternalFlags::IdAndTypeDeterminismChecks,
|
142
|
+
event_dat.last_task_in_history,
|
143
|
+
) {
|
144
|
+
if event_dat.wf_id != state.workflow_id {
|
145
|
+
return TransitionResult::Err(WFMachinesError::Nondeterminism(format!(
|
146
|
+
"Child workflow id of scheduled event '{}' does not \
|
147
|
+
match child workflow id of activity command '{}'",
|
148
|
+
event_dat.wf_id, state.workflow_id
|
149
|
+
)));
|
150
|
+
}
|
151
|
+
if event_dat.wf_type != state.workflow_type {
|
152
|
+
return TransitionResult::Err(WFMachinesError::Nondeterminism(format!(
|
153
|
+
"Child workflow type of scheduled event '{}' does not \
|
154
|
+
match child workflow type of activity command '{}'",
|
155
|
+
event_dat.wf_type, state.workflow_type
|
156
|
+
)));
|
157
|
+
}
|
158
|
+
}
|
129
159
|
ChildWorkflowMachineTransition::ok_shared(
|
130
160
|
vec![],
|
131
161
|
StartEventRecorded::default(),
|
132
162
|
SharedState {
|
133
|
-
initiated_event_id,
|
163
|
+
initiated_event_id: event_dat.event_id,
|
134
164
|
..state
|
135
165
|
},
|
136
166
|
)
|
@@ -299,7 +329,7 @@ pub(super) struct Terminated {}
|
|
299
329
|
#[derive(Default, Clone)]
|
300
330
|
pub(super) struct TimedOut {}
|
301
331
|
|
302
|
-
#[derive(
|
332
|
+
#[derive(Clone, Debug)]
|
303
333
|
pub(super) struct SharedState {
|
304
334
|
initiated_event_id: i64,
|
305
335
|
started_event_id: i64,
|
@@ -310,20 +340,15 @@ pub(super) struct SharedState {
|
|
310
340
|
workflow_type: String,
|
311
341
|
cancelled_before_sent: bool,
|
312
342
|
cancel_type: ChildWorkflowCancellationType,
|
313
|
-
|
314
|
-
|
315
|
-
/// Creates a new child workflow state machine and a command to start it on the server.
|
316
|
-
pub(super) fn new_child_workflow(attribs: StartChildWorkflowExecution) -> NewMachineWithCommand {
|
317
|
-
let (wf, add_cmd) = ChildWorkflowMachine::new_scheduled(attribs);
|
318
|
-
NewMachineWithCommand {
|
319
|
-
command: add_cmd,
|
320
|
-
machine: wf.into(),
|
321
|
-
}
|
343
|
+
internal_flags: InternalFlagsRef,
|
322
344
|
}
|
323
345
|
|
324
346
|
impl ChildWorkflowMachine {
|
325
347
|
/// Create a new child workflow and immediately schedule it.
|
326
|
-
pub(
|
348
|
+
pub(super) fn new_scheduled(
|
349
|
+
attribs: StartChildWorkflowExecution,
|
350
|
+
internal_flags: InternalFlagsRef,
|
351
|
+
) -> NewMachineWithCommand {
|
327
352
|
let mut s = Self {
|
328
353
|
state: Created {}.into(),
|
329
354
|
shared_state: SharedState {
|
@@ -332,7 +357,11 @@ impl ChildWorkflowMachine {
|
|
332
357
|
workflow_type: attribs.workflow_type.clone(),
|
333
358
|
namespace: attribs.namespace.clone(),
|
334
359
|
cancel_type: attribs.cancellation_type(),
|
335
|
-
|
360
|
+
internal_flags,
|
361
|
+
run_id: "".to_string(),
|
362
|
+
initiated_event_id: 0,
|
363
|
+
started_event_id: 0,
|
364
|
+
cancelled_before_sent: false,
|
336
365
|
},
|
337
366
|
};
|
338
367
|
OnEventWrapper::on_event_mut(&mut s, ChildWorkflowMachineEvents::Schedule)
|
@@ -341,7 +370,10 @@ impl ChildWorkflowMachine {
|
|
341
370
|
command_type: CommandType::StartChildWorkflowExecution as i32,
|
342
371
|
attributes: Some(attribs.into()),
|
343
372
|
};
|
344
|
-
|
373
|
+
NewMachineWithCommand {
|
374
|
+
command: cmd,
|
375
|
+
machine: s.into(),
|
376
|
+
}
|
345
377
|
}
|
346
378
|
|
347
379
|
fn resolve_cancelled_msg(&self) -> ResolveChildWorkflowExecution {
|
@@ -372,13 +404,31 @@ impl ChildWorkflowMachine {
|
|
372
404
|
}
|
373
405
|
}
|
374
406
|
|
375
|
-
impl TryFrom<
|
407
|
+
impl TryFrom<HistEventData> for ChildWorkflowMachineEvents {
|
376
408
|
type Error = WFMachinesError;
|
377
409
|
|
378
|
-
fn try_from(e:
|
410
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
411
|
+
let last_task_in_history = e.current_task_is_last_in_history;
|
412
|
+
let e = e.event;
|
379
413
|
Ok(match EventType::from_i32(e.event_type) {
|
380
414
|
Some(EventType::StartChildWorkflowExecutionInitiated) => {
|
381
|
-
|
415
|
+
if let Some(
|
416
|
+
history_event::Attributes::StartChildWorkflowExecutionInitiatedEventAttributes(
|
417
|
+
attrs,
|
418
|
+
),
|
419
|
+
) = e.attributes
|
420
|
+
{
|
421
|
+
Self::StartChildWorkflowExecutionInitiated(ChildWorkflowInitiatedData {
|
422
|
+
event_id: e.event_id,
|
423
|
+
wf_type: attrs.workflow_type.unwrap_or_default().name,
|
424
|
+
wf_id: attrs.workflow_id,
|
425
|
+
last_task_in_history,
|
426
|
+
})
|
427
|
+
} else {
|
428
|
+
return Err(WFMachinesError::Fatal(
|
429
|
+
"StartChildWorkflowExecutionInitiated attributes were unset".to_string(),
|
430
|
+
));
|
431
|
+
}
|
382
432
|
}
|
383
433
|
Some(EventType::StartChildWorkflowExecutionFailed) => {
|
384
434
|
if let Some(
|
@@ -471,8 +521,7 @@ impl TryFrom<HistoryEvent> for ChildWorkflowMachineEvents {
|
|
471
521
|
}
|
472
522
|
_ => {
|
473
523
|
return Err(WFMachinesError::Fatal(format!(
|
474
|
-
"Child workflow machine does not handle this event: {:?}"
|
475
|
-
e
|
524
|
+
"Child workflow machine does not handle this event: {e:?}"
|
476
525
|
)))
|
477
526
|
}
|
478
527
|
})
|
@@ -612,7 +661,7 @@ impl Cancellable for ChildWorkflowMachine {
|
|
612
661
|
| c @ ChildWorkflowCommand::IssueCancelAfterStarted { .. } => {
|
613
662
|
self.adapt_response(c, None)
|
614
663
|
}
|
615
|
-
x => panic!("Invalid cancel event response {:?}"
|
664
|
+
x => panic!("Invalid cancel event response {x:?}"),
|
616
665
|
})
|
617
666
|
.collect::<Result<Vec<_>, _>>()?
|
618
667
|
.into_iter()
|
@@ -650,8 +699,7 @@ fn convert_payloads(
|
|
650
699
|
) -> Result<Option<Payload>, WFMachinesError> {
|
651
700
|
result.map(TryInto::try_into).transpose().map_err(|pe| {
|
652
701
|
WFMachinesError::Fatal(format!(
|
653
|
-
"Not exactly one payload in child workflow result ({}) for event: {:?}"
|
654
|
-
pe, event_info
|
702
|
+
"Not exactly one payload in child workflow result ({pe}) for event: {event_info:?}"
|
655
703
|
))
|
656
704
|
})
|
657
705
|
}
|
@@ -660,11 +708,12 @@ fn convert_payloads(
|
|
660
708
|
mod test {
|
661
709
|
use super::*;
|
662
710
|
use crate::{
|
663
|
-
replay::TestHistoryBuilder, test_help::canned_histories,
|
711
|
+
internal_flags::InternalFlags, replay::TestHistoryBuilder, test_help::canned_histories,
|
712
|
+
worker::workflow::ManagedWFFunc,
|
664
713
|
};
|
665
714
|
use anyhow::anyhow;
|
666
715
|
use rstest::{fixture, rstest};
|
667
|
-
use std::mem::discriminant;
|
716
|
+
use std::{cell::RefCell, mem::discriminant, rc::Rc};
|
668
717
|
use temporal_sdk::{
|
669
718
|
CancellableFuture, ChildWorkflowOptions, WfContext, WorkflowFunction, WorkflowResult,
|
670
719
|
};
|
@@ -848,7 +897,18 @@ mod test {
|
|
848
897
|
] {
|
849
898
|
let mut s = ChildWorkflowMachine {
|
850
899
|
state: state.clone(),
|
851
|
-
shared_state:
|
900
|
+
shared_state: SharedState {
|
901
|
+
initiated_event_id: 0,
|
902
|
+
started_event_id: 0,
|
903
|
+
lang_sequence_number: 0,
|
904
|
+
namespace: "".to_string(),
|
905
|
+
workflow_id: "".to_string(),
|
906
|
+
run_id: "".to_string(),
|
907
|
+
workflow_type: "".to_string(),
|
908
|
+
cancelled_before_sent: false,
|
909
|
+
cancel_type: Default::default(),
|
910
|
+
internal_flags: Rc::new(RefCell::new(InternalFlags::new(&Default::default()))),
|
911
|
+
},
|
852
912
|
};
|
853
913
|
let cmds = s.cancel().unwrap();
|
854
914
|
assert_eq!(cmds.len(), 0);
|
@@ -2,6 +2,7 @@ use super::{
|
|
2
2
|
workflow_machines::MachineResponse, Cancellable, EventInfo, NewMachineWithCommand,
|
3
3
|
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
4
4
|
};
|
5
|
+
use crate::worker::workflow::machines::HistEventData;
|
5
6
|
use rustfsm::{fsm, TransitionResult};
|
6
7
|
use std::convert::TryFrom;
|
7
8
|
use temporal_sdk_core_protos::{
|
@@ -61,16 +62,16 @@ impl CompleteWorkflowMachine {
|
|
61
62
|
}
|
62
63
|
}
|
63
64
|
|
64
|
-
impl TryFrom<
|
65
|
+
impl TryFrom<HistEventData> for CompleteWorkflowMachineEvents {
|
65
66
|
type Error = WFMachinesError;
|
66
67
|
|
67
|
-
fn try_from(e:
|
68
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
69
|
+
let e = e.event;
|
68
70
|
Ok(match e.event_type() {
|
69
71
|
EventType::WorkflowExecutionCompleted => Self::WorkflowExecutionCompleted,
|
70
72
|
_ => {
|
71
73
|
return Err(WFMachinesError::Nondeterminism(format!(
|
72
|
-
"Complete workflow machine does not handle this event: {}"
|
73
|
-
e
|
74
|
+
"Complete workflow machine does not handle this event: {e}"
|
74
75
|
)))
|
75
76
|
}
|
76
77
|
})
|
data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs
CHANGED
@@ -2,6 +2,7 @@ use super::{
|
|
2
2
|
Cancellable, EventInfo, HistoryEvent, MachineResponse, NewMachineWithCommand, OnEventWrapper,
|
3
3
|
WFMachinesAdapter, WFMachinesError,
|
4
4
|
};
|
5
|
+
use crate::worker::workflow::machines::HistEventData;
|
5
6
|
use rustfsm::{fsm, TransitionResult};
|
6
7
|
use std::convert::TryFrom;
|
7
8
|
use temporal_sdk_core_protos::{
|
@@ -69,16 +70,16 @@ impl From<ContinueAsNewWorkflowCommandCreated> for ContinueAsNewWorkflowCommandR
|
|
69
70
|
}
|
70
71
|
}
|
71
72
|
|
72
|
-
impl TryFrom<
|
73
|
+
impl TryFrom<HistEventData> for ContinueAsNewWorkflowMachineEvents {
|
73
74
|
type Error = WFMachinesError;
|
74
75
|
|
75
|
-
fn try_from(e:
|
76
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
77
|
+
let e = e.event;
|
76
78
|
Ok(match e.event_type() {
|
77
79
|
EventType::WorkflowExecutionContinuedAsNew => Self::WorkflowExecutionContinuedAsNew,
|
78
80
|
_ => {
|
79
81
|
return Err(WFMachinesError::Nondeterminism(format!(
|
80
|
-
"Continue as new workflow machine does not handle this event: {}"
|
81
|
-
e
|
82
|
+
"Continue as new workflow machine does not handle this event: {e}"
|
82
83
|
)))
|
83
84
|
}
|
84
85
|
})
|