Skip to content

Commit

Permalink
modify rust package structure (#2586)
Browse files Browse the repository at this point in the history
* modify rust package structure

Signed-off-by: Kosuke Morimoto <[email protected]>

* format

Signed-off-by: Kosuke Morimoto <[email protected]>

---------

Signed-off-by: Kosuke Morimoto <[email protected]>
Co-authored-by: Yusuke Kato <[email protected]>
  • Loading branch information
kmrmt and kpango authored Aug 30, 2024
1 parent e633c91 commit b17cc73
Show file tree
Hide file tree
Showing 14 changed files with 367 additions and 78 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"
7 changes: 3 additions & 4 deletions rust/libs/ngt/Cargo.toml → rust/libs/algorithm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
# limitations under the License.
#
[package]
name = "ngt"
name = "algorithm"
version = "0.1.0"
edition = "2021"

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

[dependencies]
ngt-rs = { version = "0.1.0", path = "../ngt-rs" }
faiss = { version = "0.1.0", path = "../algorithms/faiss" }
ngt = { version = "0.1.0", path = "../algorithms/ngt" }
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
pub fn add(left: usize, right: usize) -> usize {
pub fn add(left: u64, right: u64) -> u64 {
left + right
}

Expand Down
21 changes: 21 additions & 0 deletions rust/libs/algorithms/faiss/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
[package]
name = "faiss"
version = "0.1.0"
edition = "2021"

[dependencies]
29 changes: 29 additions & 0 deletions rust/libs/algorithms/faiss/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
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
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 b17cc73

Please sign in to comment.