Skip to content

Commit

Permalink
modify rust package structure
Browse files Browse the repository at this point in the history
Signed-off-by: Kosuke Morimoto <[email protected]>
  • Loading branch information
kmrmt committed Aug 22, 2024
1 parent 4560a2b commit 42f548b
Show file tree
Hide file tree
Showing 16 changed files with 355 additions and 126 deletions.
347 changes: 293 additions & 54 deletions rust/Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
#
[workspace]
members = [
"libs/ngt",
"libs/ngt-rs",
"libs/observability",
"libs/proto",
"bin/agent",
"libs/algorithm",
"libs/algorithms/ngt",
"libs/algorithms/faiss",
]
8 changes: 4 additions & 4 deletions rust/bin/agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ngt = { version = "0.1.0", path = "../../libs/ngt" }
prost = "0.12.4"
algorithm = { version = "0.1.0", path = "../../libs/algorithm" }
prost = "0.13.1"
proto = { version = "0.1.0", path = "../../libs/proto" }
tokio = { version = "1.37.0", features = ["full"] }
tokio = { version = "1.39.3", features = ["full"] }
tokio-stream = { version = "0.1.15", features = ["full"] }
tonic = "0.11.0"
tonic = "0.12.1"
8 changes: 8 additions & 0 deletions rust/libs/algorithm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "algorithm"
version = "0.1.0"
edition = "2021"

[dependencies]
faiss = { version = "0.1.0", path = "../algorithms/faiss" }
ngt = { version = "0.1.0", path = "../algorithms/ngt" }
14 changes: 14 additions & 0 deletions rust/libs/algorithm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: u64, right: u64) -> u64 {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
6 changes: 6 additions & 0 deletions rust/libs/algorithms/faiss/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "faiss"
version = "0.1.0"
edition = "2021"

[dependencies]
14 changes: 14 additions & 0 deletions rust/libs/algorithms/faiss/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: u64, right: u64) -> u64 {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
# limitations under the License.
#
[package]
name = "ngt-rs"
name = "ngt"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.81"
cxx = { version = "1.0.117", features = ["c++20"] }
anyhow = "1.0.86"
cxx = { version = "1.0.126", features = ["c++20"] }

[build-dependencies]
cxx-build = "1.0.117"
miette = { version = "7.1.0", features = ["fancy"] }
cxx-build = "1.0.126"
miette = { version = "7.2.0", features = ["fancy"] }

[dev-dependencies]
rand = "0.8.5"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// limitations under the License.
//
#include <vector>
#include "ngt-rs/src/input.h"
#include "ngt-rs/src/lib.rs.h"
#include "ngt/src/input.h"
#include "ngt/src/lib.rs.h"

Property::Property(): p() {}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub mod ffi {
}

unsafe extern "C++" {
include!("ngt-rs/src/input.h");
include!("ngt/src/input.h");

type Property;
fn new_property() -> UniquePtr<Property>;
Expand Down
24 changes: 0 additions & 24 deletions rust/libs/ngt/Cargo.toml

This file was deleted.

29 changes: 0 additions & 29 deletions rust/libs/ngt/src/lib.rs

This file was deleted.

4 changes: 2 additions & 2 deletions rust/libs/observability/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ edition = "2021"
opentelemetry = { version = "0.23" }
opentelemetry_sdk = { version = "0.23", features = ["rt-tokio"] }
opentelemetry-otlp = { version = "0.16.0", features = ["http-proto", "reqwest-client", "logs"] }
tokio = { version = "1.38.0", features = ["full"] }
serde_json = { version="1.0.120" }
tokio = { version = "1.39.3", features = ["full"] }
serde_json = { version="1.0.125" }
opentelemetry-semantic-conventions = { version = "0.16.0"}
scopeguard = { version = "1.2.0"}
paste = {version = "1.0.15"}
Expand Down
6 changes: 3 additions & 3 deletions rust/libs/proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ edition = "2021"

[dependencies]
futures-core = "0.3.30"
prost = "0.12.3"
tonic = "0.11.0"
tonic-types = "0.11.0"
prost = "0.13.1"
tonic = "0.12.1"
tonic-types = "0.12.1"

0 comments on commit 42f548b

Please sign in to comment.