temporalio 0.0.2 → 0.1.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.
- 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
|
@@ -21,7 +21,7 @@ use super::{
|
|
|
21
21
|
workflow_machines::MachineResponse, Cancellable, EventInfo, NewMachineWithCommand,
|
|
22
22
|
OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
|
23
23
|
};
|
|
24
|
-
use crate::protosext::HistoryEventExt;
|
|
24
|
+
use crate::{protosext::HistoryEventExt, worker::workflow::machines::HistEventData};
|
|
25
25
|
use rustfsm::{fsm, TransitionResult};
|
|
26
26
|
use std::convert::TryFrom;
|
|
27
27
|
use temporal_sdk_core_protos::{
|
|
@@ -201,15 +201,15 @@ impl TryFrom<CommandType> for PatchMachineEvents {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
impl TryFrom<
|
|
204
|
+
impl TryFrom<HistEventData> for PatchMachineEvents {
|
|
205
205
|
type Error = WFMachinesError;
|
|
206
206
|
|
|
207
|
-
fn try_from(e:
|
|
207
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
|
208
|
+
let e = e.event;
|
|
208
209
|
match e.get_patch_marker_details() {
|
|
209
210
|
Some((id, _)) => Ok(Self::MarkerRecorded(id)),
|
|
210
211
|
_ => Err(WFMachinesError::Nondeterminism(format!(
|
|
211
|
-
"Change machine cannot handle this event: {}"
|
|
212
|
-
e
|
|
212
|
+
"Change machine cannot handle this event: {e}"
|
|
213
213
|
))),
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -238,15 +238,14 @@ mod tests {
|
|
|
238
238
|
common::v1::ActivityType,
|
|
239
239
|
enums::v1::{CommandType, EventType},
|
|
240
240
|
history::v1::{
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
TimerFiredEventAttributes,
|
|
241
|
+
ActivityTaskCompletedEventAttributes, ActivityTaskScheduledEventAttributes,
|
|
242
|
+
ActivityTaskStartedEventAttributes, TimerFiredEventAttributes,
|
|
244
243
|
},
|
|
245
244
|
},
|
|
246
245
|
};
|
|
247
246
|
|
|
248
247
|
const MY_PATCH_ID: &str = "test_patch_id";
|
|
249
|
-
#[derive(Eq, PartialEq, Copy, Clone)]
|
|
248
|
+
#[derive(Eq, PartialEq, Copy, Clone, Debug)]
|
|
250
249
|
enum MarkerType {
|
|
251
250
|
Deprecated,
|
|
252
251
|
NotDeprecated,
|
|
@@ -267,7 +266,11 @@ mod tests {
|
|
|
267
266
|
/// EVENT_TYPE_WORKFLOW_TASK_STARTED
|
|
268
267
|
/// EVENT_TYPE_WORKFLOW_TASK_COMPLETED
|
|
269
268
|
/// EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED
|
|
270
|
-
fn patch_marker_single_activity(
|
|
269
|
+
fn patch_marker_single_activity(
|
|
270
|
+
marker_type: MarkerType,
|
|
271
|
+
version: usize,
|
|
272
|
+
replay: bool,
|
|
273
|
+
) -> TestHistoryBuilder {
|
|
271
274
|
let mut t = TestHistoryBuilder::default();
|
|
272
275
|
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
273
276
|
t.add_full_wf_task();
|
|
@@ -277,41 +280,41 @@ mod tests {
|
|
|
277
280
|
MarkerType::NoMarker => {}
|
|
278
281
|
};
|
|
279
282
|
|
|
280
|
-
let
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
),
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
)
|
|
314
|
-
);
|
|
283
|
+
let activity_id = if replay {
|
|
284
|
+
match (marker_type, version) {
|
|
285
|
+
(_, 1) => "no_change",
|
|
286
|
+
(MarkerType::NotDeprecated, 2) => "had_change",
|
|
287
|
+
(MarkerType::Deprecated, 2) => "had_change",
|
|
288
|
+
(MarkerType::NoMarker, 2) => "no_change",
|
|
289
|
+
(_, 3) => "had_change",
|
|
290
|
+
(_, 4) => "had_change",
|
|
291
|
+
v => panic!("Nonsense marker / version combo {v:?}"),
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
// If the workflow isn't replaying (we're creating history here for a workflow which
|
|
295
|
+
// wasn't replaying at the time of scheduling the activity, and has done that, and now
|
|
296
|
+
// we're feeding back the history it would have produced) then it always has the change,
|
|
297
|
+
// except in v1.
|
|
298
|
+
if version > 1 {
|
|
299
|
+
"had_change"
|
|
300
|
+
} else {
|
|
301
|
+
"no_change"
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
let scheduled_event_id = t.add(ActivityTaskScheduledEventAttributes {
|
|
306
|
+
activity_id: activity_id.to_string(),
|
|
307
|
+
..Default::default()
|
|
308
|
+
});
|
|
309
|
+
let started_event_id = t.add(ActivityTaskStartedEventAttributes {
|
|
310
|
+
scheduled_event_id,
|
|
311
|
+
..Default::default()
|
|
312
|
+
});
|
|
313
|
+
t.add(ActivityTaskCompletedEventAttributes {
|
|
314
|
+
scheduled_event_id,
|
|
315
|
+
started_event_id,
|
|
316
|
+
..Default::default()
|
|
317
|
+
});
|
|
315
318
|
t.add_full_wf_task();
|
|
316
319
|
t.add_workflow_execution_completed();
|
|
317
320
|
t
|
|
@@ -384,7 +387,7 @@ mod tests {
|
|
|
384
387
|
Ok(().into())
|
|
385
388
|
});
|
|
386
389
|
|
|
387
|
-
let t = patch_marker_single_activity(marker_type);
|
|
390
|
+
let t = patch_marker_single_activity(marker_type, workflow_version, replaying);
|
|
388
391
|
let histinfo = if replaying {
|
|
389
392
|
t.get_full_history_info()
|
|
390
393
|
} else {
|
|
@@ -422,7 +425,7 @@ mod tests {
|
|
|
422
425
|
} else {
|
|
423
426
|
// Feed more history
|
|
424
427
|
wfm.new_history(
|
|
425
|
-
patch_marker_single_activity(marker_type)
|
|
428
|
+
patch_marker_single_activity(marker_type, wf_version, replaying)
|
|
426
429
|
.get_full_history_info()
|
|
427
430
|
.unwrap()
|
|
428
431
|
.into(),
|
|
@@ -516,7 +519,7 @@ mod tests {
|
|
|
516
519
|
// and the history should have the has-change timer. v3 of course always has the change
|
|
517
520
|
// regardless.
|
|
518
521
|
wfm.new_history(
|
|
519
|
-
patch_marker_single_activity(marker_type)
|
|
522
|
+
patch_marker_single_activity(marker_type, wf_version, replaying)
|
|
520
523
|
.get_full_history_info()
|
|
521
524
|
.unwrap()
|
|
522
525
|
.into(),
|
|
@@ -565,118 +568,66 @@ mod tests {
|
|
|
565
568
|
t.add_full_wf_task();
|
|
566
569
|
if have_marker_in_hist {
|
|
567
570
|
t.add_has_change_marker(MY_PATCH_ID, false);
|
|
568
|
-
let scheduled_event_id = t.
|
|
569
|
-
|
|
570
|
-
Some(
|
|
571
|
-
|
|
572
|
-
ActivityTaskScheduledEventAttributes {
|
|
573
|
-
activity_id: "1".to_owned(),
|
|
574
|
-
activity_type: Some(ActivityType {
|
|
575
|
-
name: "".to_string(),
|
|
576
|
-
}),
|
|
577
|
-
..Default::default()
|
|
578
|
-
},
|
|
579
|
-
),
|
|
580
|
-
),
|
|
581
|
-
);
|
|
582
|
-
let started_event_id = t.add_get_event_id(
|
|
583
|
-
EventType::ActivityTaskStarted,
|
|
584
|
-
Some(
|
|
585
|
-
history_event::Attributes::ActivityTaskStartedEventAttributes(
|
|
586
|
-
ActivityTaskStartedEventAttributes {
|
|
587
|
-
scheduled_event_id,
|
|
588
|
-
..Default::default()
|
|
589
|
-
},
|
|
590
|
-
),
|
|
591
|
-
),
|
|
592
|
-
);
|
|
593
|
-
t.add(
|
|
594
|
-
EventType::ActivityTaskCompleted,
|
|
595
|
-
history_event::Attributes::ActivityTaskCompletedEventAttributes(
|
|
596
|
-
ActivityTaskCompletedEventAttributes {
|
|
597
|
-
scheduled_event_id,
|
|
598
|
-
started_event_id,
|
|
599
|
-
// TODO result: Some(Payloads { payloads: vec![Payload{ metadata: Default::default(), data: vec![] }] }),
|
|
600
|
-
..Default::default()
|
|
601
|
-
},
|
|
602
|
-
),
|
|
603
|
-
);
|
|
604
|
-
t.add_full_wf_task();
|
|
605
|
-
let timer_started_event_id = t.add_get_event_id(EventType::TimerStarted, None);
|
|
606
|
-
t.add(
|
|
607
|
-
EventType::TimerFired,
|
|
608
|
-
history_event::Attributes::TimerFiredEventAttributes(TimerFiredEventAttributes {
|
|
609
|
-
started_event_id: timer_started_event_id,
|
|
610
|
-
timer_id: "1".to_owned(),
|
|
571
|
+
let scheduled_event_id = t.add(ActivityTaskScheduledEventAttributes {
|
|
572
|
+
activity_id: "1".to_owned(),
|
|
573
|
+
activity_type: Some(ActivityType {
|
|
574
|
+
name: "".to_string(),
|
|
611
575
|
}),
|
|
612
|
-
|
|
576
|
+
..Default::default()
|
|
577
|
+
});
|
|
578
|
+
let started_event_id = t.add(ActivityTaskStartedEventAttributes {
|
|
579
|
+
scheduled_event_id,
|
|
580
|
+
..Default::default()
|
|
581
|
+
});
|
|
582
|
+
t.add(ActivityTaskCompletedEventAttributes {
|
|
583
|
+
scheduled_event_id,
|
|
584
|
+
started_event_id,
|
|
585
|
+
..Default::default()
|
|
586
|
+
});
|
|
587
|
+
t.add_full_wf_task();
|
|
588
|
+
let timer_started_event_id = t.add_by_type(EventType::TimerStarted);
|
|
589
|
+
t.add(TimerFiredEventAttributes {
|
|
590
|
+
started_event_id: timer_started_event_id,
|
|
591
|
+
timer_id: "1".to_owned(),
|
|
592
|
+
});
|
|
613
593
|
} else {
|
|
614
|
-
let started_event_id = t.
|
|
615
|
-
t.add(
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
timer_id: "1".to_owned(),
|
|
620
|
-
}),
|
|
621
|
-
);
|
|
594
|
+
let started_event_id = t.add_by_type(EventType::TimerStarted);
|
|
595
|
+
t.add(TimerFiredEventAttributes {
|
|
596
|
+
started_event_id,
|
|
597
|
+
timer_id: "1".to_owned(),
|
|
598
|
+
});
|
|
622
599
|
t.add_full_wf_task();
|
|
623
|
-
let timer_started_event_id = t.
|
|
624
|
-
t.add(
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
timer_id: "2".to_owned(),
|
|
629
|
-
}),
|
|
630
|
-
);
|
|
600
|
+
let timer_started_event_id = t.add_by_type(EventType::TimerStarted);
|
|
601
|
+
t.add(TimerFiredEventAttributes {
|
|
602
|
+
started_event_id: timer_started_event_id,
|
|
603
|
+
timer_id: "2".to_owned(),
|
|
604
|
+
});
|
|
631
605
|
}
|
|
632
606
|
t.add_full_wf_task();
|
|
633
607
|
|
|
634
608
|
if have_marker_in_hist {
|
|
635
|
-
let scheduled_event_id = t.
|
|
636
|
-
|
|
637
|
-
Some(
|
|
638
|
-
|
|
639
|
-
ActivityTaskScheduledEventAttributes {
|
|
640
|
-
activity_id: "2".to_string(),
|
|
641
|
-
activity_type: Some(ActivityType {
|
|
642
|
-
name: "".to_string(),
|
|
643
|
-
}),
|
|
644
|
-
..Default::default()
|
|
645
|
-
},
|
|
646
|
-
),
|
|
647
|
-
),
|
|
648
|
-
);
|
|
649
|
-
let started_event_id = t.add_get_event_id(
|
|
650
|
-
EventType::ActivityTaskStarted,
|
|
651
|
-
Some(
|
|
652
|
-
history_event::Attributes::ActivityTaskStartedEventAttributes(
|
|
653
|
-
ActivityTaskStartedEventAttributes {
|
|
654
|
-
scheduled_event_id,
|
|
655
|
-
..Default::default()
|
|
656
|
-
},
|
|
657
|
-
),
|
|
658
|
-
),
|
|
659
|
-
);
|
|
660
|
-
t.add(
|
|
661
|
-
EventType::ActivityTaskCompleted,
|
|
662
|
-
history_event::Attributes::ActivityTaskCompletedEventAttributes(
|
|
663
|
-
ActivityTaskCompletedEventAttributes {
|
|
664
|
-
scheduled_event_id,
|
|
665
|
-
started_event_id,
|
|
666
|
-
// TODO result: Some(Payloads { payloads: vec![Payload{ metadata: Default::default(), data: vec![] }] }),
|
|
667
|
-
..Default::default()
|
|
668
|
-
},
|
|
669
|
-
),
|
|
670
|
-
);
|
|
671
|
-
} else {
|
|
672
|
-
let started_event_id = t.add_get_event_id(EventType::TimerStarted, None);
|
|
673
|
-
t.add(
|
|
674
|
-
EventType::TimerFired,
|
|
675
|
-
history_event::Attributes::TimerFiredEventAttributes(TimerFiredEventAttributes {
|
|
676
|
-
started_event_id,
|
|
677
|
-
timer_id: "3".to_owned(),
|
|
609
|
+
let scheduled_event_id = t.add(ActivityTaskScheduledEventAttributes {
|
|
610
|
+
activity_id: "2".to_string(),
|
|
611
|
+
activity_type: Some(ActivityType {
|
|
612
|
+
name: "".to_string(),
|
|
678
613
|
}),
|
|
679
|
-
|
|
614
|
+
..Default::default()
|
|
615
|
+
});
|
|
616
|
+
let started_event_id = t.add(ActivityTaskStartedEventAttributes {
|
|
617
|
+
scheduled_event_id,
|
|
618
|
+
..Default::default()
|
|
619
|
+
});
|
|
620
|
+
t.add(ActivityTaskCompletedEventAttributes {
|
|
621
|
+
scheduled_event_id,
|
|
622
|
+
started_event_id,
|
|
623
|
+
..Default::default()
|
|
624
|
+
});
|
|
625
|
+
} else {
|
|
626
|
+
let started_event_id = t.add_by_type(EventType::TimerStarted);
|
|
627
|
+
t.add(TimerFiredEventAttributes {
|
|
628
|
+
started_event_id,
|
|
629
|
+
timer_id: "3".to_owned(),
|
|
630
|
+
});
|
|
680
631
|
}
|
|
681
632
|
t.add_full_wf_task();
|
|
682
633
|
t.add_workflow_execution_completed();
|
|
@@ -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, MachineError, TransitionResult};
|
|
6
7
|
use std::convert::TryFrom;
|
|
7
8
|
use temporal_sdk_core_protos::{
|
|
@@ -183,10 +184,11 @@ impl TryFrom<CommandType> for SignalExternalMachineEvents {
|
|
|
183
184
|
})
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
|
-
impl TryFrom<
|
|
187
|
+
impl TryFrom<HistEventData> for SignalExternalMachineEvents {
|
|
187
188
|
type Error = WFMachinesError;
|
|
188
189
|
|
|
189
|
-
fn try_from(e:
|
|
190
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
|
191
|
+
let e = e.event;
|
|
190
192
|
Ok(match e.event_type() {
|
|
191
193
|
EventType::ExternalWorkflowExecutionSignaled => Self::ExternalWorkflowExecutionSignaled,
|
|
192
194
|
EventType::SignalExternalWorkflowExecutionInitiated => {
|
|
@@ -202,15 +204,13 @@ impl TryFrom<HistoryEvent> for SignalExternalMachineEvents {
|
|
|
202
204
|
Self::SignalExternalWorkflowExecutionFailed(attrs.cause())
|
|
203
205
|
} else {
|
|
204
206
|
return Err(WFMachinesError::Fatal(format!(
|
|
205
|
-
"Signal workflow failed attributes were unset: {}"
|
|
206
|
-
e
|
|
207
|
+
"Signal workflow failed attributes were unset: {e}"
|
|
207
208
|
)));
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
211
|
_ => {
|
|
211
212
|
return Err(WFMachinesError::Nondeterminism(format!(
|
|
212
|
-
"Signal external WF machine does not handle this event: {}"
|
|
213
|
-
e
|
|
213
|
+
"Signal external WF machine does not handle this event: {e}"
|
|
214
214
|
)))
|
|
215
215
|
}
|
|
216
216
|
})
|
|
@@ -242,7 +242,7 @@ impl WFMachinesAdapter for SignalExternalMachine {
|
|
|
242
242
|
seq: self.shared_state.seq,
|
|
243
243
|
// TODO: Create new failure type upstream for this
|
|
244
244
|
failure: Some(Failure {
|
|
245
|
-
message: format!("Unable to signal external workflow because {}"
|
|
245
|
+
message: format!("Unable to signal external workflow because {reason}"),
|
|
246
246
|
failure_info: Some(FailureInfo::ApplicationFailureInfo(
|
|
247
247
|
ApplicationFailureInfo {
|
|
248
248
|
r#type: f.to_string(),
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#![allow(clippy::large_enum_variant)]
|
|
2
2
|
|
|
3
3
|
use super::{
|
|
4
|
-
workflow_machines::
|
|
5
|
-
|
|
4
|
+
workflow_machines::MachineResponse, Cancellable, EventInfo, NewMachineWithCommand,
|
|
5
|
+
OnEventWrapper, WFMachinesAdapter,
|
|
6
6
|
};
|
|
7
|
+
use crate::worker::workflow::{machines::HistEventData, WFMachinesError};
|
|
7
8
|
use rustfsm::{fsm, MachineError, StateMachine, TransitionResult};
|
|
8
9
|
use std::convert::TryFrom;
|
|
9
10
|
use temporal_sdk_core_protos::{
|
|
@@ -93,10 +94,11 @@ impl TimerMachine {
|
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
impl TryFrom<
|
|
97
|
+
impl TryFrom<HistEventData> for TimerMachineEvents {
|
|
97
98
|
type Error = WFMachinesError;
|
|
98
99
|
|
|
99
|
-
fn try_from(e:
|
|
100
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
|
101
|
+
let e = e.event;
|
|
100
102
|
Ok(match e.event_type() {
|
|
101
103
|
EventType::TimerStarted => Self::TimerStarted(e.event_id),
|
|
102
104
|
EventType::TimerCanceled => Self::TimerCanceled,
|
|
@@ -107,15 +109,13 @@ impl TryFrom<HistoryEvent> for TimerMachineEvents {
|
|
|
107
109
|
Self::TimerFired(attrs)
|
|
108
110
|
} else {
|
|
109
111
|
return Err(WFMachinesError::Fatal(format!(
|
|
110
|
-
"Timer fired attribs were unset: {}"
|
|
111
|
-
e
|
|
112
|
+
"Timer fired attribs were unset: {e}"
|
|
112
113
|
)));
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
_ => {
|
|
116
117
|
return Err(WFMachinesError::Nondeterminism(format!(
|
|
117
|
-
"Timer machine does not handle this event: {}"
|
|
118
|
-
e
|
|
118
|
+
"Timer machine does not handle this event: {e}"
|
|
119
119
|
)))
|
|
120
120
|
}
|
|
121
121
|
})
|
|
@@ -256,7 +256,7 @@ impl Cancellable for TimerMachine {
|
|
|
256
256
|
vec![MachineResponse::IssueNewCommand(cmd)]
|
|
257
257
|
}
|
|
258
258
|
None => vec![],
|
|
259
|
-
x => panic!("Invalid cancel event response {:?}"
|
|
259
|
+
x => panic!("Invalid cancel event response {x:?}"),
|
|
260
260
|
},
|
|
261
261
|
)
|
|
262
262
|
}
|
|
@@ -144,7 +144,7 @@ mod machine_coverage_report {
|
|
|
144
144
|
m @ "ModifyWorkflowPropertiesMachine" => {
|
|
145
145
|
cover_transitions(m, &mut modify_wf_props, coverage)
|
|
146
146
|
}
|
|
147
|
-
m => panic!("Unknown machine {}"
|
|
147
|
+
m => panic!("Unknown machine {m}"),
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -168,7 +168,7 @@ mod machine_coverage_report {
|
|
|
168
168
|
let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
169
169
|
d.push("machine_coverage");
|
|
170
170
|
std::fs::create_dir_all(&d).unwrap();
|
|
171
|
-
d.push(format!("{}_Coverage.puml"
|
|
171
|
+
d.push(format!("{machine}_Coverage.puml"));
|
|
172
172
|
let mut file = File::create(d).unwrap();
|
|
173
173
|
file.write_all(viz.as_bytes()).unwrap();
|
|
174
174
|
}
|
data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
use super::{
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
use super::{workflow_machines::MachineResponse, NewMachineWithCommand};
|
|
2
|
+
use crate::worker::workflow::{
|
|
3
|
+
machines::{Cancellable, EventInfo, HistEventData, WFMachinesAdapter},
|
|
4
|
+
WFMachinesError,
|
|
4
5
|
};
|
|
5
|
-
use crate::worker::workflow::machines::{Cancellable, EventInfo, WFMachinesAdapter};
|
|
6
6
|
use rustfsm::{fsm, TransitionResult};
|
|
7
7
|
use temporal_sdk_core_protos::{
|
|
8
8
|
coresdk::workflow_commands::UpsertWorkflowSearchAttributes,
|
|
@@ -109,10 +109,11 @@ impl Cancellable for UpsertSearchAttributesMachine {}
|
|
|
109
109
|
// Converts the generic history event with type EventType::UpsertWorkflowSearchAttributes into the
|
|
110
110
|
// UpsertSearchAttributesMachine-specific event type
|
|
111
111
|
// UpsertSearchAttributesMachineEvents::CommandRecorded.
|
|
112
|
-
impl TryFrom<
|
|
112
|
+
impl TryFrom<HistEventData> for UpsertSearchAttributesMachineEvents {
|
|
113
113
|
type Error = WFMachinesError;
|
|
114
114
|
|
|
115
|
-
fn try_from(e:
|
|
115
|
+
fn try_from(e: HistEventData) -> Result<Self, Self::Error> {
|
|
116
|
+
let e = e.event;
|
|
116
117
|
match e.event_type() {
|
|
117
118
|
EventType::UpsertWorkflowSearchAttributes => {
|
|
118
119
|
Ok(UpsertSearchAttributesMachineEvents::CommandRecorded)
|
|
@@ -229,7 +230,13 @@ mod tests {
|
|
|
229
230
|
..Default::default()
|
|
230
231
|
};
|
|
231
232
|
assert!(sm.matches_event(&recorded_history_event));
|
|
232
|
-
let cmd_recorded_sm_event =
|
|
233
|
+
let cmd_recorded_sm_event = HistEventData {
|
|
234
|
+
event: recorded_history_event,
|
|
235
|
+
replaying: false,
|
|
236
|
+
current_task_is_last_in_history: true,
|
|
237
|
+
}
|
|
238
|
+
.try_into()
|
|
239
|
+
.unwrap();
|
|
233
240
|
|
|
234
241
|
OnEventWrapper::on_event_mut(&mut sm, cmd_scheduled_sm_event)
|
|
235
242
|
.expect("CommandScheduled should transition Created -> CommandIssued");
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
use super::super::
|
|
1
|
+
use super::super::local_activity_state_machine::ResolveDat;
|
|
2
2
|
use crate::{
|
|
3
|
-
protosext::{
|
|
3
|
+
protosext::{CompleteLocalActivityData, ValidScheduleLA},
|
|
4
4
|
worker::{ExecutingLAId, LocalActRequest, NewLocalAct},
|
|
5
5
|
};
|
|
6
6
|
use std::{
|
|
7
7
|
collections::{HashMap, HashSet},
|
|
8
8
|
time::SystemTime,
|
|
9
9
|
};
|
|
10
|
-
use temporal_sdk_core_protos::temporal::api::
|
|
11
|
-
common::v1::WorkflowExecution, history::v1::HistoryEvent,
|
|
12
|
-
};
|
|
10
|
+
use temporal_sdk_core_protos::temporal::api::common::v1::WorkflowExecution;
|
|
13
11
|
|
|
14
12
|
#[derive(Default)]
|
|
15
13
|
pub(super) struct LocalActivityData {
|
|
@@ -70,17 +68,8 @@ impl LocalActivityData {
|
|
|
70
68
|
self.executing.len() + self.new_requests.len()
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
pub(super) fn
|
|
74
|
-
|
|
75
|
-
self.preresolutions
|
|
76
|
-
.insert(la_dat.marker_dat.seq, la_dat.into());
|
|
77
|
-
} else {
|
|
78
|
-
return Err(WFMachinesError::Fatal(format!(
|
|
79
|
-
"Local activity marker was unparsable: {:?}",
|
|
80
|
-
e
|
|
81
|
-
)));
|
|
82
|
-
}
|
|
83
|
-
Ok(())
|
|
71
|
+
pub(super) fn insert_peeked_marker(&mut self, dat: CompleteLocalActivityData) {
|
|
72
|
+
self.preresolutions.insert(dat.marker_dat.seq, dat.into());
|
|
84
73
|
}
|
|
85
74
|
|
|
86
75
|
pub(super) fn take_preresolution(&mut self, seq: u32) -> Option<ResolveDat> {
|