Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add turmoil based simulation support #112

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
xtask = "run --manifest-path ./xtask/Cargo.toml --"

# Uncomment the lines below to allow your IDE to be in sim mode
# [build]
# rustflags = ["--cfg", "tokio_unstable", "--cfg", "sim"]
167 changes: 148 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,21 @@ opentelemetry-aws = { version = "0.5.0", optional = true }
# Allows you to send data to the OTel collector
opentelemetry-otlp = { version = "0.10.0", optional = true }

# TODO: Make this cfg dep
turmoil = "0.3"

[dev-dependencies]
# Enable test-utilities in dev mode only. This is mostly for tests.
tokio = { version = "1", features = ["test-util"] }

[features]
otel = ["dep:opentelemetry", "dep:tracing-opentelemetry", "dep:opentelemetry-aws", "dep:opentelemetry-otlp"]

[workspace]
members = [
".",
"xtask"
]

[patch.crates-io]
turmoil = { path = "../turmoil" }
6 changes: 6 additions & 0 deletions src/bin/cli.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(sim, allow(dead_code, unused_imports))]

use mini_redis::{client, DEFAULT_PORT};

use bytes::Bytes;
Expand Down Expand Up @@ -64,6 +66,9 @@ enum Command {
},
}

#[cfg(sim)]
fn main() {}

/// Entry point for CLI tool.
///
/// The `[tokio::main]` annotation signals that the Tokio runtime should be
Expand All @@ -73,6 +78,7 @@ enum Command {
/// `flavor = "current_thread"` is used here to avoid spawning background
/// threads. The CLI tool use case benefits more by being lighter instead of
/// multi-threaded.
#[cfg(not(sim))]
#[tokio::main(flavor = "current_thread")]
async fn main() -> mini_redis::Result<()> {
// Enable logging
Expand Down
Loading