Skip to content

Commit

Permalink
workspace reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
weezy20 committed Feb 12, 2024
1 parent 412f9b1 commit 9413fb9
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 54 deletions.
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "cppvsdbg",
"request": "launch",
"name": "Debug cmd in executable 'kvs'",
"program": "${workspaceFolder}/target/debug/kvs.exe",
"args": [
"set",
"horseradish",
"clams"
],
"cwd": "${workspaceFolder}",
"preLaunchTask": "rust: cargo build",
},
]
}
21 changes: 21 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "rust: cargo build",
"type": "cargo",
"command": "build",
"args": [
// "--package kvs",
// "--bin kvs"
],
"options": {
"cwd": "${workspaceFolder}",
},
"problemMatcher": [
"$rustc"
],
"group": "build",
}
]
}
6 changes: 6 additions & 0 deletions Cargo.lock

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

61 changes: 10 additions & 51 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,24 @@
authors = ["Abhishek Shah <[email protected]>"]
description = "A key-value store called kvs"
edition = "2021"
name = "kvstore"
# licenses = ["MIT"]
version = "1.2.0"

[package]
authors.workspace = true
description = "A key-value store called kvs"
# licenses.workspace = true
edition = {workspace = true}
name = "kvs"
version = {workspace = true}
default-run = "kvs"

[[bin]]
description = "kvs cli to interact with kvs library"
name = "kvs"
path = "src/bin/main.rs"

[[bin]]
name = "kvs-client"
path = "crates/kvs-client/src/main.rs"

[[bin]]
name = "kvs-server"
path = "crates/kvs-server/src/main.rs"

[lib]
doctest = false
name = "kvs"
path = "src/lib.rs"
test = false
license = "MIT"
# https://doc.rust-lang.org/cargo/reference/workspaces.html

[workspace]
members = ["crates/kvs-client", "crates/kvs-server"]
resolver = "2"

[dependencies]
clap = {version = "4.1.6", features = ["derive"]}
dotenv = "0.15.0"
env_logger = "0.10.0"
lazy_static = "1.4.0"
log = "0.4.20"
ron = "0.8.1"
serde = {version = "1.0.188", features = ["derive"]}
serde_json = "1.0.104"
thiserror = "1.0.38"
members = ["crates/kvs-client", "crates/kvs-server", "lib"]
default-members = ["lib", "crates/kvs-client"]

[workspace.dependencies]
clap = {version = "4.1.6", features = ["derive"]}
clap = { version = "4.1.6", features = ["derive"] }
dotenv = "0.15.0"
env_logger = "0.10.0"
kvs = {path = "."}
kvs = { path = "lib" }
lazy_static = "1.4.0"
log = "0.4.20"
ron = "0.8.1"

[dev-dependencies]
assert_cmd = "0.11"
criterion = "0.3"
predicates = "1.0.0"
rand = "0.6.5"
tempfile = "3.0.7"
walkdir = "2.2.7"
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.104"
thiserror = "1.0.38"
15 changes: 12 additions & 3 deletions crates/kvs-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
[package]
name = "kvs-client"
version = { workspace = true }
version = { workspace = true }
edition = "2021"
authors = { workspace = true }
authors = { workspace = true }
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
kvs = { workspace = true }
clap = { workspace = true }
clap = { workspace = true }

[dev-dependencies]
assert_cmd = "0.11"
criterion = "0.3"
predicates = "1.0.0"
rand = "0.6.5"
tempfile = "3.0.7"
walkdir = "2.2.7"
15 changes: 15 additions & 0 deletions crates/kvs-client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
fn main() {
println!("Hello, world! from kvs client");
exit_program(0);
}
/// Non-zero exit code indicates a program error
fn exit_program(code: i32) -> ! {
std::process::exit(code)
}

#[derive(Debug, clap::Parser)]
struct Cli {
#[arg(short, long)]
get: String,
#[arg(short, long)]
set: String,
#[arg(short, long)]
rm: String,
}
File renamed without changes.
29 changes: 29 additions & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "kvs"
authors.workspace = true
description.workspace = true
edition = { workspace = true }
version = { workspace = true }

[[bin]]
name = "kvs"
path = "src/bin/main.rs"

[dependencies]
clap = { version = "4.1.6", features = ["derive"] }
dotenv = "0.15.0"
env_logger = "0.10.0"
lazy_static = "1.4.0"
log = "0.4.20"
ron = "0.8.1"
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.104"
thiserror = "1.0.38"

[dev-dependencies]
assert_cmd = "0.11"
criterion = "0.3"
predicates = "1.0.0"
rand = "0.6.5"
tempfile = "3.0.7"
walkdir = "2.2.7"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions tests/kv_store.rs → lib/tests/kv_store.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unused_mut)]

use kvs::{KvStore, KvsEngine, Result};
use tempfile::TempDir;
use walkdir::WalkDir;
Expand Down Expand Up @@ -82,6 +84,7 @@ fn remove_key() -> Result<()> {
// Insert data until total size of the directory decreases.
// Test data correctness after compaction.
#[test]
#[ignore = "takes a while"]
fn compaction() -> Result<()> {
let temp_dir = TempDir::new().expect("unable to create temporary working directory");
let mut store = KvStore::open(temp_dir.path())?;
Expand Down

0 comments on commit 9413fb9

Please sign in to comment.