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
|
@@ -12,13 +12,15 @@ categories = ["development-tools"]
|
|
|
12
12
|
|
|
13
13
|
[features]
|
|
14
14
|
history_builders = ["uuid", "rand"]
|
|
15
|
+
serde_serialize = []
|
|
15
16
|
|
|
16
17
|
[dependencies]
|
|
17
18
|
anyhow = "1.0"
|
|
18
|
-
base64 = "0.
|
|
19
|
+
base64 = "0.21"
|
|
19
20
|
derive_more = "0.99"
|
|
20
21
|
prost = "0.11"
|
|
21
|
-
prost-
|
|
22
|
+
prost-wkt = "0.4"
|
|
23
|
+
prost-wkt-types = "0.4"
|
|
22
24
|
rand = { version = "0.8", optional = true }
|
|
23
25
|
serde = { version = "1.0", features = ["derive"] }
|
|
24
26
|
serde_json = "1.0"
|
|
@@ -28,3 +30,4 @@ uuid = { version = "1.1", features = ["v4"], optional = true }
|
|
|
28
30
|
|
|
29
31
|
[build-dependencies]
|
|
30
32
|
tonic-build = "0.8"
|
|
33
|
+
prost-wkt-build = "0.4"
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
use std::{env, path::PathBuf};
|
|
2
|
+
|
|
1
3
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
2
4
|
println!("cargo:rerun-if-changed=../protos");
|
|
5
|
+
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
6
|
+
let descriptor_file = out.join("descriptors.bin");
|
|
3
7
|
tonic_build::configure()
|
|
4
8
|
// We don't actually want to build the grpc definitions - we don't need them (for now).
|
|
5
9
|
// Just build the message structs.
|
|
@@ -74,7 +78,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
74
78
|
// All external data is useful to be able to JSON serialize, so it can render in web UI
|
|
75
79
|
.type_attribute(
|
|
76
80
|
".coresdk.external_data",
|
|
77
|
-
"#[derive(::serde::Serialize, ::serde::Deserialize)]",
|
|
81
|
+
"#[cfg_attr(not(feature = \"serde_serialize\"), derive(::serde::Serialize, ::serde::Deserialize))]",
|
|
82
|
+
)
|
|
83
|
+
.type_attribute(
|
|
84
|
+
".",
|
|
85
|
+
"#[cfg_attr(feature = \"serde_serialize\", derive(::serde::Serialize, ::serde::Deserialize))]",
|
|
78
86
|
)
|
|
79
87
|
.field_attribute(
|
|
80
88
|
"coresdk.external_data.LocalActivityMarkerData.complete_time",
|
|
@@ -88,6 +96,23 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
88
96
|
"coresdk.external_data.LocalActivityMarkerData.backoff",
|
|
89
97
|
"#[serde(with = \"opt_duration\")]",
|
|
90
98
|
)
|
|
99
|
+
.extern_path(
|
|
100
|
+
".google.protobuf.Any",
|
|
101
|
+
"::prost_wkt_types::Any"
|
|
102
|
+
)
|
|
103
|
+
.extern_path(
|
|
104
|
+
".google.protobuf.Timestamp",
|
|
105
|
+
"::prost_wkt_types::Timestamp"
|
|
106
|
+
)
|
|
107
|
+
.extern_path(
|
|
108
|
+
".google.protobuf.Duration",
|
|
109
|
+
"::prost_wkt_types::Duration"
|
|
110
|
+
)
|
|
111
|
+
.extern_path(
|
|
112
|
+
".google.protobuf.Value",
|
|
113
|
+
"::prost_wkt_types::Value"
|
|
114
|
+
)
|
|
115
|
+
.file_descriptor_set_path(#[allow(clippy::needless_borrow)] &descriptor_file)
|
|
91
116
|
.compile(
|
|
92
117
|
&[
|
|
93
118
|
"../protos/local/temporal/sdk/core/core_interface.proto",
|
|
@@ -103,5 +128,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
103
128
|
"../protos/grpc",
|
|
104
129
|
],
|
|
105
130
|
)?;
|
|
131
|
+
|
|
132
|
+
#[cfg(feature = "serde_serialize")]
|
|
133
|
+
{
|
|
134
|
+
use prost_wkt_build::{FileDescriptorSet, Message};
|
|
135
|
+
|
|
136
|
+
let descriptor_bytes = std::fs::read(descriptor_file)?;
|
|
137
|
+
let descriptor = FileDescriptorSet::decode(&descriptor_bytes[..])?;
|
|
138
|
+
prost_wkt_build::add_serde(out, descriptor);
|
|
139
|
+
}
|
|
140
|
+
|
|
106
141
|
Ok(())
|
|
107
142
|
}
|
|
@@ -6,10 +6,11 @@ use crate::{
|
|
|
6
6
|
NamespacedWorkflowExecution,
|
|
7
7
|
},
|
|
8
8
|
external_data::LocalActivityMarkerData,
|
|
9
|
+
workflow_commands::ScheduleActivity,
|
|
9
10
|
IntoPayloadsExt,
|
|
10
11
|
},
|
|
11
12
|
temporal::api::{
|
|
12
|
-
common::v1::{Payload, Payloads, WorkflowExecution, WorkflowType},
|
|
13
|
+
common::v1::{ActivityType, Payload, Payloads, WorkflowExecution, WorkflowType},
|
|
13
14
|
enums::v1::{EventType, TaskQueueKind, WorkflowTaskFailedCause},
|
|
14
15
|
failure::v1::{failure, CanceledFailureInfo, Failure},
|
|
15
16
|
history::v1::{history_event::Attributes, *},
|
|
@@ -18,11 +19,12 @@ use crate::{
|
|
|
18
19
|
HistoryInfo,
|
|
19
20
|
};
|
|
20
21
|
use anyhow::bail;
|
|
21
|
-
use
|
|
22
|
+
use prost_wkt_types::Timestamp;
|
|
22
23
|
use std::time::{Duration, SystemTime};
|
|
23
24
|
use uuid::Uuid;
|
|
24
25
|
|
|
25
26
|
pub static DEFAULT_WORKFLOW_TYPE: &str = "default_wf_type";
|
|
27
|
+
pub static DEFAULT_ACTIVITY_TYPE: &str = "default_act_type";
|
|
26
28
|
|
|
27
29
|
type Result<T, E = anyhow::Error> = std::result::Result<T, E>;
|
|
28
30
|
|
|
@@ -61,26 +63,19 @@ impl TestHistoryBuilder {
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
/// Add an event by type with attributes. Bundles both into a [HistoryEvent] with an id that is
|
|
64
|
-
/// incremented on each call to add.
|
|
65
|
-
pub fn add(&mut self,
|
|
66
|
-
|
|
66
|
+
/// incremented on each call to add. Returns the id of the new event.
|
|
67
|
+
pub fn add(&mut self, attribs: impl Into<Attributes>) -> i64 {
|
|
68
|
+
let attribs: Attributes = attribs.into();
|
|
69
|
+
self.build_and_push_event(attribs.event_type(), attribs);
|
|
70
|
+
self.current_event_id
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
/// Adds an event to the history by type, with default attributes.
|
|
70
|
-
|
|
73
|
+
/// Adds an event to the history by type, with default attributes. Returns the id of the new
|
|
74
|
+
/// event.
|
|
75
|
+
pub fn add_by_type(&mut self, event_type: EventType) -> i64 {
|
|
71
76
|
let attribs =
|
|
72
77
|
default_attribs(event_type).expect("Couldn't make default attributes in test builder");
|
|
73
|
-
self.
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/// Adds an event, returning the ID that was assigned to it
|
|
77
|
-
pub fn add_get_event_id(&mut self, event_type: EventType, attrs: Option<Attributes>) -> i64 {
|
|
78
|
-
if let Some(a) = attrs {
|
|
79
|
-
self.build_and_push_event(event_type, a);
|
|
80
|
-
} else {
|
|
81
|
-
self.add_by_type(event_type);
|
|
82
|
-
}
|
|
83
|
-
self.current_event_id
|
|
78
|
+
self.add(attribs)
|
|
84
79
|
}
|
|
85
80
|
|
|
86
81
|
/// Adds the following events:
|
|
@@ -100,25 +95,21 @@ impl TestHistoryBuilder {
|
|
|
100
95
|
}
|
|
101
96
|
|
|
102
97
|
pub fn add_workflow_task_scheduled(&mut self) {
|
|
103
|
-
self.workflow_task_scheduled_event_id =
|
|
104
|
-
self.add_get_event_id(EventType::WorkflowTaskScheduled, None);
|
|
98
|
+
self.workflow_task_scheduled_event_id = self.add_by_type(EventType::WorkflowTaskScheduled);
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
pub fn add_workflow_task_started(&mut self) {
|
|
108
|
-
|
|
102
|
+
self.final_workflow_task_started_event_id = self.add(WorkflowTaskStartedEventAttributes {
|
|
109
103
|
scheduled_event_id: self.workflow_task_scheduled_event_id,
|
|
110
104
|
..Default::default()
|
|
111
|
-
};
|
|
112
|
-
self.final_workflow_task_started_event_id =
|
|
113
|
-
self.add_get_event_id(EventType::WorkflowTaskStarted, Some(attrs.into()));
|
|
105
|
+
});
|
|
114
106
|
}
|
|
115
107
|
|
|
116
108
|
pub fn add_workflow_task_completed(&mut self) {
|
|
117
|
-
let
|
|
109
|
+
let id = self.add(WorkflowTaskCompletedEventAttributes {
|
|
118
110
|
scheduled_event_id: self.workflow_task_scheduled_event_id,
|
|
119
111
|
..Default::default()
|
|
120
|
-
};
|
|
121
|
-
let id = self.add_get_event_id(EventType::WorkflowTaskCompleted, Some(attrs.into()));
|
|
112
|
+
});
|
|
122
113
|
self.previous_task_completed_id = id;
|
|
123
114
|
}
|
|
124
115
|
|
|
@@ -176,30 +167,22 @@ impl TestHistoryBuilder {
|
|
|
176
167
|
}
|
|
177
168
|
|
|
178
169
|
pub fn add_activity_task_scheduled(&mut self, activity_id: impl Into<String>) -> i64 {
|
|
179
|
-
self.
|
|
180
|
-
|
|
181
|
-
Some(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
},
|
|
187
|
-
),
|
|
188
|
-
),
|
|
189
|
-
)
|
|
170
|
+
self.add(ActivityTaskScheduledEventAttributes {
|
|
171
|
+
activity_id: activity_id.into(),
|
|
172
|
+
activity_type: Some(ActivityType {
|
|
173
|
+
name: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
174
|
+
}),
|
|
175
|
+
..Default::default()
|
|
176
|
+
})
|
|
190
177
|
}
|
|
178
|
+
|
|
191
179
|
pub fn add_activity_task_started(&mut self, scheduled_event_id: i64) -> i64 {
|
|
192
|
-
self.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
..Default::default()
|
|
199
|
-
},
|
|
200
|
-
),
|
|
201
|
-
),
|
|
202
|
-
)
|
|
180
|
+
self.add(Attributes::ActivityTaskStartedEventAttributes(
|
|
181
|
+
ActivityTaskStartedEventAttributes {
|
|
182
|
+
scheduled_event_id,
|
|
183
|
+
..Default::default()
|
|
184
|
+
},
|
|
185
|
+
))
|
|
203
186
|
}
|
|
204
187
|
|
|
205
188
|
pub fn add_activity_task_completed(
|
|
@@ -208,17 +191,12 @@ impl TestHistoryBuilder {
|
|
|
208
191
|
started_event_id: i64,
|
|
209
192
|
payload: Payload,
|
|
210
193
|
) {
|
|
211
|
-
self.add(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
result: vec![payload].into_payloads(),
|
|
218
|
-
..Default::default()
|
|
219
|
-
},
|
|
220
|
-
),
|
|
221
|
-
);
|
|
194
|
+
self.add(ActivityTaskCompletedEventAttributes {
|
|
195
|
+
scheduled_event_id,
|
|
196
|
+
started_event_id,
|
|
197
|
+
result: vec![payload].into_payloads(),
|
|
198
|
+
..Default::default()
|
|
199
|
+
});
|
|
222
200
|
}
|
|
223
201
|
|
|
224
202
|
pub fn add_activity_task_cancel_requested(&mut self, scheduled_event_id: i64) {
|
|
@@ -258,13 +236,10 @@ impl TestHistoryBuilder {
|
|
|
258
236
|
}
|
|
259
237
|
|
|
260
238
|
pub fn add_timer_fired(&mut self, timer_started_evt_id: i64, timer_id: String) {
|
|
261
|
-
self.add(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
timer_id,
|
|
266
|
-
}),
|
|
267
|
-
);
|
|
239
|
+
self.add(TimerFiredEventAttributes {
|
|
240
|
+
started_event_id: timer_started_evt_id,
|
|
241
|
+
timer_id,
|
|
242
|
+
});
|
|
268
243
|
}
|
|
269
244
|
|
|
270
245
|
pub fn add_we_signaled(&mut self, signal_name: &str, payloads: Vec<Payload>) {
|
|
@@ -298,7 +273,7 @@ impl TestHistoryBuilder {
|
|
|
298
273
|
seq,
|
|
299
274
|
attempt: 1,
|
|
300
275
|
activity_id: activity_id.to_string(),
|
|
301
|
-
activity_type:
|
|
276
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
302
277
|
complete_time: None,
|
|
303
278
|
backoff: None,
|
|
304
279
|
original_schedule_time: None,
|
|
@@ -369,7 +344,7 @@ impl TestHistoryBuilder {
|
|
|
369
344
|
workflow_id: impl Into<String>,
|
|
370
345
|
run_id: impl Into<String>,
|
|
371
346
|
) -> i64 {
|
|
372
|
-
|
|
347
|
+
self.add(SignalExternalWorkflowExecutionInitiatedEventAttributes {
|
|
373
348
|
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
374
349
|
workflow_execution: Some(WorkflowExecution {
|
|
375
350
|
workflow_id: workflow_id.into(),
|
|
@@ -378,11 +353,7 @@ impl TestHistoryBuilder {
|
|
|
378
353
|
signal_name: signal_name.into(),
|
|
379
354
|
control: "".to_string(),
|
|
380
355
|
..Default::default()
|
|
381
|
-
}
|
|
382
|
-
self.add_get_event_id(
|
|
383
|
-
EventType::SignalExternalWorkflowExecutionInitiated,
|
|
384
|
-
Some(attrs.into()),
|
|
385
|
-
)
|
|
356
|
+
})
|
|
386
357
|
}
|
|
387
358
|
|
|
388
359
|
pub fn add_external_signal_completed(&mut self, initiated_id: i64) {
|
|
@@ -405,18 +376,16 @@ impl TestHistoryBuilder {
|
|
|
405
376
|
}
|
|
406
377
|
|
|
407
378
|
pub fn add_cancel_external_wf(&mut self, execution: NamespacedWorkflowExecution) -> i64 {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
EventType::RequestCancelExternalWorkflowExecutionInitiated,
|
|
419
|
-
Some(attrs.into()),
|
|
379
|
+
self.add(
|
|
380
|
+
RequestCancelExternalWorkflowExecutionInitiatedEventAttributes {
|
|
381
|
+
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
382
|
+
namespace: execution.namespace,
|
|
383
|
+
workflow_execution: Some(WorkflowExecution {
|
|
384
|
+
workflow_id: execution.workflow_id,
|
|
385
|
+
run_id: execution.run_id,
|
|
386
|
+
}),
|
|
387
|
+
..Default::default()
|
|
388
|
+
},
|
|
420
389
|
)
|
|
421
390
|
}
|
|
422
391
|
|
|
@@ -442,6 +411,12 @@ impl TestHistoryBuilder {
|
|
|
442
411
|
);
|
|
443
412
|
}
|
|
444
413
|
|
|
414
|
+
pub fn add_wfe_started_with_wft_timeout(&mut self, dur: Duration) {
|
|
415
|
+
let mut wesattrs = default_wes_attribs();
|
|
416
|
+
wesattrs.workflow_task_timeout = Some(dur.try_into().unwrap());
|
|
417
|
+
self.add(wesattrs);
|
|
418
|
+
}
|
|
419
|
+
|
|
445
420
|
pub fn get_orig_run_id(&self) -> &str {
|
|
446
421
|
&self.original_run_id
|
|
447
422
|
}
|
|
@@ -466,7 +441,7 @@ impl TestHistoryBuilder {
|
|
|
466
441
|
}
|
|
467
442
|
|
|
468
443
|
/// Return most recent wft start time or panic if unset
|
|
469
|
-
pub fn wft_start_time(&self) ->
|
|
444
|
+
pub fn wft_start_time(&self) -> Timestamp {
|
|
470
445
|
self.events[(self.workflow_task_scheduled_event_id + 1) as usize]
|
|
471
446
|
.event_time
|
|
472
447
|
.clone()
|
|
@@ -493,6 +468,37 @@ impl TestHistoryBuilder {
|
|
|
493
468
|
modifier(he);
|
|
494
469
|
}
|
|
495
470
|
|
|
471
|
+
/// Sets internal patches which should appear in the first WFT complete event
|
|
472
|
+
pub fn set_flags_first_wft(&mut self, core: &[u32], lang: &[u32]) {
|
|
473
|
+
Self::set_flags(self.events.iter_mut(), core, lang)
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/// Sets internal patches which should appear in the most recent complete event
|
|
477
|
+
pub fn set_flags_last_wft(&mut self, core: &[u32], lang: &[u32]) {
|
|
478
|
+
Self::set_flags(self.events.iter_mut().rev(), core, lang)
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
fn set_flags<'a>(
|
|
482
|
+
mut events: impl Iterator<Item = &'a mut HistoryEvent>,
|
|
483
|
+
core: &[u32],
|
|
484
|
+
lang: &[u32],
|
|
485
|
+
) {
|
|
486
|
+
if let Some(first_attrs) = events.find_map(|e| {
|
|
487
|
+
if let Some(Attributes::WorkflowTaskCompletedEventAttributes(a)) = e.attributes.as_mut()
|
|
488
|
+
{
|
|
489
|
+
Some(a)
|
|
490
|
+
} else {
|
|
491
|
+
None
|
|
492
|
+
}
|
|
493
|
+
}) {
|
|
494
|
+
let sdk_dat = first_attrs
|
|
495
|
+
.sdk_metadata
|
|
496
|
+
.get_or_insert_with(Default::default);
|
|
497
|
+
sdk_dat.core_used_flags = core.to_vec();
|
|
498
|
+
sdk_dat.lang_used_flags = lang.to_vec();
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
496
502
|
fn build_and_push_event(&mut self, event_type: EventType, attribs: Attributes) {
|
|
497
503
|
self.current_event_id += 1;
|
|
498
504
|
let evt = HistoryEvent {
|
|
@@ -542,3 +548,10 @@ pub fn default_wes_attribs() -> WorkflowExecutionStartedEventAttributes {
|
|
|
542
548
|
..Default::default()
|
|
543
549
|
}
|
|
544
550
|
}
|
|
551
|
+
|
|
552
|
+
pub fn default_act_sched() -> ScheduleActivity {
|
|
553
|
+
ScheduleActivity {
|
|
554
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
555
|
+
..Default::default()
|
|
556
|
+
}
|
|
557
|
+
}
|
|
@@ -136,6 +136,10 @@ impl HistoryInfo {
|
|
|
136
136
|
&self.events
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
pub fn into_events(self) -> Vec<HistoryEvent> {
|
|
140
|
+
self.events
|
|
141
|
+
}
|
|
142
|
+
|
|
139
143
|
/// Extract run id from the workflow execution started attributes.
|
|
140
144
|
pub fn orig_run_id(&self) -> &str {
|
|
141
145
|
&self.wf_exe_started_attrs.original_execution_run_id
|
|
@@ -204,7 +208,7 @@ mod tests {
|
|
|
204
208
|
let mut t = TestHistoryBuilder::default();
|
|
205
209
|
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
206
210
|
t.add_full_wf_task();
|
|
207
|
-
let timer_started_event_id = t.
|
|
211
|
+
let timer_started_event_id = t.add_by_type(EventType::TimerStarted);
|
|
208
212
|
t.add_timer_fired(timer_started_event_id, timer_id.to_string());
|
|
209
213
|
t.add_workflow_task_scheduled_and_started();
|
|
210
214
|
t
|