Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ exclude = ["protos/*/.github/*"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
history_builders = ["dep:rand"]
otel = ["dep:opentelemetry", "dep:opentelemetry_sdk", "dep:opentelemetry-otlp"]
prometheus = [
"dep:prometheus",
Expand All @@ -25,7 +24,6 @@ prometheus = [
]
envconfig = ["dep:toml", "dep:dirs"]
serde_serialize = []
test-utilities = ["history_builders"]
core-telemetry-bridge = ["dep:ringbuf", "dep:futures-channel"]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chris-olszewski Note the casing inconsistency in serde_serialize vs other features.

core-based-sdk = ["core-telemetry-bridge", "prometheus", "envconfig"]

Expand Down Expand Up @@ -70,7 +68,6 @@ prometheus = { version = "0.14", optional = true, default-features = false }
prost = { workspace = true }
prost-wkt = "0.7"
prost-types = { workspace = true }
rand = { version = "0.10", optional = true }
ringbuf = { version = "0.4", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = { workspace = true }
Expand Down
16 changes: 0 additions & 16 deletions crates/common/src/protos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,10 @@ pub mod constants;
/// Utility functions for working with protobuf types.
pub mod utilities;

#[cfg(feature = "test-utilities")]
/// Pre-built test histories for common workflow patterns.
pub mod canned_histories;
#[cfg(feature = "history_builders")]
mod history_builder;
#[cfg(feature = "history_builders")]
mod history_info;
mod task_token;
#[cfg(feature = "test-utilities")]
pub mod test_utils;

use std::time::Duration;

#[cfg(feature = "history_builders")]
pub use history_builder::{
DEFAULT_ACTIVITY_TYPE, DEFAULT_WORKFLOW_TYPE, TestHistoryBuilder, default_act_sched,
default_wes_attribs,
};
#[cfg(feature = "history_builders")]
pub use history_info::HistoryInfo;
pub use task_token::TaskToken;

/// Payload metadata key that identifies the encoding format.
Expand Down
9 changes: 5 additions & 4 deletions crates/sdk-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ otel = [
]
ephemeral-server = ["dep:flate2", "dep:reqwest", "dep:tar", "dep:zip"]
debug-plugin = ["dep:reqwest", "dep:hyper"]
# Exposes mocks and helpers used by sdk-core's own integration tests, benches,
# and the `histfetch` binary. Not part of the public API surface; downstream
# crates should not enable this feature.
test-utilities = ["dep:assert_matches", "dep:bimap"]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a Rust convention for features that are not meant to be used publicly?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I know of. We could prefix with __ to make the name convey internal usage, but I don't think that is a widely used pattern.

antithesis_assertions = ["dep:antithesis_sdk"]

Expand Down Expand Up @@ -119,7 +122,7 @@ zip = { version = "8.4", optional = true, default-features = false, features = [
path = "../common"
version = "0.3"
default-features = false
features = ["core-telemetry-bridge", "history_builders"]
features = ["core-telemetry-bridge"]

[dependencies.temporalio-client]
path = "../client"
Expand Down Expand Up @@ -149,9 +152,7 @@ hyper-util = { version = "0.1", features = [
rstest = "0.26"
semver = "1.0"
temporalio-sdk = { path = "../sdk" }
temporalio-common = { path = "../common", version = "0.3", default-features = false, features = [
"test-utilities",
] }
temporalio-common = { path = "../common", version = "0.3", default-features = false }
tokio = { version = "1.47", default-features = false, features = [
"rt",
"rt-multi-thread",
Expand Down
10 changes: 5 additions & 5 deletions crates/sdk-core/benches/workflow_replay_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use std::{
thread,
time::Duration,
};
use temporalio_common::{
protos::{DEFAULT_WORKFLOW_TYPE, canned_histories},
telemetry::metrics::{MetricKeyValue, MetricParameters, NewAttributes},
};
use temporalio_common::telemetry::metrics::{MetricKeyValue, MetricParameters, NewAttributes};
use temporalio_macros::{workflow, workflow_methods};
use temporalio_sdk::{SyncWorkflowContext, WorkflowContext, WorkflowResult};
use temporalio_sdk_core::{CoreRuntime, replay::HistoryForReplay};
use temporalio_sdk_core::{
CoreRuntime,
replay::{DEFAULT_WORKFLOW_TYPE, HistoryForReplay, canned_histories},
};

pub fn criterion_benchmark(c: &mut Criterion) {
let tokio_runtime = tokio::runtime::Builder::new_current_thread()
Expand Down
5 changes: 2 additions & 3 deletions crates/sdk-core/src/core_tests/activity_tasks.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::{
ActivityHeartbeat, CompleteActivityError, Worker, advance_fut, job_assert, prost_dur,
replay::{TestHistoryBuilder, canned_histories},
test_help::{
FakeWfResponses, MockPollCfg, MockWorkerInputs, MocksHolder, QueueResponse, WorkerExt,
WorkflowCachingPolicy, build_fake_worker, build_mock_pollers, build_multihist_mock_sg,
fanout_tasks, gen_assert_and_reply, mock_manual_poller, mock_poller, mock_worker,
poll_and_reply, single_hist_mock_sg, test_worker_cfg,
poll_and_reply, single_hist_mock_sg, start_timer_cmd, test_worker_cfg,
},
worker::{
PollerBehavior,
Expand All @@ -26,7 +27,6 @@ use std::{
};
use temporalio_common::{
protos::{
TestHistoryBuilder, canned_histories,
coresdk::{
ActivityTaskCompletion,
activity_result::{
Expand All @@ -52,7 +52,6 @@ use temporalio_common::{
RespondActivityTaskFailedResponse, RespondWorkflowTaskCompletedResponse,
},
},
test_utils::start_timer_cmd,
},
worker::WorkerTaskTypes,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/sdk-core/src/core_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod workflow_tasks;

use crate::{
PollError, Worker,
replay::{TestHistoryBuilder, canned_histories},
test_help::{
MockPollCfg, build_mock_pollers, mock_worker, single_hist_mock_sg, test_worker_cfg,
},
Expand All @@ -19,7 +20,6 @@ use crate::{
use futures_util::FutureExt;
use std::{sync::LazyLock, time::Duration};
use temporalio_common::protos::{
TestHistoryBuilder, canned_histories,
coresdk::{
workflow_activation::{WorkflowActivationJob, workflow_activation_job},
workflow_completion::WorkflowActivationCompletion,
Expand Down
6 changes: 3 additions & 3 deletions crates/sdk-core/src/core_tests/queries.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{
replay::{TestHistoryBuilder, canned_histories},
test_help::{
MockPollCfg, MocksHolder, ResponseType, WorkerExt, WorkerTestHelpers, build_mock_pollers,
hist_to_poll_resp, mock_worker, single_hist_mock_sg,
hist_to_poll_resp, mock_worker, query_ok, schedule_activity_cmd, single_hist_mock_sg,
start_timer_cmd,
},
worker::{
LEGACY_QUERY_ID, WorkerVersioningStrategy,
Expand All @@ -19,7 +21,6 @@ use std::{
};
use temporalio_client::MESSAGE_TOO_LARGE_KEY;
use temporalio_common::protos::{
TestHistoryBuilder, canned_histories,
coresdk::{
workflow_activation::{
WorkflowActivationJob, remove_from_cache::EvictionReason, workflow_activation_job,
Expand All @@ -40,7 +41,6 @@ use temporalio_common::protos::{
GetWorkflowExecutionHistoryResponse, RespondWorkflowTaskCompletedResponse,
},
},
test_utils::{query_ok, schedule_activity_cmd, start_timer_cmd},
};

#[rstest::rstest]
Expand Down
8 changes: 5 additions & 3 deletions crates/sdk-core/src/core_tests/replay_flag.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
use crate::{
test_help::{MockPollCfg, ResponseType, build_mock_pollers, hist_to_poll_resp, mock_worker},
replay::{TestHistoryBuilder, canned_histories},
test_help::{
MockPollCfg, ResponseType, build_mock_pollers, hist_to_poll_resp, mock_worker, query_ok,
start_timer_cmd,
},
worker::{LEGACY_QUERY_ID, client::mocks::mock_worker_client},
};
use std::{collections::VecDeque, time::Duration};
use temporalio_common::protos::{
TestHistoryBuilder, canned_histories,
coresdk::{
workflow_activation::{WorkflowActivationJob, workflow_activation_job},
workflow_completion::WorkflowActivationCompletion,
},
temporal::api::{enums::v1::EventType, query::v1::WorkflowQuery},
test_utils::{query_ok, start_timer_cmd},
};

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion crates/sdk-core/src/core_tests/updates.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::{
prost_dur,
replay::{DEFAULT_ACTIVITY_TYPE, TestHistoryBuilder},
test_help::{
MockPollCfg, PollWFTRespExt, ResponseType, WorkerTestHelpers, build_mock_pollers,
hist_to_poll_resp, mock_worker,
},
worker::client::mocks::mock_worker_client,
};
use temporalio_common::protos::{
DEFAULT_ACTIVITY_TYPE, TestHistoryBuilder,
coresdk::{
workflow_activation::{WorkflowActivationJob, workflow_activation_job},
workflow_commands::{
Expand Down
6 changes: 3 additions & 3 deletions crates/sdk-core/src/core_tests/workers.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::{
CompleteNexusError, PollError, prost_dur,
replay::canned_histories,
test_help::{
MockPollCfg, MockWorkerInputs, MocksHolder, QueueResponse, ResponseType, WorkerExt,
WorkerTestHelpers, build_fake_worker, build_mock_pollers, mock_worker, test_worker_cfg,
WorkerTestHelpers, build_fake_worker, build_mock_pollers, mock_worker, start_timer_cmd,
test_worker_cfg,
},
worker::{
self, PollerBehavior,
Expand All @@ -24,7 +26,6 @@ use temporalio_common::protos::temporal::api::{
};
use temporalio_common::{
protos::{
canned_histories,
coresdk::{
ActivityTaskCompletion,
activity_result::ActivityExecutionResult,
Expand Down Expand Up @@ -55,7 +56,6 @@ use temporalio_common::{
RespondWorkflowTaskCompletedResponse, ShutdownWorkerResponse,
},
},
test_utils::start_timer_cmd,
},
worker::WorkerTaskTypes,
};
Expand Down
15 changes: 6 additions & 9 deletions crates/sdk-core/src/core_tests/workflow_cancels.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use crate::{
job_assert,
replay::canned_histories,
test_help::{
ResponseType, WorkflowCachingPolicy::NonSticky, build_fake_worker, gen_assert_and_reply,
poll_and_reply,
poll_and_reply, start_timer_cmd,
},
};
use rstest::rstest;
use std::time::Duration;
use temporalio_common::protos::{
canned_histories,
coresdk::{
workflow_activation::{WorkflowActivationJob, workflow_activation_job},
workflow_commands::{
CancelWorkflowExecution, CompleteWorkflowExecution, FailWorkflowExecution,
},
use temporalio_common::protos::coresdk::{
workflow_activation::{WorkflowActivationJob, workflow_activation_job},
workflow_commands::{
CancelWorkflowExecution, CompleteWorkflowExecution, FailWorkflowExecution,
},
test_utils::start_timer_cmd,
};

enum CompletionType {
Expand Down
18 changes: 11 additions & 7 deletions crates/sdk-core/src/core_tests/workflow_tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ use crate::{
PollError, PollWorkflowOptions, Worker, advance_fut,
internal_flags::CoreInternalFlags,
job_assert,
replay::TestHistoryBuilder,
replay::{TestHistoryBuilder, canned_histories, default_act_sched, default_wes_attribs},
test_help::{
FakeWfResponses, MockPollCfg, MocksHolder, ResponseType, WorkerExt, WorkerTestHelpers,
WorkflowCachingPolicy::{self, AfterEveryReply, NonSticky},
build_fake_worker, build_mock_pollers, build_multihist_mock_sg, fanout_tasks,
gen_assert_and_fail, gen_assert_and_reply, hist_to_poll_resp, mock_worker, poll_and_reply,
poll_and_reply_clears_outstanding_evicts, single_hist_mock_sg, test_worker_cfg,
poll_and_reply_clears_outstanding_evicts, single_hist_mock_sg, start_timer_cmd,
test_worker_cfg,
},
worker::{
PollerBehavior, SlotMarkUsedContext, SlotReleaseContext, SlotReservationContext,
Expand All @@ -31,7 +32,6 @@ use std::{
use temporalio_client::MESSAGE_TOO_LARGE_KEY;
use temporalio_common::{
protos::{
canned_histories,
coresdk::{
activity_result::{self as ar, ActivityResolution, activity_resolution},
common::VersioningIntent,
Expand All @@ -47,7 +47,6 @@ use temporalio_common::{
},
workflow_completion::WorkflowActivationCompletion,
},
default_act_sched, default_wes_attribs,
temporal::api::{
command::v1::command::Attributes,
common::v1::{Payload, RetryPolicy},
Expand All @@ -61,7 +60,6 @@ use temporalio_common::{
GetWorkflowExecutionHistoryResponse, RespondWorkflowTaskCompletedResponse,
},
},
test_utils::start_timer_cmd,
},
worker::WorkerTaskTypes,
};
Expand Down Expand Up @@ -2391,7 +2389,13 @@ async fn lang_internal_flag_with_update() {
let mut t = TestHistoryBuilder::default();
t.add_by_type(EventType::WorkflowExecutionStarted);
t.add_full_wf_task();
t.set_flags_last_wft(&[1, 2], &[1]);
t.set_flags_last_wft(
&[
CoreInternalFlags::IdAndTypeDeterminismChecks,
CoreInternalFlags::UpsertSearchAttributeOnPatch,
],
&[1],
);
let updid = t.add_update_accepted("upd1", "upd");
t.add_update_completed(updid);
t.add_workflow_execution_completed();
Expand Down Expand Up @@ -2513,7 +2517,7 @@ async fn post_terminal_commands_are_retained_when_replaying_and_flag_set() {
t.add_full_wf_task();
t.add_timer_started("1".to_string());
t.add_workflow_execution_completed();
t.set_flags_last_wft(&[CoreInternalFlags::MoveTerminalCommands as u32], &[]);
t.set_flags_last_wft(&[CoreInternalFlags::MoveTerminalCommands], &[]);

let commands_sent_by_lang = vec![
CompleteWorkflowExecution { result: None }.into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::protos::{
TestHistoryBuilder,
use crate::replay::TestHistoryBuilder;
use prost::Message;
use rand::Rng;
use std::{fs::File, io::Write, path::PathBuf};
use temporalio_common::protos::{
coresdk::common::NamespacedWorkflowExecution,
temporal::api::{
common::v1::{Payload, WorkflowExecution},
Expand All @@ -8,9 +11,6 @@ use crate::protos::{
history::v1::*,
},
};
use prost::Message;
use rand::Rng;
use std::{fs::File, io::Write, path::PathBuf};

/// 1: EVENT_TYPE_WORKFLOW_EXECUTION_STARTED
/// 2: EVENT_TYPE_WORKFLOW_TASK_SCHEDULED
Expand Down
Loading
Loading