diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 5c22f41ebf..a41a430640 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -21,12 +21,20 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" name = "agent" version = "0.1.0" dependencies = [ - "ngt", - "prost", + "algorithm", + "prost 0.13.1", "proto", "tokio", "tokio-stream", - "tonic", + "tonic 0.12.1", +] + +[[package]] +name = "algorithm" +version = "0.1.0" +dependencies = [ + "faiss", + "ngt", ] [[package]] @@ -68,6 +76,12 @@ dependencies = [ "syn", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.3.0" @@ -81,13 +95,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core", + "axum-core 0.3.4", "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.30", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 0.1.2", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +dependencies = [ + "async-trait", + "axum-core 0.4.3", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "itoa", "matchit", "memchr", @@ -96,7 +137,7 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper", + "sync_wrapper 1.0.1", "tower", "tower-layer", "tower-service", @@ -111,10 +152,30 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", ] @@ -149,6 +210,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bitflags" version = "1.3.2" @@ -295,6 +362,10 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "faiss" +version = "0.1.0" + [[package]] name = "fnv" version = "1.0.7" @@ -416,7 +487,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", + "indexmap 2.4.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", "indexmap 2.4.0", "slab", "tokio", @@ -453,6 +543,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -460,7 +561,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", "pin-project-lite", ] @@ -486,9 +610,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -500,18 +624,72 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-timeout" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.30", "pin-project-lite", "tokio", "tokio-io-timeout", ] +[[package]] +name = "hyper-timeout" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +dependencies = [ + "hyper 1.4.1", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.4.1", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "idna" version = "0.5.0" @@ -563,6 +741,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -694,13 +881,6 @@ dependencies = [ [[package]] name = "ngt" version = "0.1.0" -dependencies = [ - "ngt-rs", -] - -[[package]] -name = "ngt-rs" -version = "0.1.0" dependencies = [ "anyhow", "cxx", @@ -771,7 +951,7 @@ checksum = "b0ba633e55c5ea6f431875ba55e71664f2fa5d3a90bd34ec9302eecc41c865dd" dependencies = [ "async-trait", "bytes", - "http", + "http 0.2.12", "opentelemetry", "reqwest", ] @@ -784,16 +964,16 @@ checksum = "a94c69209c05319cdf7460c6d4c055ed102be242a0a6245835d7bc42c6ec7f54" dependencies = [ "async-trait", "futures-core", - "http", + "http 0.2.12", "opentelemetry", "opentelemetry-http", "opentelemetry-proto", "opentelemetry_sdk", - "prost", + "prost 0.12.6", "reqwest", "thiserror", "tokio", - "tonic", + "tonic 0.11.0", ] [[package]] @@ -804,8 +984,8 @@ checksum = "984806e6cf27f2b49282e2a05e288f30594f3dbc74eb7a6e99422bc48ed78162" dependencies = [ "opentelemetry", "opentelemetry_sdk", - "prost", - "tonic", + "prost 0.12.6", + "tonic 0.11.0", ] [[package]] @@ -944,7 +1124,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.12.6", +] + +[[package]] +name = "prost" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" +dependencies = [ + "bytes", + "prost-derive 0.13.1", ] [[package]] @@ -954,7 +1144,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-derive" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" +dependencies = [ + "anyhow", + "itertools 0.13.0", "proc-macro2", "quote", "syn", @@ -962,11 +1165,11 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" dependencies = [ - "prost", + "prost 0.13.1", ] [[package]] @@ -974,8 +1177,8 @@ name = "proto" version = "0.1.0" dependencies = [ "futures-core", - "prost", - "tonic", + "prost 0.13.1", + "tonic 0.12.1", "tonic-types", ] @@ -1033,15 +1236,15 @@ version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ - "base64", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.30", "ipnet", "js-sys", "log", @@ -1052,7 +1255,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", "tower-service", @@ -1234,6 +1437,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "system-configuration" version = "0.5.1" @@ -1392,17 +1601,47 @@ checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" dependencies = [ "async-stream", "async-trait", - "axum", - "base64", + "axum 0.6.20", + "base64 0.21.7", "bytes", - "h2", - "http", - "http-body", - "hyper", - "hyper-timeout", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.30", + "hyper-timeout 0.4.1", "percent-encoding", "pin-project", - "prost", + "prost 0.12.6", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" +dependencies = [ + "async-stream", + "async-trait", + "axum 0.7.5", + "base64 0.22.1", + "bytes", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", + "hyper-timeout 0.5.1", + "hyper-util", + "percent-encoding", + "pin-project", + "prost 0.13.1", + "socket2", "tokio", "tokio-stream", "tower", @@ -1413,13 +1652,13 @@ dependencies = [ [[package]] name = "tonic-types" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4aa089471d8d4c60ec3aef047739713a4695f0b309d4cea0073bc55201064f4" +checksum = "5563899ec5aa5f0ec48e37457461ffbbc184c9a0f413f715dacd154f46408a10" dependencies = [ - "prost", + "prost 0.13.1", "prost-types", - "tonic", + "tonic 0.12.1", ] [[package]] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 1c1c581bb1..7ab97dd32b 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -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", ] diff --git a/rust/bin/agent/Cargo.toml b/rust/bin/agent/Cargo.toml index fdfce09733..7e11dd94d6 100644 --- a/rust/bin/agent/Cargo.toml +++ b/rust/bin/agent/Cargo.toml @@ -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" diff --git a/rust/libs/ngt/Cargo.toml b/rust/libs/algorithm/Cargo.toml similarity index 80% rename from rust/libs/ngt/Cargo.toml rename to rust/libs/algorithm/Cargo.toml index 59a5530b8c..c4ca71aef8 100644 --- a/rust/libs/ngt/Cargo.toml +++ b/rust/libs/algorithm/Cargo.toml @@ -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" } diff --git a/rust/libs/ngt/src/lib.rs b/rust/libs/algorithm/src/lib.rs similarity index 94% rename from rust/libs/ngt/src/lib.rs rename to rust/libs/algorithm/src/lib.rs index 958ec94a9e..cdca5d93de 100644 --- a/rust/libs/ngt/src/lib.rs +++ b/rust/libs/algorithm/src/lib.rs @@ -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 } diff --git a/rust/libs/algorithms/faiss/Cargo.toml b/rust/libs/algorithms/faiss/Cargo.toml new file mode 100644 index 0000000000..bfe824b11e --- /dev/null +++ b/rust/libs/algorithms/faiss/Cargo.toml @@ -0,0 +1,21 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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] diff --git a/rust/libs/algorithms/faiss/src/lib.rs b/rust/libs/algorithms/faiss/src/lib.rs new file mode 100644 index 0000000000..cdca5d93de --- /dev/null +++ b/rust/libs/algorithms/faiss/src/lib.rs @@ -0,0 +1,29 @@ +// +// Copyright (C) 2019-2024 vdaas.org vald team +// +// 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); + } +} diff --git a/rust/libs/ngt-rs/Cargo.toml b/rust/libs/algorithms/ngt/Cargo.toml similarity index 81% rename from rust/libs/ngt-rs/Cargo.toml rename to rust/libs/algorithms/ngt/Cargo.toml index 7caa2b26a0..64517bf474 100644 --- a/rust/libs/ngt-rs/Cargo.toml +++ b/rust/libs/algorithms/ngt/Cargo.toml @@ -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" diff --git a/rust/libs/ngt-rs/build.rs b/rust/libs/algorithms/ngt/build.rs similarity index 100% rename from rust/libs/ngt-rs/build.rs rename to rust/libs/algorithms/ngt/build.rs diff --git a/rust/libs/ngt-rs/src/input.cpp b/rust/libs/algorithms/ngt/src/input.cpp similarity index 98% rename from rust/libs/ngt-rs/src/input.cpp rename to rust/libs/algorithms/ngt/src/input.cpp index 7e35fbd91d..c956f6da33 100644 --- a/rust/libs/ngt-rs/src/input.cpp +++ b/rust/libs/algorithms/ngt/src/input.cpp @@ -14,8 +14,8 @@ // limitations under the License. // #include -#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() {} diff --git a/rust/libs/ngt-rs/src/input.h b/rust/libs/algorithms/ngt/src/input.h similarity index 100% rename from rust/libs/ngt-rs/src/input.h rename to rust/libs/algorithms/ngt/src/input.h diff --git a/rust/libs/ngt-rs/src/lib.rs b/rust/libs/algorithms/ngt/src/lib.rs similarity index 99% rename from rust/libs/ngt-rs/src/lib.rs rename to rust/libs/algorithms/ngt/src/lib.rs index 951faff333..8474a3ee0c 100644 --- a/rust/libs/ngt-rs/src/lib.rs +++ b/rust/libs/algorithms/ngt/src/lib.rs @@ -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; diff --git a/rust/libs/observability/Cargo.toml b/rust/libs/observability/Cargo.toml index 4ef91d715e..1ef800cefb 100644 --- a/rust/libs/observability/Cargo.toml +++ b/rust/libs/observability/Cargo.toml @@ -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"} diff --git a/rust/libs/proto/Cargo.toml b/rust/libs/proto/Cargo.toml index 72ea9d88f0..12a488941d 100644 --- a/rust/libs/proto/Cargo.toml +++ b/rust/libs/proto/Cargo.toml @@ -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"