From 2ab0facfc9d2d15a1cc54d906ea9ac198e837f67 Mon Sep 17 00:00:00 2001 From: raphael-goetz Date: Thu, 19 Dec 2024 12:00:50 +0100 Subject: [PATCH 1/6] feat: setup workspace toml --- Cargo.lock | 288 +++++++++++++++++++--------------------------- Cargo.toml | 31 +++-- aquila/Cargo.toml | 23 ++++ 3 files changed, 162 insertions(+), 180 deletions(-) create mode 100644 aquila/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index b933e3d..d076e5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,22 +41,19 @@ dependencies = [ "libc", ] -[[package]] -name = "anstyle" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" - [[package]] name = "anyhow" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "aquila" version = "0.1.0" dependencies = [ + "aquila_cache", + "aquila_container", + "aquila_store", "async-stream", "async-trait", "clokwerk", @@ -64,20 +61,49 @@ dependencies = [ "futures", "json_env_logger2", "log", - "mockall", - "prost", - "prost-types", - "rabbitmq-stream-client", "redis", - "serde", "serde_json", - "testcontainers", - "thiserror 2.0.8", "tokio", "tonic", "tucana", ] +[[package]] +name = "aquila_cache" +version = "0.1.0" +dependencies = [ + "redis", +] + +[[package]] +name = "aquila_container" +version = "0.1.0" +dependencies = [ + "redis", + "testcontainers", +] + +[[package]] +name = "aquila_queue" +version = "0.1.0" +dependencies = [ + "rabbitmq-stream-client", + "tokio", +] + +[[package]] +name = "aquila_store" +version = "0.1.0" +dependencies = [ + "aquila_container", + "async-trait", + "log", + "redis", + "serde_json", + "tokio", + "tucana", +] + [[package]] name = "arc-swap" version = "1.7.1" @@ -244,9 +270,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "axum" -version = "0.7.7" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", "axum-core", @@ -263,8 +289,8 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper 1.0.1", - "tower 0.5.1", + "sync_wrapper", + "tower 0.5.2", "tower-layer", "tower-service", ] @@ -284,7 +310,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.1", + "sync_wrapper", "tower-layer", "tower-service", ] @@ -363,7 +389,7 @@ dependencies = [ "hyperlocal", "log", "pin-project-lite", - "rustls 0.23.16", + "rustls 0.23.20", "rustls-native-certs", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -372,7 +398,7 @@ dependencies = [ "serde_json", "serde_repr", "serde_urlencoded", - "thiserror 1.0.68", + "thiserror 1.0.69", "tokio", "tokio-util", "tower-service", @@ -411,9 +437,9 @@ checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "cc" -version = "1.1.34" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" +checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf" dependencies = [ "shlex", ] @@ -426,9 +452,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", @@ -597,12 +623,6 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" -[[package]] -name = "downcast" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" - [[package]] name = "either" version = "1.13.0" @@ -711,12 +731,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fragile" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" - [[package]] name = "futures" version = "0.3.31" @@ -850,9 +864,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" dependencies = [ "atomic-waker", "bytes", @@ -860,7 +874,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.6.0", + "indexmap 2.7.0", "slab", "tokio", "tokio-util", @@ -881,9 +895,9 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" @@ -911,18 +925,18 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "home" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "http" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", @@ -966,9 +980,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", @@ -1002,26 +1016,26 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.3" +version = "0.27.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +checksum = "f6884a48c6826ec44f524c7456b163cebe9e55a18d7b5e307cb4f100371cc767" dependencies = [ "futures-util", "http", "hyper", "hyper-util", - "rustls 0.23.16", + "rustls 0.23.20", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.0", + "tokio-rustls 0.26.1", "tower-service", ] [[package]] name = "hyper-timeout" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ "hyper", "hyper-util", @@ -1116,12 +1130,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "serde", ] @@ -1193,7 +1207,7 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.6.0", "libc", - "redox_syscall 0.5.7", + "redox_syscall 0.5.8", ] [[package]] @@ -1260,32 +1274,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "mockall" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39a6bfcc6c8c7eed5ee98b9c3e33adc726054389233e201c95dab2d41a3839d2" -dependencies = [ - "cfg-if", - "downcast", - "fragile", - "mockall_derive", - "predicates", - "predicates-tree", -] - -[[package]] -name = "mockall_derive" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25ca3004c2efe9011bd4e461bd8256445052b9615405b4f7ea43fc8ca5c20898" -dependencies = [ - "cfg-if", - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "multimap" version = "0.10.0" @@ -1376,9 +1364,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "ordered-float" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e7ccb95e240b7c9506a3d544f10d935e142cc90b0a1d56954fb44d89ad6b97" +checksum = "c65ee1f9701bf938026630b455d5315f490640234259037edb259798b3bcf85e" dependencies = [ "num-traits", ] @@ -1407,7 +1395,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.7", + "redox_syscall 0.5.8", "smallvec", "windows-targets 0.52.6", ] @@ -1450,7 +1438,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.6.0", + "indexmap 2.7.0", ] [[package]] @@ -1526,32 +1514,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "predicates" -version = "3.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" -dependencies = [ - "anstyle", - "predicates-core", -] - -[[package]] -name = "predicates-core" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" - -[[package]] -name = "predicates-tree" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" -dependencies = [ - "predicates-core", - "termtree", -] - [[package]] name = "prettyplease" version = "0.2.25" @@ -1592,11 +1554,10 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" +checksum = "d0f3e5beed80eb580c68e2c600937ac2c4eedabdfd5ef1e5b7ea4f3fba84497b" dependencies = [ - "bytes", "heck", "itertools 0.13.0", "log", @@ -1759,9 +1720,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ "bitflags 2.6.0", ] @@ -1780,9 +1741,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -1852,9 +1813,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" dependencies = [ "once_cell", "ring", @@ -1897,9 +1858,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" [[package]] name = "rustls-webpki" @@ -1936,9 +1897,9 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "schannel" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys 0.59.0", ] @@ -1974,9 +1935,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.0" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" dependencies = [ "core-foundation-sys", "libc", @@ -1984,9 +1945,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" [[package]] name = "serde" @@ -2053,7 +2014,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.6.0", + "indexmap 2.7.0", "serde", "serde_derive", "serde_json", @@ -2184,15 +2145,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" [[package]] name = "tempfile" @@ -2207,12 +2162,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "termtree" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" - [[package]] name = "testcontainers" version = "0.23.1" @@ -2234,7 +2183,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "thiserror 1.0.68", + "thiserror 1.0.69", "tokio", "tokio-stream", "tokio-tar", @@ -2244,11 +2193,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl 1.0.68", + "thiserror-impl 1.0.69", ] [[package]] @@ -2262,9 +2211,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", @@ -2284,9 +2233,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.36" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "itoa", @@ -2305,9 +2254,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" dependencies = [ "num-conv", "time-core", @@ -2369,20 +2318,19 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ - "rustls 0.23.16", - "rustls-pki-types", + "rustls 0.23.20", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" dependencies = [ "futures-core", "pin-project-lite", @@ -2429,7 +2377,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.7.0", "toml_datetime", "winnow", ] @@ -2500,14 +2448,14 @@ dependencies = [ [[package]] name = "tower" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", "pin-project-lite", - "sync_wrapper 0.1.2", + "sync_wrapper", "tower-layer", "tower-service", ] @@ -2537,9 +2485,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 7e1d8ef..922389d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,17 @@ -[package] -name = "aquila" -version = "0.1.0" -edition = "2021" +[workspace] +members = [ + "aquila", + "aquila_cache", + "aquila_container", + "aquila_queue", + "aquila_store", +] -[dependencies] +[workspace.dependencies] redis = { version = "0.27.0", features = ["async-std", "tokio", "aio", "tokio-comp", "async-std-comp"] } tonic = "0.12.1" -prost = { version = "0.13.1" } tokio = { version = "1.39", features = ["rt-multi-thread", "rt", "macros"] } futures = "0.3" -prost-types = { version = "0.13.1" } -serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0" } json_env_logger2 = "0.2" log = "0.4.22" @@ -18,8 +19,18 @@ clokwerk = { version = "0.4", features = ["async"] } tucana = { version = "0.0.11", features = ["sagittarius", "aquila"] } dotenv = "0.15.0" rabbitmq-stream-client = "0.7.0" -thiserror = "2.0.0" async-trait = "0.1.81" -mockall = "0.13.0" testcontainers = "0.23.1" async-stream = "0.3.6" + +[workspace.dependencies.aquila_cache] +path = "../aquila/aquila_cache" + +[workspace.dependencies.aquila_container] +path = "../aquila/aquila_container" + +[workspace.dependencies.aquila_queue] +path = "../aquila/aquila_queue" + +[workspace.dependencies.aquila_store] +path = "../aquila/aquila_store" \ No newline at end of file diff --git a/aquila/Cargo.toml b/aquila/Cargo.toml new file mode 100644 index 0000000..af3b331 --- /dev/null +++ b/aquila/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "aquila" +version = "0.1.0" +edition = "2021" + +[dependencies] +aquila_cache = { workspace = true } +aquila_store = { workspace = true } +async-stream = { workspace = true } +async-trait = { workspace = true } +clokwerk = { workspace = true } +dotenv = { workspace = true } +futures = { workspace = true } +log = { workspace = true } +json_env_logger2 = { workspace = true } +redis = { workspace = true } +serde_json = { workspace = true } +tucana = { workspace = true } +tonic = { workspace = true } +tokio = { workspace = true } + +[dev-dependencies] +aquila_container = { workspace = true } \ No newline at end of file From 16720be4348ba9a433fac83f85bc14bf844dd5a1 Mon Sep 17 00:00:00 2001 From: raphael-goetz Date: Thu, 19 Dec 2024 12:01:53 +0100 Subject: [PATCH 2/6] ref: moved redis connection into aquila_cache --- aquila_cache/Cargo.toml | 7 +++++++ aquila_cache/src/lib.rs | 7 +++++++ src/data/mod.rs | 2 -- src/data/redis/mod.rs | 28 ---------------------------- 4 files changed, 14 insertions(+), 30 deletions(-) create mode 100644 aquila_cache/Cargo.toml create mode 100644 aquila_cache/src/lib.rs delete mode 100644 src/data/mod.rs delete mode 100644 src/data/redis/mod.rs diff --git a/aquila_cache/Cargo.toml b/aquila_cache/Cargo.toml new file mode 100644 index 0000000..13a0f49 --- /dev/null +++ b/aquila_cache/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "aquila_cache" +version = "0.1.0" +edition = "2021" + +[dependencies] +redis = { workspace = true } diff --git a/aquila_cache/src/lib.rs b/aquila_cache/src/lib.rs new file mode 100644 index 0000000..6d8ac2e --- /dev/null +++ b/aquila_cache/src/lib.rs @@ -0,0 +1,7 @@ +use redis::Client; + +pub fn build_connection(redis_url: String) -> Client { + Client::open(redis_url).unwrap_or_else(|err| { + panic!("Cannot connect to redis instance {err}") + }) +} \ No newline at end of file diff --git a/src/data/mod.rs b/src/data/mod.rs deleted file mode 100644 index c6054b7..0000000 --- a/src/data/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod rabbitmq; -pub mod redis; diff --git a/src/data/redis/mod.rs b/src/data/redis/mod.rs deleted file mode 100644 index c64adf0..0000000 --- a/src/data/redis/mod.rs +++ /dev/null @@ -1,28 +0,0 @@ -use redis::aio::MultiplexedConnection; -use redis::Client; -use testcontainers::{ContainerAsync, GenericImage}; -use testcontainers::core::{IntoContainerPort, WaitFor}; -use testcontainers::runners::AsyncRunner; - -pub fn build_connection(redis_url: String) -> Client { - Client::open(redis_url).unwrap_or_else(|err| { - panic!("Cannot connect to redis instance {err}") - }) -} - -pub async fn setup_redis_test_container() -> (MultiplexedConnection, ContainerAsync) { - let container = GenericImage::new("redis", "7.2.4") - .with_exposed_port(6379.tcp()) - .with_wait_for(WaitFor::message_on_stdout("Ready to accept connections")) - .start() - .await - .unwrap(); - - let host = container.get_host().await.unwrap(); - let host_port = container.get_host_port_ipv4(6379).await.unwrap(); - - let url = format!("redis://{host}:{host_port}"); - let client = Client::open(url.as_ref()).unwrap(); - let connection = client.get_multiplexed_async_connection().await; - (connection.unwrap(), container) -} From 5ce6077294d96c424a7790315e7cf1781b6b40c2 Mon Sep 17 00:00:00 2001 From: raphael-goetz Date: Thu, 19 Dec 2024 12:02:11 +0100 Subject: [PATCH 3/6] ref: moved redis container into aquila_container --- aquila_container/Cargo.toml | 8 ++++++++ aquila_container/src/lib.rs | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 aquila_container/Cargo.toml create mode 100644 aquila_container/src/lib.rs diff --git a/aquila_container/Cargo.toml b/aquila_container/Cargo.toml new file mode 100644 index 0000000..0ff2d08 --- /dev/null +++ b/aquila_container/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "aquila_container" +version = "0.1.0" +edition = "2021" + +[dependencies] +testcontainers = { workspace = true } +redis = { workspace = true } \ No newline at end of file diff --git a/aquila_container/src/lib.rs b/aquila_container/src/lib.rs new file mode 100644 index 0000000..bc3da81 --- /dev/null +++ b/aquila_container/src/lib.rs @@ -0,0 +1,22 @@ +use redis::aio::MultiplexedConnection; +use redis::Client; +use testcontainers::core::{IntoContainerPort, WaitFor}; +use testcontainers::runners::AsyncRunner; +use testcontainers::{ContainerAsync, GenericImage}; + +pub async fn setup_redis_test_container() -> (MultiplexedConnection, ContainerAsync) { + let container = GenericImage::new("redis", "7.2.4") + .with_exposed_port(6379.tcp()) + .with_wait_for(WaitFor::message_on_stdout("Ready to accept connections")) + .start() + .await + .unwrap(); + + let host = container.get_host().await.unwrap(); + let host_port = container.get_host_port_ipv4(6379).await.unwrap(); + + let url = format!("redis://{host}:{host_port}"); + let client = Client::open(url.as_ref()).unwrap(); + let connection = client.get_multiplexed_async_connection().await; + (connection.unwrap(), container) +} From 57628261f044a44805c7624707f8bab1751d83df Mon Sep 17 00:00:00 2001 From: raphael-goetz Date: Thu, 19 Dec 2024 12:02:35 +0100 Subject: [PATCH 4/6] ref: moved rabbitmq connection into aquila_queue --- aquila_queue/Cargo.toml | 8 ++++++++ src/data/rabbitmq/mod.rs => aquila_queue/src/lib.rs | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 aquila_queue/Cargo.toml rename src/data/rabbitmq/mod.rs => aquila_queue/src/lib.rs (95%) diff --git a/aquila_queue/Cargo.toml b/aquila_queue/Cargo.toml new file mode 100644 index 0000000..83d3da8 --- /dev/null +++ b/aquila_queue/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "aquila_queue" +version = "0.1.0" +edition = "2021" + +[dependencies] +tokio = { workspace = true } +rabbitmq-stream-client = { workspace = true } \ No newline at end of file diff --git a/src/data/rabbitmq/mod.rs b/aquila_queue/src/lib.rs similarity index 95% rename from src/data/rabbitmq/mod.rs rename to aquila_queue/src/lib.rs index 207dac7..ba2a38e 100644 --- a/src/data/rabbitmq/mod.rs +++ b/aquila_queue/src/lib.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use rabbitmq_stream_client::Environment; use tokio::sync::Mutex; -struct RedisConfiguration { +pub struct RedisConfiguration { host: String, port: u16, username: String, @@ -10,11 +10,11 @@ struct RedisConfiguration { } impl RedisConfiguration { - + pub fn new(host: String, port: u16, username: String, password: String) -> RedisConfiguration { Self {host, port, username, password} } - + } pub async fn init_rabbitmq(redis_configuration: RedisConfiguration) -> Arc>> { From 1c01050ca3dd47a56349bc347da6744a20ddcc35 Mon Sep 17 00:00:00 2001 From: raphael-goetz Date: Thu, 19 Dec 2024 12:02:56 +0100 Subject: [PATCH 5/6] ref: moved flow service into aquila_store --- aquila_store/Cargo.toml | 15 +++++++++++++++ .../flow_service.rs => aquila_store/src/lib.rs | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 aquila_store/Cargo.toml rename src/service/flow_service.rs => aquila_store/src/lib.rs (99%) diff --git a/aquila_store/Cargo.toml b/aquila_store/Cargo.toml new file mode 100644 index 0000000..b46e3c5 --- /dev/null +++ b/aquila_store/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "aquila_store" +version = "0.1.0" +edition = "2021" + +[dependencies] +tokio = {workspace = true} +tucana = {workspace = true} +redis = {workspace = true} +async-trait = {workspace = true} +log = { workspace = true} +serde_json = { workspace = true } + +[dev-dependencies] +aquila_container = {workspace = true} \ No newline at end of file diff --git a/src/service/flow_service.rs b/aquila_store/src/lib.rs similarity index 99% rename from src/service/flow_service.rs rename to aquila_store/src/lib.rs index e25e08b..6c95daf 100644 --- a/src/service/flow_service.rs +++ b/aquila_store/src/lib.rs @@ -144,8 +144,8 @@ mod tests { use redis::AsyncCommands; use tokio::sync::Mutex; use tucana::sagittarius::Flow; - use crate::data::redis::setup_redis_test_container; - use crate::service::flow_service::{FlowService, FlowServiceBase}; + use aquila_container::setup_redis_test_container; + use crate::{FlowService, FlowServiceBase}; #[tokio::test] async fn test_get_all_flow_ids_redis_error() { From 93c94726abcbe5e26593c655f3917ef62cce7411 Mon Sep 17 00:00:00 2001 From: raphael-goetz Date: Thu, 19 Dec 2024 12:03:25 +0100 Subject: [PATCH 6/6] ref: moved aquila into its own workspace module --- .gitignore | 12 +- .../configuration}/configuration.json | 0 {src => aquila/src}/client/mod.rs | 0 .../src}/client/sagittarius/action_client.rs | 0 .../src}/client/sagittarius/flow_client.rs | 113 +++++++++++++----- {src => aquila/src}/client/sagittarius/mod.rs | 0 {src => aquila/src}/configuration/config.rs | 3 +- .../src}/configuration/environment.rs | 2 +- {src => aquila/src}/configuration/mod.rs | 0 .../src}/configuration/start_configuration.rs | 58 +++++---- {src => aquila/src}/main.rs | 12 +- .../src}/server/action/action_server.rs | 0 {src => aquila/src}/server/action/mod.rs | 0 {src => aquila/src}/server/mod.rs | 0 {src => aquila/src}/service/action_service.rs | 0 {src => aquila/src}/service/mod.rs | 1 - 16 files changed, 136 insertions(+), 65 deletions(-) rename {configuration => aquila/configuration}/configuration.json (100%) rename {src => aquila/src}/client/mod.rs (100%) rename {src => aquila/src}/client/sagittarius/action_client.rs (100%) rename {src => aquila/src}/client/sagittarius/flow_client.rs (80%) rename {src => aquila/src}/client/sagittarius/mod.rs (100%) rename {src => aquila/src}/configuration/config.rs (98%) rename {src => aquila/src}/configuration/environment.rs (99%) rename {src => aquila/src}/configuration/mod.rs (100%) rename {src => aquila/src}/configuration/start_configuration.rs (74%) rename {src => aquila/src}/main.rs (89%) rename {src => aquila/src}/server/action/action_server.rs (100%) rename {src => aquila/src}/server/action/mod.rs (100%) rename {src => aquila/src}/server/mod.rs (100%) rename {src => aquila/src}/service/action_service.rs (100%) rename {src => aquila/src}/service/mod.rs (51%) diff --git a/.gitignore b/.gitignore index 3d6c2ab..d9b27fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ .gradle build/ !gradle/wrapper/gradle-wrapper.jar -!src/main/**/build/ -!src/test/**/build/ +!aquila/src/main/**/build/ +!aquila/src/test/**/build/ ### IntelliJ IDEA ### .idea/modules.xml @@ -13,8 +13,8 @@ build/ *.iml *.ipr out/ -!src/main/**/out/ -!src/test/**/out/ +!aquila/src/main/**/out/ +!aquila/src/test/**/out/ ### Eclipse ### .apt_generated @@ -25,8 +25,8 @@ out/ .springBeans .sts4-cache bin/ -!src/main/**/bin/ -!src/test/**/bin/ +!aquila/src/main/**/bin/ +!aquila/src/test/**/bin/ ### NetBeans ### /nbproject/private/ diff --git a/configuration/configuration.json b/aquila/configuration/configuration.json similarity index 100% rename from configuration/configuration.json rename to aquila/configuration/configuration.json diff --git a/src/client/mod.rs b/aquila/src/client/mod.rs similarity index 100% rename from src/client/mod.rs rename to aquila/src/client/mod.rs diff --git a/src/client/sagittarius/action_client.rs b/aquila/src/client/sagittarius/action_client.rs similarity index 100% rename from src/client/sagittarius/action_client.rs rename to aquila/src/client/sagittarius/action_client.rs diff --git a/src/client/sagittarius/flow_client.rs b/aquila/src/client/sagittarius/flow_client.rs similarity index 80% rename from src/client/sagittarius/flow_client.rs rename to aquila/src/client/sagittarius/flow_client.rs index 7b321a1..70f53f6 100644 --- a/src/client/sagittarius/flow_client.rs +++ b/aquila/src/client/sagittarius/flow_client.rs @@ -1,4 +1,4 @@ -use crate::service::flow_service::{FlowService, FlowServiceBase}; +use aquila_store::{FlowService, FlowServiceBase}; use async_trait::async_trait; use futures::StreamExt; use log::{error, info}; @@ -22,7 +22,10 @@ pub struct SagittariusFlowClientBase { /// Trait representing a service for receiving flows from `Sagittarius`. #[async_trait] pub trait SagittariusFlowClient { - async fn new(sagittarius_url: String, flow_service: Arc>) -> SagittariusFlowClientBase; + async fn new( + sagittarius_url: String, + flow_service: Arc>, + ) -> SagittariusFlowClientBase; async fn send_flow_update_request(&mut self); async fn send_start_request(&mut self); } @@ -35,7 +38,10 @@ impl SagittariusFlowClient for SagittariusFlowClientBase { /// /// Behavior: /// Will panic when a connection can`t be established - async fn new(sagittarius_url: String, flow_service: Arc>) -> SagittariusFlowClientBase { + async fn new( + sagittarius_url: String, + flow_service: Arc>, + ) -> SagittariusFlowClientBase { let client = match FlowServiceClient::connect(sagittarius_url).await { Ok(res) => res, Err(start_error) => { @@ -43,7 +49,10 @@ impl SagittariusFlowClient for SagittariusFlowClientBase { } }; - SagittariusFlowClientBase { flow_service, client } + SagittariusFlowClientBase { + flow_service, + client, + } } /// Will send a request `FlowGetRequest` to `Sagittarius` @@ -89,7 +98,10 @@ impl SagittariusFlowClient for SagittariusFlowClientBase { let mut stream = response.into_inner(); - async fn handle_response(response: FlowResponse, flow_service: Arc>) { + async fn handle_response( + response: FlowResponse, + flow_service: Arc>, + ) { match response.r#type { INSERT => { let flow = response.updated_flow; @@ -137,11 +149,14 @@ impl SagittariusFlowClient for SagittariusFlowClientBase { #[cfg(test)] mod tests { - use crate::client::sagittarius::action_client::{SagittariusActionClient, SagittariusActionClientBase}; - use crate::client::sagittarius::flow_client::{SagittariusFlowClient, SagittariusFlowClientBase}; - use crate::data::redis::setup_redis_test_container; - use crate::service::flow_service::FlowService; - use crate::service::flow_service::FlowServiceBase; + use crate::client::sagittarius::action_client::{ + SagittariusActionClient, SagittariusActionClientBase, + }; + use crate::client::sagittarius::flow_client::{ + SagittariusFlowClient, SagittariusFlowClientBase, + }; + use aquila_container::setup_redis_test_container; + use aquila_store::{FlowService, FlowServiceBase}; use async_trait::async_trait; use std::pin::Pin; use std::sync::Arc; @@ -152,8 +167,12 @@ mod tests { use tonic::codegen::tokio_stream::Stream; use tonic::transport::Server; use tonic::{Request, Response, Status}; - use tucana::sagittarius::flow_service_server::{FlowService as SagittariusFlowService, FlowServiceServer}; - use tucana::sagittarius::{Flow, FlowGetRequest, FlowGetResponse, FlowLogonRequest, FlowResponse}; + use tucana::sagittarius::flow_service_server::{ + FlowService as SagittariusFlowService, FlowServiceServer, + }; + use tucana::sagittarius::{ + Flow, FlowGetRequest, FlowGetResponse, FlowLogonRequest, FlowResponse, + }; struct MockFlowService { flow_get_result: FlowGetResponse, @@ -170,13 +189,19 @@ mod tests { #[async_trait] impl SagittariusFlowService for MockFlowService { - async fn get(&self, _request: Request) -> Result, Status> { + async fn get( + &self, + _request: Request, + ) -> Result, Status> { Ok(Response::new(self.flow_get_result.clone())) } - type UpdateStream = Pin> + Send>>; + type UpdateStream = Pin> + Send>>; - async fn update(&self, _request: Request) -> Result, Status> { + async fn update( + &self, + _request: Request, + ) -> Result, Status> { let flow = Flow { flow_id: 1, start_node: None, @@ -191,24 +216,34 @@ mod tests { }; }; - Ok(Response::new(Box::pin(response_stream) as Self::UpdateStream)) + Ok(Response::new( + Box::pin(response_stream) as Self::UpdateStream + )) } } #[async_trait] impl SagittariusFlowService for BrokenMockFlowService { - async fn get(&self, _request: Request) -> Result, Status> { + async fn get( + &self, + _request: Request, + ) -> Result, Status> { Err(Status::internal("An unhandled error occurred!")) } - type UpdateStream = Pin> + Send>>; + type UpdateStream = Pin> + Send>>; - async fn update(&self, _request: Request) -> Result, Status> { + async fn update( + &self, + _request: Request, + ) -> Result, Status> { Err(Status::internal("An unhandled error occurred!")) } } - async fn setup_sagittarius_mock(flow_get_response: FlowGetResponse) -> (JoinHandle<()>, oneshot::Sender<()>, String) { + async fn setup_sagittarius_mock( + flow_get_response: FlowGetResponse, + ) -> (JoinHandle<()>, oneshot::Sender<()>, String) { let (shutdown_tx, shutdown_rx) = oneshot::channel(); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); @@ -300,9 +335,21 @@ mod tests { async fn test_get_flows_update_only() { let response = FlowGetResponse { updated_flows: vec![ - Flow { flow_id: 1, start_node: None, definition: None }, - Flow { flow_id: 2, start_node: None, definition: None }, - Flow { flow_id: 3, start_node: None, definition: None }, + Flow { + flow_id: 1, + start_node: None, + definition: None, + }, + Flow { + flow_id: 2, + start_node: None, + definition: None, + }, + Flow { + flow_id: 3, + start_node: None, + definition: None, + }, ], deleted_flow_ids: vec![], }; @@ -337,9 +384,21 @@ mod tests { { let response = FlowGetResponse { updated_flows: vec![ - Flow { flow_id: 1, start_node: None, definition: None }, - Flow { flow_id: 2, start_node: None, definition: None }, - Flow { flow_id: 3, start_node: None, definition: None }, + Flow { + flow_id: 1, + start_node: None, + definition: None, + }, + Flow { + flow_id: 2, + start_node: None, + definition: None, + }, + Flow { + flow_id: 3, + start_node: None, + definition: None, + }, ], deleted_flow_ids: vec![], }; @@ -395,4 +454,4 @@ mod tests { let sagittarius_url = "http://127.0.0.1:25565".to_string(); let _client = SagittariusActionClientBase::new(sagittarius_url).await; } -} \ No newline at end of file +} diff --git a/src/client/sagittarius/mod.rs b/aquila/src/client/sagittarius/mod.rs similarity index 100% rename from src/client/sagittarius/mod.rs rename to aquila/src/client/sagittarius/mod.rs diff --git a/src/configuration/config.rs b/aquila/src/configuration/config.rs similarity index 98% rename from src/configuration/config.rs rename to aquila/src/configuration/config.rs index ed8d961..3420442 100644 --- a/src/configuration/config.rs +++ b/aquila/src/configuration/config.rs @@ -1,6 +1,7 @@ use std::env; use std::fmt::{Debug, Display}; use std::str::FromStr; +use dotenv::from_filename; use log::{error, info}; use crate::configuration::environment::Environment; @@ -48,7 +49,7 @@ pub struct Config { /// Searches for the env. file at root level. Filename: `.env` impl Config { pub fn new() -> Self { - let result = dotenv::from_filename(".env"); + let result = from_filename("../../../.env"); match result { Ok(_) => info!(".env file loaded successfully"), Err(e) => error!("Error loading .env file: {}", e), diff --git a/src/configuration/environment.rs b/aquila/src/configuration/environment.rs similarity index 99% rename from src/configuration/environment.rs rename to aquila/src/configuration/environment.rs index 02f9b5c..afea0ce 100644 --- a/src/configuration/environment.rs +++ b/aquila/src/configuration/environment.rs @@ -12,4 +12,4 @@ impl Environment { _ => Environment::Development, } } -} \ No newline at end of file +} diff --git a/src/configuration/mod.rs b/aquila/src/configuration/mod.rs similarity index 100% rename from src/configuration/mod.rs rename to aquila/src/configuration/mod.rs diff --git a/src/configuration/start_configuration.rs b/aquila/src/configuration/start_configuration.rs similarity index 74% rename from src/configuration/start_configuration.rs rename to aquila/src/configuration/start_configuration.rs index d0580ac..101a511 100644 --- a/src/configuration/start_configuration.rs +++ b/aquila/src/configuration/start_configuration.rs @@ -1,16 +1,17 @@ -use std::fs::File; -use std::io::Read; -use std::sync::Arc; +use crate::client::sagittarius::flow_client::{SagittariusFlowClient, SagittariusFlowClientBase}; +use crate::configuration::config::Config; +use aquila_store::{FlowService, FlowServiceBase}; use async_trait::async_trait; -use clokwerk::{AsyncScheduler}; +use clokwerk::AsyncScheduler; use clokwerk::Interval::Seconds; use log::{debug, error, info}; use redis::aio::MultiplexedConnection; +use serde_json::from_str; +use std::fs::File; +use std::io::Read; +use std::sync::Arc; use tokio::sync::Mutex; use tucana::sagittarius::Flow; -use crate::client::sagittarius::flow_client::{SagittariusFlowClient, SagittariusFlowClientBase}; -use crate::configuration::config::Config; -use crate::service::flow_service::{FlowService, FlowServiceBase}; pub struct StartConfigurationBase { connection_arc: Arc>>, @@ -19,7 +20,10 @@ pub struct StartConfigurationBase { #[async_trait] pub trait StartConfiguration { - async fn new(connection_arc: Arc>>, config: Config) -> StartConfigurationBase; + async fn new( + connection_arc: Arc>>, + config: Config, + ) -> StartConfigurationBase; async fn init_flows_from_sagittarius(&mut self); async fn init_flows_from_json(mut self); } @@ -27,8 +31,14 @@ pub trait StartConfiguration { /// `Aquila's` startup configuration logic. #[async_trait] impl StartConfiguration for StartConfigurationBase { - async fn new(connection_arc: Arc>>, config: Config) -> StartConfigurationBase { - StartConfigurationBase { connection_arc, config } + async fn new( + connection_arc: Arc>>, + config: Config, + ) -> StartConfigurationBase { + StartConfigurationBase { + connection_arc, + config, + } } /// Function to initialize the connection to `Sagittarius` to receive latest flows. @@ -43,7 +53,8 @@ impl StartConfiguration for StartConfigurationBase { async fn init_flows_from_sagittarius(&mut self) { let flow_service = FlowServiceBase::new(self.connection_arc.clone()).await; let flow_service_arc = Arc::new(Mutex::new(flow_service)); - let mut sagittarius_client = SagittariusFlowClientBase::new(self.config.backend_url.clone(), flow_service_arc).await; + let mut sagittarius_client = + SagittariusFlowClientBase::new(self.config.backend_url.clone(), flow_service_arc).await; if !self.config.enable_scheduled_update { info!("Receiving flows from sagittarius once"); @@ -55,16 +66,14 @@ impl StartConfiguration for StartConfigurationBase { let schedule_interval = self.config.update_schedule_interval; let mut scheduler = AsyncScheduler::new(); - scheduler - .every(Seconds(schedule_interval)) - .run(move || { - let local_flow_client = Arc::new(Mutex::new(sagittarius_client.clone())); + scheduler.every(Seconds(schedule_interval)).run(move || { + let local_flow_client = Arc::new(Mutex::new(sagittarius_client.clone())); - async move { - let mut current_flow_client = local_flow_client.lock().await; - current_flow_client.send_start_request().await - } - }); + async move { + let mut current_flow_client = local_flow_client.lock().await; + current_flow_client.send_start_request().await + } + }); } /// Function to start `Aquila` from a JSON containing the flows. @@ -105,15 +114,18 @@ impl StartConfiguration for StartConfigurationBase { } } - let flows: Vec = match serde_json::from_str(&data) { + let flows: Vec = match from_str(&data) { Ok(flows) => flows, Err(error) => { error!("Error deserializing json file {}", error); - panic!("There was a problem deserializing the json file: {:?}", error); + panic!( + "There was a problem deserializing the json file: {:?}", + error + ); } }; info!("Loaded {} Flows!", &flows.len()); flow_service.insert_flows(flows).await; } -} \ No newline at end of file +} diff --git a/src/main.rs b/aquila/src/main.rs similarity index 89% rename from src/main.rs rename to aquila/src/main.rs index 41226a3..3ce3bc1 100644 --- a/src/main.rs +++ b/aquila/src/main.rs @@ -1,19 +1,19 @@ +use crate::configuration::config::Config; use crate::configuration::start_configuration::{StartConfiguration, StartConfigurationBase}; +use aquila_cache::build_connection; +use std::env::set_var; use std::sync::Arc; use tokio::sync::Mutex; -use crate::configuration::config::Config; -use crate::data::redis::build_connection; mod client; mod configuration; -mod data; -mod service; mod server; +mod service; #[tokio::main] async fn main() { // Configure logging - std::env::set_var("RUST_LOG", "info"); + set_var("RUST_LOG", "info"); json_env_logger2::init(); json_env_logger2::panic_hook(); @@ -29,4 +29,4 @@ async fn main() { let mut startup = StartConfigurationBase::new(connection, config).await; startup.init_flows_from_sagittarius().await; startup.init_flows_from_json().await -} \ No newline at end of file +} diff --git a/src/server/action/action_server.rs b/aquila/src/server/action/action_server.rs similarity index 100% rename from src/server/action/action_server.rs rename to aquila/src/server/action/action_server.rs diff --git a/src/server/action/mod.rs b/aquila/src/server/action/mod.rs similarity index 100% rename from src/server/action/mod.rs rename to aquila/src/server/action/mod.rs diff --git a/src/server/mod.rs b/aquila/src/server/mod.rs similarity index 100% rename from src/server/mod.rs rename to aquila/src/server/mod.rs diff --git a/src/service/action_service.rs b/aquila/src/service/action_service.rs similarity index 100% rename from src/service/action_service.rs rename to aquila/src/service/action_service.rs diff --git a/src/service/mod.rs b/aquila/src/service/mod.rs similarity index 51% rename from src/service/mod.rs rename to aquila/src/service/mod.rs index 6e7882b..5018d1d 100644 --- a/src/service/mod.rs +++ b/aquila/src/service/mod.rs @@ -1,2 +1 @@ -pub mod flow_service; pub mod action_service; \ No newline at end of file