From 828e8cd48c0e8022426c2b3d7a11826aa4df9edb Mon Sep 17 00:00:00 2001 From: Innes Anderson-Morrison Date: Mon, 23 Sep 2024 16:38:19 +0100 Subject: [PATCH] refactor: restructuring as a monorepo for the rewrite --- Cargo.lock | 859 +++++++++++++++++- Cargo.toml | 61 +- TODO | 25 - crates/ratings/Cargo.toml | 60 ++ build.rs => crates/ratings/build.rs | 28 +- .../20230829085908_ratings_init.down.sql | 0 .../20230829085908_ratings_init.up.sql | 0 .../20240208071037_categories.up.sql | 0 {src => crates/ratings/src}/app/context.rs | 0 .../app/interfaces/authentication/admin.rs | 0 .../src}/app/interfaces/authentication/jwt.rs | 0 .../src}/app/interfaces/authentication/mod.rs | 0 .../ratings/src}/app/interfaces/errors.rs | 0 .../ratings/src}/app/interfaces/middleware.rs | 0 .../ratings/src}/app/interfaces/mod.rs | 0 .../src}/app/interfaces/servers/grpc.rs | 0 .../src}/app/interfaces/servers/mod.rs | 0 .../src}/app/interfaces/servers/rest.rs | 0 {src => crates/ratings/src}/app/mod.rs | 0 {src => crates/ratings/src}/app/run.rs | 0 .../features/admin/api_version/interface.rs | 0 .../src}/features/admin/api_version/mod.rs | 0 .../features/admin/api_version/service/mod.rs | 0 .../admin/api_version/service/rest.rs | 0 .../features/admin/log_level/interface.rs | 0 .../src}/features/admin/log_level/mod.rs | 0 .../features/admin/log_level/service/mod.rs | 0 .../features/admin/log_level/service/rest.rs | 0 .../ratings/src}/features/admin/mod.rs | 0 .../ratings/src}/features/chart/entities.rs | 0 .../ratings/src}/features/chart/errors.rs | 0 .../src}/features/chart/infrastructure.rs | 0 .../ratings/src}/features/chart/mod.rs | 0 .../src}/features/chart/service/grpc.rs | 0 .../src}/features/chart/service/mod.rs | 0 .../ratings/src}/features/chart/use_cases.rs | 0 .../ratings/src}/features/common/entities.rs | 0 .../ratings/src}/features/common/mod.rs | 0 {src => crates/ratings/src}/features/mod.rs | 0 {src => crates/ratings/src}/features/pb.rs | 12 +- .../ratings/src}/features/rating/errors.rs | 0 .../src}/features/rating/infrastructure.rs | 0 .../ratings/src}/features/rating/mod.rs | 0 .../src}/features/rating/service/grpc.rs | 0 .../src}/features/rating/service/mod.rs | 0 .../ratings/src}/features/rating/use_cases.rs | 0 .../ratings/src}/features/user/entities.rs | 0 .../ratings/src}/features/user/errors.rs | 0 .../src}/features/user/infrastructure.rs | 0 .../ratings/src}/features/user/mod.rs | 0 .../src}/features/user/service/grpc.rs | 0 .../ratings/src}/features/user/service/mod.rs | 0 .../ratings/src}/features/user/use_cases.rs | 0 {src => crates/ratings/src}/lib.rs | 0 {src => crates/ratings/src}/main.rs | 0 .../ratings/src/proto/ratings.features.app.rs | 304 +++++++ .../src/proto/ratings.features.chart.rs | 432 +++++++++ .../src/proto/ratings.features.common.rs | 49 + .../src/proto/ratings.features.user.rs | 639 +++++++++++++ {src => crates/ratings/src}/utils/config.rs | 0 .../ratings/src}/utils/infrastructure.rs | 0 {src => crates/ratings/src}/utils/jwt.rs | 0 {src => crates/ratings/src}/utils/log_util.rs | 0 {src => crates/ratings/src}/utils/migrator.rs | 0 {src => crates/ratings/src}/utils/mod.rs | 0 crates/ratings_new/Cargo.lock | 7 + crates/ratings_new/Cargo.toml | 19 + crates/ratings_new/src/db/mod.rs | 0 crates/ratings_new/src/db/user.rs | 0 crates/ratings_new/src/db/vote.rs | 16 + crates/ratings_new/src/grpc/app.rs | 0 crates/ratings_new/src/grpc/charts.rs | 0 crates/ratings_new/src/grpc/mod.rs | 0 crates/ratings_new/src/grpc/user.rs | 0 crates/ratings_new/src/lib.rs | 0 crates/ratings_new/src/main.rs | 3 + crates/ratings_new/src/middleware.rs | 0 77 files changed, 2356 insertions(+), 158 deletions(-) delete mode 100644 TODO create mode 100644 crates/ratings/Cargo.toml rename build.rs => crates/ratings/build.rs (62%) rename {sql => crates/ratings/sql}/migrations/20230829085908_ratings_init.down.sql (100%) rename {sql => crates/ratings/sql}/migrations/20230829085908_ratings_init.up.sql (100%) rename {sql => crates/ratings/sql}/migrations/20240208071037_categories.up.sql (100%) rename {src => crates/ratings/src}/app/context.rs (100%) rename {src => crates/ratings/src}/app/interfaces/authentication/admin.rs (100%) rename {src => crates/ratings/src}/app/interfaces/authentication/jwt.rs (100%) rename {src => crates/ratings/src}/app/interfaces/authentication/mod.rs (100%) rename {src => crates/ratings/src}/app/interfaces/errors.rs (100%) rename {src => crates/ratings/src}/app/interfaces/middleware.rs (100%) rename {src => crates/ratings/src}/app/interfaces/mod.rs (100%) rename {src => crates/ratings/src}/app/interfaces/servers/grpc.rs (100%) rename {src => crates/ratings/src}/app/interfaces/servers/mod.rs (100%) rename {src => crates/ratings/src}/app/interfaces/servers/rest.rs (100%) rename {src => crates/ratings/src}/app/mod.rs (100%) rename {src => crates/ratings/src}/app/run.rs (100%) rename {src => crates/ratings/src}/features/admin/api_version/interface.rs (100%) rename {src => crates/ratings/src}/features/admin/api_version/mod.rs (100%) rename {src => crates/ratings/src}/features/admin/api_version/service/mod.rs (100%) rename {src => crates/ratings/src}/features/admin/api_version/service/rest.rs (100%) rename {src => crates/ratings/src}/features/admin/log_level/interface.rs (100%) rename {src => crates/ratings/src}/features/admin/log_level/mod.rs (100%) rename {src => crates/ratings/src}/features/admin/log_level/service/mod.rs (100%) rename {src => crates/ratings/src}/features/admin/log_level/service/rest.rs (100%) rename {src => crates/ratings/src}/features/admin/mod.rs (100%) rename {src => crates/ratings/src}/features/chart/entities.rs (100%) rename {src => crates/ratings/src}/features/chart/errors.rs (100%) rename {src => crates/ratings/src}/features/chart/infrastructure.rs (100%) rename {src => crates/ratings/src}/features/chart/mod.rs (100%) rename {src => crates/ratings/src}/features/chart/service/grpc.rs (100%) rename {src => crates/ratings/src}/features/chart/service/mod.rs (100%) rename {src => crates/ratings/src}/features/chart/use_cases.rs (100%) rename {src => crates/ratings/src}/features/common/entities.rs (100%) rename {src => crates/ratings/src}/features/common/mod.rs (100%) rename {src => crates/ratings/src}/features/mod.rs (100%) rename {src => crates/ratings/src}/features/pb.rs (65%) rename {src => crates/ratings/src}/features/rating/errors.rs (100%) rename {src => crates/ratings/src}/features/rating/infrastructure.rs (100%) rename {src => crates/ratings/src}/features/rating/mod.rs (100%) rename {src => crates/ratings/src}/features/rating/service/grpc.rs (100%) rename {src => crates/ratings/src}/features/rating/service/mod.rs (100%) rename {src => crates/ratings/src}/features/rating/use_cases.rs (100%) rename {src => crates/ratings/src}/features/user/entities.rs (100%) rename {src => crates/ratings/src}/features/user/errors.rs (100%) rename {src => crates/ratings/src}/features/user/infrastructure.rs (100%) rename {src => crates/ratings/src}/features/user/mod.rs (100%) rename {src => crates/ratings/src}/features/user/service/grpc.rs (100%) rename {src => crates/ratings/src}/features/user/service/mod.rs (100%) rename {src => crates/ratings/src}/features/user/use_cases.rs (100%) rename {src => crates/ratings/src}/lib.rs (100%) rename {src => crates/ratings/src}/main.rs (100%) create mode 100644 crates/ratings/src/proto/ratings.features.app.rs create mode 100644 crates/ratings/src/proto/ratings.features.chart.rs create mode 100644 crates/ratings/src/proto/ratings.features.common.rs create mode 100644 crates/ratings/src/proto/ratings.features.user.rs rename {src => crates/ratings/src}/utils/config.rs (100%) rename {src => crates/ratings/src}/utils/infrastructure.rs (100%) rename {src => crates/ratings/src}/utils/jwt.rs (100%) rename {src => crates/ratings/src}/utils/log_util.rs (100%) rename {src => crates/ratings/src}/utils/migrator.rs (100%) rename {src => crates/ratings/src}/utils/mod.rs (100%) create mode 100644 crates/ratings_new/Cargo.lock create mode 100644 crates/ratings_new/Cargo.toml create mode 100644 crates/ratings_new/src/db/mod.rs create mode 100644 crates/ratings_new/src/db/user.rs create mode 100644 crates/ratings_new/src/db/vote.rs create mode 100644 crates/ratings_new/src/grpc/app.rs create mode 100644 crates/ratings_new/src/grpc/charts.rs create mode 100644 crates/ratings_new/src/grpc/mod.rs create mode 100644 crates/ratings_new/src/grpc/user.rs create mode 100644 crates/ratings_new/src/lib.rs create mode 100644 crates/ratings_new/src/main.rs create mode 100644 crates/ratings_new/src/middleware.rs diff --git a/Cargo.lock b/Cargo.lock index 12bd2801..d5e2cd93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,6 +59,55 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +dependencies = [ + "anstyle", + "windows-sys 0.59.0", +] + [[package]] name = "anyhow" version = "1.0.89" @@ -138,7 +187,7 @@ 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", @@ -158,7 +207,34 @@ dependencies = [ "serde_urlencoded", "sync_wrapper 0.1.2", "tokio", - "tower", + "tower 0.4.13", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f43644eed690f5374f1af436ecd6aea01cd201f6fbdf0178adaf6907afb2cec" +dependencies = [ + "async-trait", + "axum-core 0.4.4", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 1.0.1", + "tower 0.5.1", "tower-layer", "tower-service", ] @@ -180,6 +256,26 @@ dependencies = [ "tower-service", ] +[[package]] +name = "axum-core" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6b8ba012a258d63c9adfa28b9ddcf66149da6f986c5b5452e629d5ee64bf00" +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 1.0.1", + "tower-layer", + "tower-service", +] + [[package]] name = "backtrace" version = "0.3.73" @@ -246,12 +342,28 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bstr" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "bumpalo" version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "bytecount" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" + [[package]] name = "byteorder" version = "1.5.0" @@ -289,11 +401,60 @@ checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", "serde", + "wasm-bindgen", "windows-targets 0.52.6", ] +[[package]] +name = "clap" +version = "4.5.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", + "terminal_size", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" + +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + [[package]] name = "concurrent-queue" version = "2.5.0" @@ -303,6 +464,19 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.52.0", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -349,6 +523,25 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-queue" version = "0.3.11" @@ -374,6 +567,92 @@ dependencies = [ "typenum", ] +[[package]] +name = "cucumber" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5063d8cf24f4998ad01cac265da468a15ca682a8f4f826d50e661964e8d9b8" +dependencies = [ + "anyhow", + "async-trait", + "clap", + "console", + "crossbeam-utils", + "cucumber-codegen", + "cucumber-expressions", + "derive_more", + "drain_filter_polyfill", + "either", + "futures", + "gherkin", + "globwalk", + "humantime", + "inventory", + "itertools", + "lazy-regex", + "linked-hash-map", + "once_cell", + "pin-project", + "regex", + "sealed", + "serde", + "serde_json", + "smart-default", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "cucumber-codegen" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01091e28d1f566c8b31b67948399d2efd6c0a8f6228a9785519ed7b73f7f0aef" +dependencies = [ + "cucumber-expressions", + "inflections", + "itertools", + "proc-macro2", + "quote", + "regex", + "syn", + "synthez", +] + +[[package]] +name = "cucumber-expressions" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d794fed319eea24246fb5f57632f7ae38d61195817b7eb659455aa5bdd7c1810" +dependencies = [ + "derive_more", + "either", + "nom", + "nom_locate", + "regex", + "regex-syntax 0.7.5", +] + +[[package]] +name = "deadpool" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb84100978c1c7b37f09ed3ce3e5f843af02c2a2c431bae5b19230dad2c1b490" +dependencies = [ + "async-trait", + "deadpool-runtime", + "num_cpus", + "tokio", +] + +[[package]] +name = "deadpool-runtime" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b" +dependencies = [ + "tokio", +] + [[package]] name = "der" version = "0.7.9" @@ -394,6 +673,17 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "derive_more" +version = "0.99.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "digest" version = "0.10.7" @@ -412,6 +702,12 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "drain_filter_polyfill" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "669a445ee724c5c69b1b06fe0b63e70a1c84bc9bb7d9696cd4f4e3ec45050408" + [[package]] name = "either" version = "1.13.0" @@ -421,6 +717,12 @@ dependencies = [ "serde", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "encoding_rs" version = "0.8.34" @@ -659,6 +961,23 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gherkin" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20b79820c0df536d1f3a089a2fa958f61cb96ce9e0f3f8f507f5a31179567755" +dependencies = [ + "heck 0.4.1", + "peg", + "quote", + "serde", + "serde_json", + "syn", + "textwrap", + "thiserror", + "typed-builder", +] + [[package]] name = "gimli" version = "0.29.0" @@ -678,6 +997,30 @@ dependencies = [ "url", ] +[[package]] +name = "globset" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", +] + +[[package]] +name = "globwalk" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" +dependencies = [ + "bitflags 1.3.2", + "ignore", + "walkdir", +] + [[package]] name = "h2" version = "0.3.26" @@ -741,6 +1084,12 @@ dependencies = [ "hashbrown 0.14.5", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "heck" version = "0.5.0" @@ -854,6 +1203,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.14.30" @@ -891,6 +1246,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -927,6 +1283,19 @@ dependencies = [ "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-tls" version = "0.6.0" @@ -958,7 +1327,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", + "tower 0.4.13", "tower-service", "tracing", ] @@ -996,6 +1365,22 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "ignore" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata 0.4.7", + "same-file", + "walkdir", + "winapi-util", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -1016,12 +1401,30 @@ dependencies = [ "hashbrown 0.14.5", ] +[[package]] +name = "inflections" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a" + +[[package]] +name = "inventory" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f958d3d68f4167080a18141e10381e7634563984a537f2a49a30fd8e53ac5767" + [[package]] name = "ipnet" version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.12.1" @@ -1070,6 +1473,29 @@ dependencies = [ "simple_asn1", ] +[[package]] +name = "lazy-regex" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d8e41c97e6bc7ecb552016274b99fbb5d035e8de288c582d9b933af6677bfda" +dependencies = [ + "lazy-regex-proc_macros", + "once_cell", + "regex", +] + +[[package]] +name = "lazy-regex-proc_macros" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76e1d8b05d672c53cb9c7b920bbba8783845ae4f0b076e02a3db1d02c81b4163" +dependencies = [ + "proc-macro2", + "quote", + "regex", + "syn", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -1126,6 +1552,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1248,6 +1680,17 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nom_locate" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e3c83c053b0713da60c5b8de47fe8e494fe3ece5267b2f23090a07a053ba8f3" +dependencies = [ + "bytecount", + "memchr", + "nom", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -1321,6 +1764,16 @@ dependencies = [ "libm", ] +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "object" version = "0.36.3" @@ -1432,6 +1885,33 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "peg" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f76678828272f177ac33b7e2ac2e3e73cc6c1cd1e3e387928aa69562fa51367" +dependencies = [ + "peg-macros", + "peg-runtime", +] + +[[package]] +name = "peg-macros" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "636d60acf97633e48d266d7415a9355d4389cea327a193f87df395d88cd2b14d" +dependencies = [ + "peg-runtime", + "proc-macro2", + "quote", +] + +[[package]] +name = "peg-runtime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9555b1514d2d99d78150d3c799d4c357a3e2c2a8062cd108e93a06d9057629c5" + [[package]] name = "pem" version = "3.0.4" @@ -1614,7 +2094,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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" +dependencies = [ + "bytes", + "prost-derive 0.13.3", ] [[package]] @@ -1624,15 +2114,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", - "heck", + "heck 0.5.0", "itertools", "log", "multimap", "once_cell", "petgraph", "prettyplease", - "prost", - "prost-types", + "prost 0.12.6", + "prost-types 0.12.6", "regex", "syn", "tempfile", @@ -1651,13 +2141,35 @@ dependencies = [ "syn", ] +[[package]] +name = "prost-derive" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "prost-types" version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "prost", + "prost 0.12.6", +] + +[[package]] +name = "prost-types" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" +dependencies = [ + "prost 0.13.3", ] [[package]] @@ -1703,11 +2215,11 @@ dependencies = [ name = "ratings" version = "0.0.3" dependencies = [ - "anyhow", "argon2", - "axum", + "axum 0.6.20", "base64 0.22.1", "chrono", + "cucumber", "dotenvy", "envy", "futures", @@ -1719,8 +2231,8 @@ dependencies = [ "lazy_static", "log", "once_cell", - "prost", - "prost-types", + "prost 0.12.6", + "prost-types 0.12.6", "rand", "regex", "reqwest", @@ -1728,17 +2240,34 @@ dependencies = [ "serde", "serde_json", "sha2", - "simple_test_case", + "snapd", "sqlx", "strum", "thiserror", "time", "tokio", "tokio-postgres", - "tonic", + "tonic 0.10.2", "tonic-build", - "tonic-reflection", - "tower", + "tonic-reflection 0.10.2", + "tower 0.4.13", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "ratings_new" +version = "0.1.0" +dependencies = [ + "chrono", + "prost 0.13.3", + "prost-types 0.13.3", + "simple_test_case", + "sqlx", + "thiserror", + "tokio", + "tonic 0.12.2", + "tonic-reflection 0.12.2", "tracing", "tracing-subscriber", ] @@ -1799,6 +2328,12 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + [[package]] name = "regex-syntax" version = "0.8.4" @@ -1955,6 +2490,15 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.23" @@ -1970,6 +2514,18 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sealed" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a8caec23b7800fb97971a1c6ae365b6239aaeddfb934d6265f8505e795699d" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "secrecy" version = "0.8.0" @@ -2160,6 +2716,41 @@ dependencies = [ "serde", ] +[[package]] +name = "smart-default" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eb01866308440fc64d6c44d9e86c5cc17adfe33c4d6eed55da9145044d0ffc1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + +[[package]] +name = "snapd" +version = "0.1.0" +source = "git+https://github.com/ZoopOTheGoop/snapd-rs?branch=framework#f4b67567f59dddfd014cb526f27e2dbc0d37db50" +dependencies = [ + "async-trait", + "deadpool", + "http 1.1.0", + "http-body-util", + "hyper 1.4.1", + "pin-project", + "serde", + "serde_json", + "thiserror", + "tokio", + "url", +] + [[package]] name = "socket2" version = "0.5.7" @@ -2201,9 +2792,9 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcfa89bea9500db4a0d038513d7a060566bfc51d46d1c014847049a45cce85e8" +checksum = "93334716a037193fac19df402f8571269c84a00852f6a7066b5d2616dcd64d3e" dependencies = [ "sqlx-core", "sqlx-macros", @@ -2214,13 +2805,14 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d06e2f2bd861719b1f3f0c7dbe1d80c30bf59e76cf019f07d9014ed7eefb8e08" +checksum = "d4d8060b456358185f7d50c55d9b5066ad956956fddec42ee2e8567134a8936e" dependencies = [ "atoi", "byteorder", "bytes", + "chrono", "crc", "crossbeam-queue", "either", @@ -2257,9 +2849,9 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f998a9defdbd48ed005a89362bd40dd2117502f15294f61c8d47034107dbbdc" +checksum = "cac0692bcc9de3b073e8d747391827297e075c7710ff6276d9f7a1f3d58c6657" dependencies = [ "proc-macro2", "quote", @@ -2270,13 +2862,13 @@ dependencies = [ [[package]] name = "sqlx-macros-core" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d100558134176a2629d46cec0c8891ba0be8910f7896abfdb75ef4ab6f4e7ce" +checksum = "1804e8a7c7865599c9c79be146dc8a9fd8cc86935fa641d3ea58e5f0688abaa5" dependencies = [ "dotenvy", "either", - "heck", + "heck 0.5.0", "hex", "once_cell", "proc-macro2", @@ -2296,15 +2888,16 @@ dependencies = [ [[package]] name = "sqlx-mysql" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cac0ab331b14cb3921c62156d913e4c15b74fb6ec0f3146bd4ef6e4fb3c12" +checksum = "64bb4714269afa44aef2755150a0fc19d756fb580a67db8885608cf02f47d06a" dependencies = [ "atoi", "base64 0.22.1", "bitflags 2.6.0", "byteorder", "bytes", + "chrono", "crc", "digest", "dotenvy", @@ -2339,14 +2932,15 @@ dependencies = [ [[package]] name = "sqlx-postgres" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9734dbce698c67ecf67c442f768a5e90a49b2a4d61a9f1d59f73874bd4cf0710" +checksum = "6fa91a732d854c5d7726349bb4bb879bb9478993ceb764247660aee25f67c2f8" dependencies = [ "atoi", "base64 0.22.1", "bitflags 2.6.0", "byteorder", + "chrono", "crc", "dotenvy", "etcetera", @@ -2378,11 +2972,12 @@ dependencies = [ [[package]] name = "sqlx-sqlite" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75b419c3c1b1697833dd927bdc4c6545a620bc1bbafabd44e1efbe9afcd337e" +checksum = "d5b2cf34a45953bfd3daaf3db0f7a7878ab9b7a6b91b422d24a7a9e4c857b680" dependencies = [ "atoi", + "chrono", "flume", "futures-channel", "futures-core", @@ -2411,6 +3006,12 @@ dependencies = [ "unicode-properties", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "strum" version = "0.26.3" @@ -2426,7 +3027,7 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", @@ -2465,6 +3066,39 @@ dependencies = [ "futures-core", ] +[[package]] +name = "synthez" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d2c2202510a1e186e63e596d9318c91a8cbe85cd1a56a7be0c333e5f59ec8d" +dependencies = [ + "syn", + "synthez-codegen", + "synthez-core", +] + +[[package]] +name = "synthez-codegen" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f724aa6d44b7162f3158a57bccd871a77b39a4aef737e01bcdff41f4772c7746" +dependencies = [ + "syn", + "synthez-core", +] + +[[package]] +name = "synthez-core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78bfa6ec52465e2425fd43ce5bbbe0f0b623964f7c63feb6b10980e816c654ea" +dependencies = [ + "proc-macro2", + "quote", + "sealed", + "syn", +] + [[package]] name = "system-configuration" version = "0.6.1" @@ -2499,20 +3133,41 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "terminal_size" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" +dependencies = [ + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] + [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -2577,9 +3232,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -2693,20 +3348,50 @@ checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" dependencies = [ "async-stream", "async-trait", - "axum", + "axum 0.6.20", "base64 0.21.7", "bytes", "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", - "hyper-timeout", + "hyper-timeout 0.4.1", + "percent-encoding", + "pin-project", + "prost 0.12.6", + "tokio", + "tokio-stream", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" +dependencies = [ + "async-stream", + "async-trait", + "axum 0.7.6", + "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", + "prost 0.13.3", + "socket2", "tokio", "tokio-stream", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", "tracing", @@ -2731,11 +3416,24 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fa37c513df1339d197f4ba21d28c918b9ef1ac1768265f11ecb6b7f1cba1b76" dependencies = [ - "prost", - "prost-types", + "prost 0.12.6", + "prost-types 0.12.6", + "tokio", + "tokio-stream", + "tonic 0.10.2", +] + +[[package]] +name = "tonic-reflection" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b56b874eedb04f89907573b408eab1e87c1c1dce43aac6ad63742f57faa99ff" +dependencies = [ + "prost 0.13.3", + "prost-types 0.13.3", "tokio", "tokio-stream", - "tonic", + "tonic 0.12.2", ] [[package]] @@ -2758,6 +3456,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-layer" version = "0.3.3" @@ -2838,6 +3550,26 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typed-builder" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe83c85a85875e8c4cb9ce4a890f05b23d38cd0d47647db7895d3d2a79566d2" +dependencies = [ + "typed-builder-macro", +] + +[[package]] +name = "typed-builder-macro" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29a3151c41d0b13e3d011f98adc24434560ef06673a155a6c7f66b9879eecce2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "typenum" version = "1.17.0" @@ -2856,6 +3588,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + [[package]] name = "unicode-normalization" version = "0.1.23" @@ -2871,6 +3609,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524" +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + [[package]] name = "unicode_categories" version = "0.1.1" @@ -2894,6 +3638,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "valuable" version = "0.1.0" @@ -2912,6 +3662,16 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -3046,6 +3806,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index c56eb9fd..8d7d84c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,59 +1,4 @@ -[package] -name = "ratings" -description = "Ubuntu App Center ratings service" -license = "GPL-3.0-only" -authors = ["Canonical"] -version = "0.0.3" -edition = "2021" +[workspace] +resolver = "2" -[dependencies] -argon2 = "0.5.3" -axum = "0.6.20" # this *must* be pinned because 0.7.x relies on hyper 1.x causing a ton of type conversion issues -base64 = "0.22.0" -chrono = { version = "0.4.34", default-features = false, features = [ - "std", - "clock", - "serde", -] } -dotenvy = "0.15" -envy = "0.4" -futures = "0.3" -http = "1.0" -http-body = "0.4.6" -hyper = { version = "0.14", features = ["full", "backports", "deprecated"] } -jsonwebtoken = "9.2" -log = { version = "0.4.21", features = ["serde"] } -once_cell = "1.19" -prost = "0.12" -prost-types = "0.12" -rand = "0.8" -reqwest = "0.12" -secrecy = { version = "0.8.0", features = ["serde"] } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0.114" -sha2 = "0.10" -sqlx = { version = "0.8", features = [ - "runtime-tokio-rustls", - "postgres", - "time", -] } -strum = { version = "0.26.2", features = ["derive"] } -thiserror = "1.0" -time = { version = "0.3", features = ["macros"] } -tokio = { version = "1.36", features = ["full"] } -tokio-postgres = "0.7" -tonic = "0.10" -tonic-reflection = "0.10" -tower = "0.4" -tracing = "0.1" -tracing-subscriber = { version = "0.3", features = ["env-filter"] } - -[build-dependencies] -git2 = { version = "0.18.2", default-features = false } -tonic-build = { version = "0.11", features = ["prost"] } - -[dev-dependencies] -anyhow = "1.0.89" -lazy_static = "1.4.0" -regex = "1.10.3" -simple_test_case = "1.2.0" +members = [ "crates/*" ] diff --git a/TODO b/TODO deleted file mode 100644 index ee248561..00000000 --- a/TODO +++ /dev/null @@ -1,25 +0,0 @@ -# Things we need to handle as part of the refactor - -- [ ] update proto generation to output rust files to somewhere within /src (same as prompting client) - - [ ] add the CI check from prompting that the generated code is up to date -- [ ] replace the cargo-make Makefile with a normal Makefile -- [ ] two docker compose files: one for running a locally built image and one running latest in the github registry -- [ ] rip out cucumber and simplify the integration tests - - the test cases themselves are good but the cucumber wrappers are not needed - - originally the tests were written without cucumber so lets look back in the git history to see if we can start - from there -- [ ] rip out axum and the log-level / api version stuff - - this will also include removing the axum wrapper around the tonic server -- [ ] replace the log crate with tracing - - -src/ - db.rs - grpc.rs - main.rs - middleware.rs - schema/ - ... files containing DB structs - ratings/ - snap.rs - catergory.rs diff --git a/crates/ratings/Cargo.toml b/crates/ratings/Cargo.toml new file mode 100644 index 00000000..340846a5 --- /dev/null +++ b/crates/ratings/Cargo.toml @@ -0,0 +1,60 @@ +[package] +name = "ratings" +description = "Ubuntu App Center ratings service" +license = "GPL-3.0-only" +authors = ["Canonical"] +version = "0.0.3" +edition = "2021" + +[dependencies] +argon2 = "0.5.3" +axum = "0.6.20" # this *must* be pinned because 0.7.x relies on hyper 1.x causing a ton of type conversion issues +base64 = "0.22.0" +chrono = { version = "0.4.34", default-features = false, features = [ + "std", + "clock", + "serde", +] } +dotenvy = "0.15" +envy = "0.4" +futures = "0.3" +http = "1.0" +http-body = "0.4.6" +hyper = { version = "0.14", features = ["full", "backports", "deprecated"] } +jsonwebtoken = "9.2" +log = { version = "0.4.21", features = ["serde"] } +once_cell = "1.19" +prost = "0.12" +prost-types = "0.12" +rand = "0.8" +reqwest = "0.12" +secrecy = { version = "0.8.0", features = ["serde"] } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0.114" +sha2 = "0.10" +snapd = { git = "https://github.com/ZoopOTheGoop/snapd-rs", branch = "framework" } +sqlx = { version = "0.8", features = [ + "runtime-tokio-rustls", + "postgres", + "time", +] } +strum = { version = "0.26.2", features = ["derive"] } +thiserror = "1.0" +time = { version = "0.3", features = ["macros"] } +tokio = { version = "1.36", features = ["full"] } +tokio-postgres = "0.7" +tonic = "0.10" +tonic-reflection = "0.10" +tower = "0.4" +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +[build-dependencies] +git2 = { version = "0.18.2", default-features = false } +tonic-build = { version = "0.11", features = ["prost"] } + +[dev-dependencies] +cucumber = { version = "0.20.2", features = ["libtest", "tracing"] } +lazy_static = "1.4.0" +regex = "1.10.3" +serde_json = "1.0.114" + diff --git a/build.rs b/crates/ratings/build.rs similarity index 62% rename from build.rs rename to crates/ratings/build.rs index 8c7a94a5..c6376f0b 100644 --- a/build.rs +++ b/crates/ratings/build.rs @@ -3,7 +3,7 @@ use std::path::Path; fn init_proto() -> Result<(), Box> { // Define the path to the output directory within the `src` folder - let out_dir = Path::new("proto"); + let out_dir = Path::new("src/proto"); std::fs::create_dir_all(out_dir)?; let descriptor_set_path = format!( @@ -12,10 +12,10 @@ fn init_proto() -> Result<(), Box> { ); let files = &[ - "proto/ratings_features_app.proto", - "proto/ratings_features_chart.proto", - "proto/ratings_features_user.proto", - "proto/ratings_features_common.proto", + "../../proto/ratings_features_app.proto", + "../../proto/ratings_features_chart.proto", + "../../proto/ratings_features_user.proto", + "../../proto/ratings_features_common.proto", ]; tonic_build::configure() @@ -31,27 +31,11 @@ fn init_proto() -> Result<(), Box> { "Category", r#"#[strum(serialize_all = "kebab_case", ascii_case_insensitive)]"#, ) - .compile(files, &["proto"])?; + .compile(files, &["../../proto"])?; Ok(()) } -// fn include_build_info() -> Result<(), Box> { -// let repo = Repository::open(std::env::current_dir()?)?; -// let head = repo.head()?; -// let branch = head -// .name() -// .unwrap() -// .strip_prefix("refs/heads/") -// .unwrap_or("no-branch"); -// println!("cargo:rustc-env=GIT_BRANCH={}", branch); -// -// let commit_sha = repo.head()?.target().unwrap(); -// println!("cargo:rustc-env=GIT_HASH={}", commit_sha); -// -// Ok(()) -// } - fn main() -> Result<(), Box> { init_proto()?; // Running this in docker compose breaks the build and we only need it for diff --git a/sql/migrations/20230829085908_ratings_init.down.sql b/crates/ratings/sql/migrations/20230829085908_ratings_init.down.sql similarity index 100% rename from sql/migrations/20230829085908_ratings_init.down.sql rename to crates/ratings/sql/migrations/20230829085908_ratings_init.down.sql diff --git a/sql/migrations/20230829085908_ratings_init.up.sql b/crates/ratings/sql/migrations/20230829085908_ratings_init.up.sql similarity index 100% rename from sql/migrations/20230829085908_ratings_init.up.sql rename to crates/ratings/sql/migrations/20230829085908_ratings_init.up.sql diff --git a/sql/migrations/20240208071037_categories.up.sql b/crates/ratings/sql/migrations/20240208071037_categories.up.sql similarity index 100% rename from sql/migrations/20240208071037_categories.up.sql rename to crates/ratings/sql/migrations/20240208071037_categories.up.sql diff --git a/src/app/context.rs b/crates/ratings/src/app/context.rs similarity index 100% rename from src/app/context.rs rename to crates/ratings/src/app/context.rs diff --git a/src/app/interfaces/authentication/admin.rs b/crates/ratings/src/app/interfaces/authentication/admin.rs similarity index 100% rename from src/app/interfaces/authentication/admin.rs rename to crates/ratings/src/app/interfaces/authentication/admin.rs diff --git a/src/app/interfaces/authentication/jwt.rs b/crates/ratings/src/app/interfaces/authentication/jwt.rs similarity index 100% rename from src/app/interfaces/authentication/jwt.rs rename to crates/ratings/src/app/interfaces/authentication/jwt.rs diff --git a/src/app/interfaces/authentication/mod.rs b/crates/ratings/src/app/interfaces/authentication/mod.rs similarity index 100% rename from src/app/interfaces/authentication/mod.rs rename to crates/ratings/src/app/interfaces/authentication/mod.rs diff --git a/src/app/interfaces/errors.rs b/crates/ratings/src/app/interfaces/errors.rs similarity index 100% rename from src/app/interfaces/errors.rs rename to crates/ratings/src/app/interfaces/errors.rs diff --git a/src/app/interfaces/middleware.rs b/crates/ratings/src/app/interfaces/middleware.rs similarity index 100% rename from src/app/interfaces/middleware.rs rename to crates/ratings/src/app/interfaces/middleware.rs diff --git a/src/app/interfaces/mod.rs b/crates/ratings/src/app/interfaces/mod.rs similarity index 100% rename from src/app/interfaces/mod.rs rename to crates/ratings/src/app/interfaces/mod.rs diff --git a/src/app/interfaces/servers/grpc.rs b/crates/ratings/src/app/interfaces/servers/grpc.rs similarity index 100% rename from src/app/interfaces/servers/grpc.rs rename to crates/ratings/src/app/interfaces/servers/grpc.rs diff --git a/src/app/interfaces/servers/mod.rs b/crates/ratings/src/app/interfaces/servers/mod.rs similarity index 100% rename from src/app/interfaces/servers/mod.rs rename to crates/ratings/src/app/interfaces/servers/mod.rs diff --git a/src/app/interfaces/servers/rest.rs b/crates/ratings/src/app/interfaces/servers/rest.rs similarity index 100% rename from src/app/interfaces/servers/rest.rs rename to crates/ratings/src/app/interfaces/servers/rest.rs diff --git a/src/app/mod.rs b/crates/ratings/src/app/mod.rs similarity index 100% rename from src/app/mod.rs rename to crates/ratings/src/app/mod.rs diff --git a/src/app/run.rs b/crates/ratings/src/app/run.rs similarity index 100% rename from src/app/run.rs rename to crates/ratings/src/app/run.rs diff --git a/src/features/admin/api_version/interface.rs b/crates/ratings/src/features/admin/api_version/interface.rs similarity index 100% rename from src/features/admin/api_version/interface.rs rename to crates/ratings/src/features/admin/api_version/interface.rs diff --git a/src/features/admin/api_version/mod.rs b/crates/ratings/src/features/admin/api_version/mod.rs similarity index 100% rename from src/features/admin/api_version/mod.rs rename to crates/ratings/src/features/admin/api_version/mod.rs diff --git a/src/features/admin/api_version/service/mod.rs b/crates/ratings/src/features/admin/api_version/service/mod.rs similarity index 100% rename from src/features/admin/api_version/service/mod.rs rename to crates/ratings/src/features/admin/api_version/service/mod.rs diff --git a/src/features/admin/api_version/service/rest.rs b/crates/ratings/src/features/admin/api_version/service/rest.rs similarity index 100% rename from src/features/admin/api_version/service/rest.rs rename to crates/ratings/src/features/admin/api_version/service/rest.rs diff --git a/src/features/admin/log_level/interface.rs b/crates/ratings/src/features/admin/log_level/interface.rs similarity index 100% rename from src/features/admin/log_level/interface.rs rename to crates/ratings/src/features/admin/log_level/interface.rs diff --git a/src/features/admin/log_level/mod.rs b/crates/ratings/src/features/admin/log_level/mod.rs similarity index 100% rename from src/features/admin/log_level/mod.rs rename to crates/ratings/src/features/admin/log_level/mod.rs diff --git a/src/features/admin/log_level/service/mod.rs b/crates/ratings/src/features/admin/log_level/service/mod.rs similarity index 100% rename from src/features/admin/log_level/service/mod.rs rename to crates/ratings/src/features/admin/log_level/service/mod.rs diff --git a/src/features/admin/log_level/service/rest.rs b/crates/ratings/src/features/admin/log_level/service/rest.rs similarity index 100% rename from src/features/admin/log_level/service/rest.rs rename to crates/ratings/src/features/admin/log_level/service/rest.rs diff --git a/src/features/admin/mod.rs b/crates/ratings/src/features/admin/mod.rs similarity index 100% rename from src/features/admin/mod.rs rename to crates/ratings/src/features/admin/mod.rs diff --git a/src/features/chart/entities.rs b/crates/ratings/src/features/chart/entities.rs similarity index 100% rename from src/features/chart/entities.rs rename to crates/ratings/src/features/chart/entities.rs diff --git a/src/features/chart/errors.rs b/crates/ratings/src/features/chart/errors.rs similarity index 100% rename from src/features/chart/errors.rs rename to crates/ratings/src/features/chart/errors.rs diff --git a/src/features/chart/infrastructure.rs b/crates/ratings/src/features/chart/infrastructure.rs similarity index 100% rename from src/features/chart/infrastructure.rs rename to crates/ratings/src/features/chart/infrastructure.rs diff --git a/src/features/chart/mod.rs b/crates/ratings/src/features/chart/mod.rs similarity index 100% rename from src/features/chart/mod.rs rename to crates/ratings/src/features/chart/mod.rs diff --git a/src/features/chart/service/grpc.rs b/crates/ratings/src/features/chart/service/grpc.rs similarity index 100% rename from src/features/chart/service/grpc.rs rename to crates/ratings/src/features/chart/service/grpc.rs diff --git a/src/features/chart/service/mod.rs b/crates/ratings/src/features/chart/service/mod.rs similarity index 100% rename from src/features/chart/service/mod.rs rename to crates/ratings/src/features/chart/service/mod.rs diff --git a/src/features/chart/use_cases.rs b/crates/ratings/src/features/chart/use_cases.rs similarity index 100% rename from src/features/chart/use_cases.rs rename to crates/ratings/src/features/chart/use_cases.rs diff --git a/src/features/common/entities.rs b/crates/ratings/src/features/common/entities.rs similarity index 100% rename from src/features/common/entities.rs rename to crates/ratings/src/features/common/entities.rs diff --git a/src/features/common/mod.rs b/crates/ratings/src/features/common/mod.rs similarity index 100% rename from src/features/common/mod.rs rename to crates/ratings/src/features/common/mod.rs diff --git a/src/features/mod.rs b/crates/ratings/src/features/mod.rs similarity index 100% rename from src/features/mod.rs rename to crates/ratings/src/features/mod.rs diff --git a/src/features/pb.rs b/crates/ratings/src/features/pb.rs similarity index 65% rename from src/features/pb.rs rename to crates/ratings/src/features/pb.rs index d20971ed..43db56c9 100644 --- a/src/features/pb.rs +++ b/crates/ratings/src/features/pb.rs @@ -6,24 +6,20 @@ pub mod app { //! Contains protobufs relating to the app features - - include!("../../proto/ratings.features.app.rs"); + include!("../proto/ratings.features.app.rs"); } pub mod common { //! Contains common protobufs - - include!("../../proto/ratings.features.common.rs"); + include!("../proto/ratings.features.common.rs"); } pub mod user { //! Contains user protobufs - - include!("../../proto/ratings.features.user.rs"); + include!("../proto/ratings.features.user.rs"); } pub mod chart { //! Contains chart protobufs - - include!("../../proto/ratings.features.chart.rs"); + include!("../proto/ratings.features.chart.rs"); } diff --git a/src/features/rating/errors.rs b/crates/ratings/src/features/rating/errors.rs similarity index 100% rename from src/features/rating/errors.rs rename to crates/ratings/src/features/rating/errors.rs diff --git a/src/features/rating/infrastructure.rs b/crates/ratings/src/features/rating/infrastructure.rs similarity index 100% rename from src/features/rating/infrastructure.rs rename to crates/ratings/src/features/rating/infrastructure.rs diff --git a/src/features/rating/mod.rs b/crates/ratings/src/features/rating/mod.rs similarity index 100% rename from src/features/rating/mod.rs rename to crates/ratings/src/features/rating/mod.rs diff --git a/src/features/rating/service/grpc.rs b/crates/ratings/src/features/rating/service/grpc.rs similarity index 100% rename from src/features/rating/service/grpc.rs rename to crates/ratings/src/features/rating/service/grpc.rs diff --git a/src/features/rating/service/mod.rs b/crates/ratings/src/features/rating/service/mod.rs similarity index 100% rename from src/features/rating/service/mod.rs rename to crates/ratings/src/features/rating/service/mod.rs diff --git a/src/features/rating/use_cases.rs b/crates/ratings/src/features/rating/use_cases.rs similarity index 100% rename from src/features/rating/use_cases.rs rename to crates/ratings/src/features/rating/use_cases.rs diff --git a/src/features/user/entities.rs b/crates/ratings/src/features/user/entities.rs similarity index 100% rename from src/features/user/entities.rs rename to crates/ratings/src/features/user/entities.rs diff --git a/src/features/user/errors.rs b/crates/ratings/src/features/user/errors.rs similarity index 100% rename from src/features/user/errors.rs rename to crates/ratings/src/features/user/errors.rs diff --git a/src/features/user/infrastructure.rs b/crates/ratings/src/features/user/infrastructure.rs similarity index 100% rename from src/features/user/infrastructure.rs rename to crates/ratings/src/features/user/infrastructure.rs diff --git a/src/features/user/mod.rs b/crates/ratings/src/features/user/mod.rs similarity index 100% rename from src/features/user/mod.rs rename to crates/ratings/src/features/user/mod.rs diff --git a/src/features/user/service/grpc.rs b/crates/ratings/src/features/user/service/grpc.rs similarity index 100% rename from src/features/user/service/grpc.rs rename to crates/ratings/src/features/user/service/grpc.rs diff --git a/src/features/user/service/mod.rs b/crates/ratings/src/features/user/service/mod.rs similarity index 100% rename from src/features/user/service/mod.rs rename to crates/ratings/src/features/user/service/mod.rs diff --git a/src/features/user/use_cases.rs b/crates/ratings/src/features/user/use_cases.rs similarity index 100% rename from src/features/user/use_cases.rs rename to crates/ratings/src/features/user/use_cases.rs diff --git a/src/lib.rs b/crates/ratings/src/lib.rs similarity index 100% rename from src/lib.rs rename to crates/ratings/src/lib.rs diff --git a/src/main.rs b/crates/ratings/src/main.rs similarity index 100% rename from src/main.rs rename to crates/ratings/src/main.rs diff --git a/crates/ratings/src/proto/ratings.features.app.rs b/crates/ratings/src/proto/ratings.features.app.rs new file mode 100644 index 00000000..f8df299e --- /dev/null +++ b/crates/ratings/src/proto/ratings.features.app.rs @@ -0,0 +1,304 @@ +// This file is @generated by prost-build. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetRatingRequest { + #[prost(string, tag = "1")] + pub snap_id: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetRatingResponse { + #[prost(message, optional, tag = "1")] + pub rating: ::core::option::Option, +} +/// Generated client implementations. +pub mod app_client { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + #[derive(Debug, Clone)] + pub struct AppClient { + inner: tonic::client::Grpc, + } + impl AppClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl AppClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + Send + 'static, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> AppClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + Send + Sync, + { + AppClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } + pub async fn get_rating( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/ratings.features.app.App/GetRating", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("ratings.features.app.App", "GetRating")); + self.inner.unary(req, path, codec).await + } + } +} +/// Generated server implementations. +pub mod app_server { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with AppServer. + #[async_trait] + pub trait App: Send + Sync + 'static { + async fn get_rating( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + } + #[derive(Debug)] + pub struct AppServer { + inner: _Inner, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + struct _Inner(Arc); + impl AppServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + let inner = _Inner(inner); + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for AppServer + where + T: App, + B: Body + Send + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/ratings.features.app.App/GetRating" => { + #[allow(non_camel_case_types)] + struct GetRatingSvc(pub Arc); + impl tonic::server::UnaryService + for GetRatingSvc { + type Response = super::GetRatingResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_rating(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = GetRatingSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } + } + } + } + impl Clone for AppServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(Arc::clone(&self.0)) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::server::NamedService for AppServer { + const NAME: &'static str = "ratings.features.app.App"; + } +} diff --git a/crates/ratings/src/proto/ratings.features.chart.rs b/crates/ratings/src/proto/ratings.features.chart.rs new file mode 100644 index 00000000..db65b5dc --- /dev/null +++ b/crates/ratings/src/proto/ratings.features.chart.rs @@ -0,0 +1,432 @@ +// This file is @generated by prost-build. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetChartRequest { + #[prost(enumeration = "Timeframe", tag = "1")] + pub timeframe: i32, + #[prost(enumeration = "Category", optional, tag = "2")] + pub category: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetChartResponse { + #[prost(enumeration = "Timeframe", tag = "1")] + pub timeframe: i32, + #[prost(message, repeated, tag = "2")] + pub ordered_chart_data: ::prost::alloc::vec::Vec, + #[prost(enumeration = "Category", optional, tag = "3")] + pub category: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ChartData { + #[prost(float, tag = "1")] + pub raw_rating: f32, + #[prost(message, optional, tag = "2")] + pub rating: ::core::option::Option, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum Timeframe { + Unspecified = 0, + Week = 1, + Month = 2, +} +impl Timeframe { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Timeframe::Unspecified => "TIMEFRAME_UNSPECIFIED", + Timeframe::Week => "TIMEFRAME_WEEK", + Timeframe::Month => "TIMEFRAME_MONTH", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "TIMEFRAME_UNSPECIFIED" => Some(Self::Unspecified), + "TIMEFRAME_WEEK" => Some(Self::Week), + "TIMEFRAME_MONTH" => Some(Self::Month), + _ => None, + } + } +} +/// The categories that can be selected, these +/// are taken directly from `curl -sS -X GET --unix-socket /run/snapd.socket " +/// On 2024-02-03, it may need to be kept in sync. +#[derive(sqlx::Type, strum::EnumString, strum::Display)] +#[strum(serialize_all = "kebab_case", ascii_case_insensitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum Category { + ArtAndDesign = 0, + BookAndReference = 1, + Development = 2, + DevicesAndIot = 3, + Education = 4, + Entertainment = 5, + Featured = 6, + Finance = 7, + Games = 8, + HealthAndFitness = 9, + MusicAndAudio = 10, + NewsAndWeather = 11, + Personalisation = 12, + PhotoAndVideo = 13, + Productivity = 14, + Science = 15, + Security = 16, + ServerAndCloud = 17, + Social = 18, + Utilities = 19, +} +impl Category { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Category::ArtAndDesign => "ART_AND_DESIGN", + Category::BookAndReference => "BOOK_AND_REFERENCE", + Category::Development => "DEVELOPMENT", + Category::DevicesAndIot => "DEVICES_AND_IOT", + Category::Education => "EDUCATION", + Category::Entertainment => "ENTERTAINMENT", + Category::Featured => "FEATURED", + Category::Finance => "FINANCE", + Category::Games => "GAMES", + Category::HealthAndFitness => "HEALTH_AND_FITNESS", + Category::MusicAndAudio => "MUSIC_AND_AUDIO", + Category::NewsAndWeather => "NEWS_AND_WEATHER", + Category::Personalisation => "PERSONALISATION", + Category::PhotoAndVideo => "PHOTO_AND_VIDEO", + Category::Productivity => "PRODUCTIVITY", + Category::Science => "SCIENCE", + Category::Security => "SECURITY", + Category::ServerAndCloud => "SERVER_AND_CLOUD", + Category::Social => "SOCIAL", + Category::Utilities => "UTILITIES", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "ART_AND_DESIGN" => Some(Self::ArtAndDesign), + "BOOK_AND_REFERENCE" => Some(Self::BookAndReference), + "DEVELOPMENT" => Some(Self::Development), + "DEVICES_AND_IOT" => Some(Self::DevicesAndIot), + "EDUCATION" => Some(Self::Education), + "ENTERTAINMENT" => Some(Self::Entertainment), + "FEATURED" => Some(Self::Featured), + "FINANCE" => Some(Self::Finance), + "GAMES" => Some(Self::Games), + "HEALTH_AND_FITNESS" => Some(Self::HealthAndFitness), + "MUSIC_AND_AUDIO" => Some(Self::MusicAndAudio), + "NEWS_AND_WEATHER" => Some(Self::NewsAndWeather), + "PERSONALISATION" => Some(Self::Personalisation), + "PHOTO_AND_VIDEO" => Some(Self::PhotoAndVideo), + "PRODUCTIVITY" => Some(Self::Productivity), + "SCIENCE" => Some(Self::Science), + "SECURITY" => Some(Self::Security), + "SERVER_AND_CLOUD" => Some(Self::ServerAndCloud), + "SOCIAL" => Some(Self::Social), + "UTILITIES" => Some(Self::Utilities), + _ => None, + } + } +} +/// Generated client implementations. +pub mod chart_client { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + #[derive(Debug, Clone)] + pub struct ChartClient { + inner: tonic::client::Grpc, + } + impl ChartClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl ChartClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + Send + 'static, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> ChartClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + Send + Sync, + { + ChartClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } + pub async fn get_chart( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/ratings.features.chart.Chart/GetChart", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("ratings.features.chart.Chart", "GetChart")); + self.inner.unary(req, path, codec).await + } + } +} +/// Generated server implementations. +pub mod chart_server { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with ChartServer. + #[async_trait] + pub trait Chart: Send + Sync + 'static { + async fn get_chart( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + } + #[derive(Debug)] + pub struct ChartServer { + inner: _Inner, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + struct _Inner(Arc); + impl ChartServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + let inner = _Inner(inner); + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for ChartServer + where + T: Chart, + B: Body + Send + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/ratings.features.chart.Chart/GetChart" => { + #[allow(non_camel_case_types)] + struct GetChartSvc(pub Arc); + impl tonic::server::UnaryService + for GetChartSvc { + type Response = super::GetChartResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_chart(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = GetChartSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } + } + } + } + impl Clone for ChartServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(Arc::clone(&self.0)) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::server::NamedService for ChartServer { + const NAME: &'static str = "ratings.features.chart.Chart"; + } +} diff --git a/crates/ratings/src/proto/ratings.features.common.rs b/crates/ratings/src/proto/ratings.features.common.rs new file mode 100644 index 00000000..9e9f6a98 --- /dev/null +++ b/crates/ratings/src/proto/ratings.features.common.rs @@ -0,0 +1,49 @@ +// This file is @generated by prost-build. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Rating { + #[prost(string, tag = "1")] + pub snap_id: ::prost::alloc::string::String, + #[prost(uint64, tag = "2")] + pub total_votes: u64, + #[prost(enumeration = "RatingsBand", tag = "3")] + pub ratings_band: i32, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum RatingsBand { + VeryGood = 0, + Good = 1, + Neutral = 2, + Poor = 3, + VeryPoor = 4, + InsufficientVotes = 5, +} +impl RatingsBand { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + RatingsBand::VeryGood => "VERY_GOOD", + RatingsBand::Good => "GOOD", + RatingsBand::Neutral => "NEUTRAL", + RatingsBand::Poor => "POOR", + RatingsBand::VeryPoor => "VERY_POOR", + RatingsBand::InsufficientVotes => "INSUFFICIENT_VOTES", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "VERY_GOOD" => Some(Self::VeryGood), + "GOOD" => Some(Self::Good), + "NEUTRAL" => Some(Self::Neutral), + "POOR" => Some(Self::Poor), + "VERY_POOR" => Some(Self::VeryPoor), + "INSUFFICIENT_VOTES" => Some(Self::InsufficientVotes), + _ => None, + } + } +} diff --git a/crates/ratings/src/proto/ratings.features.user.rs b/crates/ratings/src/proto/ratings.features.user.rs new file mode 100644 index 00000000..8b234b1b --- /dev/null +++ b/crates/ratings/src/proto/ratings.features.user.rs @@ -0,0 +1,639 @@ +// This file is @generated by prost-build. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AuthenticateRequest { + /// sha256(\[$user:$machineId\]) + #[prost(string, tag = "1")] + pub id: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AuthenticateResponse { + #[prost(string, tag = "1")] + pub token: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListMyVotesRequest { + #[prost(string, tag = "1")] + pub snap_id_filter: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListMyVotesResponse { + #[prost(message, repeated, tag = "1")] + pub votes: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetSnapVotesRequest { + #[prost(string, tag = "1")] + pub snap_id: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetSnapVotesResponse { + #[prost(message, repeated, tag = "1")] + pub votes: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Vote { + #[prost(string, tag = "1")] + pub snap_id: ::prost::alloc::string::String, + #[prost(int32, tag = "2")] + pub snap_revision: i32, + #[prost(bool, tag = "3")] + pub vote_up: bool, + #[prost(message, optional, tag = "4")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VoteRequest { + #[prost(string, tag = "1")] + pub snap_id: ::prost::alloc::string::String, + #[prost(int32, tag = "2")] + pub snap_revision: i32, + #[prost(bool, tag = "3")] + pub vote_up: bool, +} +/// Generated client implementations. +pub mod user_client { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + #[derive(Debug, Clone)] + pub struct UserClient { + inner: tonic::client::Grpc, + } + impl UserClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl UserClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + Send + 'static, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> UserClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + Send + Sync, + { + UserClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } + pub async fn authenticate( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/ratings.features.user.User/Authenticate", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("ratings.features.user.User", "Authenticate")); + self.inner.unary(req, path, codec).await + } + pub async fn delete( + &mut self, + request: impl tonic::IntoRequest<()>, + ) -> std::result::Result, tonic::Status> { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/ratings.features.user.User/Delete", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("ratings.features.user.User", "Delete")); + self.inner.unary(req, path, codec).await + } + pub async fn vote( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/ratings.features.user.User/Vote", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("ratings.features.user.User", "Vote")); + self.inner.unary(req, path, codec).await + } + pub async fn list_my_votes( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/ratings.features.user.User/ListMyVotes", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("ratings.features.user.User", "ListMyVotes")); + self.inner.unary(req, path, codec).await + } + pub async fn get_snap_votes( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/ratings.features.user.User/GetSnapVotes", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("ratings.features.user.User", "GetSnapVotes")); + self.inner.unary(req, path, codec).await + } + } +} +/// Generated server implementations. +pub mod user_server { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with UserServer. + #[async_trait] + pub trait User: Send + Sync + 'static { + async fn authenticate( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn delete( + &self, + request: tonic::Request<()>, + ) -> std::result::Result, tonic::Status>; + async fn vote( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + async fn list_my_votes( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_snap_votes( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + } + #[derive(Debug)] + pub struct UserServer { + inner: _Inner, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + struct _Inner(Arc); + impl UserServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + let inner = _Inner(inner); + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for UserServer + where + T: User, + B: Body + Send + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/ratings.features.user.User/Authenticate" => { + #[allow(non_camel_case_types)] + struct AuthenticateSvc(pub Arc); + impl tonic::server::UnaryService + for AuthenticateSvc { + type Response = super::AuthenticateResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::authenticate(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = AuthenticateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/ratings.features.user.User/Delete" => { + #[allow(non_camel_case_types)] + struct DeleteSvc(pub Arc); + impl tonic::server::UnaryService<()> for DeleteSvc { + type Response = (); + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call(&mut self, request: tonic::Request<()>) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::delete(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = DeleteSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/ratings.features.user.User/Vote" => { + #[allow(non_camel_case_types)] + struct VoteSvc(pub Arc); + impl tonic::server::UnaryService + for VoteSvc { + type Response = (); + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::vote(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = VoteSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/ratings.features.user.User/ListMyVotes" => { + #[allow(non_camel_case_types)] + struct ListMyVotesSvc(pub Arc); + impl tonic::server::UnaryService + for ListMyVotesSvc { + type Response = super::ListMyVotesResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::list_my_votes(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = ListMyVotesSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/ratings.features.user.User/GetSnapVotes" => { + #[allow(non_camel_case_types)] + struct GetSnapVotesSvc(pub Arc); + impl tonic::server::UnaryService + for GetSnapVotesSvc { + type Response = super::GetSnapVotesResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_snap_votes(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = GetSnapVotesSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } + } + } + } + impl Clone for UserServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(Arc::clone(&self.0)) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::server::NamedService for UserServer { + const NAME: &'static str = "ratings.features.user.User"; + } +} diff --git a/src/utils/config.rs b/crates/ratings/src/utils/config.rs similarity index 100% rename from src/utils/config.rs rename to crates/ratings/src/utils/config.rs diff --git a/src/utils/infrastructure.rs b/crates/ratings/src/utils/infrastructure.rs similarity index 100% rename from src/utils/infrastructure.rs rename to crates/ratings/src/utils/infrastructure.rs diff --git a/src/utils/jwt.rs b/crates/ratings/src/utils/jwt.rs similarity index 100% rename from src/utils/jwt.rs rename to crates/ratings/src/utils/jwt.rs diff --git a/src/utils/log_util.rs b/crates/ratings/src/utils/log_util.rs similarity index 100% rename from src/utils/log_util.rs rename to crates/ratings/src/utils/log_util.rs diff --git a/src/utils/migrator.rs b/crates/ratings/src/utils/migrator.rs similarity index 100% rename from src/utils/migrator.rs rename to crates/ratings/src/utils/migrator.rs diff --git a/src/utils/mod.rs b/crates/ratings/src/utils/mod.rs similarity index 100% rename from src/utils/mod.rs rename to crates/ratings/src/utils/mod.rs diff --git a/crates/ratings_new/Cargo.lock b/crates/ratings_new/Cargo.lock new file mode 100644 index 00000000..66194ef8 --- /dev/null +++ b/crates/ratings_new/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ratings" +version = "0.1.0" diff --git a/crates/ratings_new/Cargo.toml b/crates/ratings_new/Cargo.toml new file mode 100644 index 00000000..19858bd0 --- /dev/null +++ b/crates/ratings_new/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "ratings_new" +version = "0.1.0" +edition = "2021" + +[dependencies] +chrono = "0.4.38" +prost = "0.13.3" +prost-types = "0.13.3" +sqlx = { version = "0.8.2", features = ["runtime-tokio-rustls", "postgres", "chrono", "migrate"] } +thiserror = "1.0.64" +tokio = "1.40.0" +tonic = "0.12.2" +tonic-reflection = "0.12.2" +tracing = "0.1.40" +tracing-subscriber = "0.3.18" + +[dev-dependencies] +simple_test_case = "1.2.0" diff --git a/crates/ratings_new/src/db/mod.rs b/crates/ratings_new/src/db/mod.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/ratings_new/src/db/user.rs b/crates/ratings_new/src/db/user.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/ratings_new/src/db/vote.rs b/crates/ratings_new/src/db/vote.rs new file mode 100644 index 00000000..0c92e5fc --- /dev/null +++ b/crates/ratings_new/src/db/vote.rs @@ -0,0 +1,16 @@ +struct RatingsService { + db_pool: Vec<()>, +} + +impl RatingService { + // helper methods +} + +impl TonicTraitForThing for RatingsService { + async fn get_vote_summary(&self, snap_name: &str) -> Result { + let conn = self.get_db_connection().await?; + let raw = VoteSummary::get_for(snap_name, conn).await?; + + Ok(raw.into()) + } +} diff --git a/crates/ratings_new/src/grpc/app.rs b/crates/ratings_new/src/grpc/app.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/ratings_new/src/grpc/charts.rs b/crates/ratings_new/src/grpc/charts.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/ratings_new/src/grpc/mod.rs b/crates/ratings_new/src/grpc/mod.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/ratings_new/src/grpc/user.rs b/crates/ratings_new/src/grpc/user.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/ratings_new/src/lib.rs b/crates/ratings_new/src/lib.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/ratings_new/src/main.rs b/crates/ratings_new/src/main.rs new file mode 100644 index 00000000..e7a11a96 --- /dev/null +++ b/crates/ratings_new/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/crates/ratings_new/src/middleware.rs b/crates/ratings_new/src/middleware.rs new file mode 100644 index 00000000..e69de29b