diff --git a/.env b/.env index 4a92cb9..c18c27e 100644 --- a/.env +++ b/.env @@ -1,9 +1,8 @@ REDIS_URL='redis://localhost:6379' ENVIRONMENT='development' MODE='static' -UPDATE_SCHEDULE_INTERVAL=180 +RUNTIME_TOKEN="" -SESSION_TOKEN= BACKEND_HOST= BACKEND_PORT= RABBITMQ_HOST= diff --git a/Cargo.lock b/Cargo.lock index 49232f2..7d256d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,9 +43,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "aquila" @@ -53,6 +53,7 @@ version = "0.1.0" dependencies = [ "aquila_cache", "aquila_container", + "aquila_grpc", "aquila_store", "async-stream", "async-trait", @@ -82,6 +83,13 @@ dependencies = [ "testcontainers", ] +[[package]] +name = "aquila_grpc" +version = "0.1.0" +dependencies = [ + "tonic", +] + [[package]] name = "aquila_queue" version = "0.1.0" @@ -162,9 +170,9 @@ dependencies = [ [[package]] name = "async-io" -version = "2.3.4" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" +checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" dependencies = [ "async-lock", "cfg-if", @@ -235,7 +243,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -252,7 +260,7 @@ checksum = "1b1244b10dcd56c92219da4e14caa97e312079e185f04ba3eea25061561dc0a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -430,15 +438,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cc" -version = "1.2.4" +version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf" +checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" dependencies = [ "shlex", ] @@ -520,9 +528,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "darling" @@ -545,7 +553,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -556,7 +564,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -593,7 +601,18 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.87", + "syn 2.0.94", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.94", ] [[package]] @@ -636,12 +655,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -674,9 +693,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" +checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2" dependencies = [ "event-listener 5.3.1", "pin-project-lite", @@ -684,9 +703,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "filetime" @@ -771,9 +790,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f1fa2f9765705486b33fd2acf1577f8ec449c2ba1f318ae5447697b7c08d210" +checksum = "cef40d21ae2c515b51041df9ed313ed21e572df340ea58a922a0aefe7e8891a1" dependencies = [ "fastrand", "futures-core", @@ -790,7 +809,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -895,12 +914,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "hermit-abi" version = "0.4.0" @@ -1006,9 +1019,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.4" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6884a48c6826ec44f524c7456b163cebe9e55a18d7b5e307cb4f100371cc767" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", "http", @@ -1091,6 +1104,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.94", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1099,12 +1230,23 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "icu_normalizer", + "icu_properties", ] [[package]] @@ -1149,16 +1291,17 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -1185,9 +1328,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libredox" @@ -1206,6 +1349,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + [[package]] name = "lock_api" version = "0.4.12" @@ -1245,20 +1394,19 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", ] [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi 0.3.9", "libc", "wasi", "windows-sys 0.52.0", @@ -1328,14 +1476,14 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] name = "object" -version = "0.36.5" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] @@ -1354,9 +1502,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "ordered-float" -version = "4.5.0" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c65ee1f9701bf938026630b455d5315f490640234259037edb259798b3bcf85e" +checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" dependencies = [ "num-traits", ] @@ -1412,7 +1560,7 @@ dependencies = [ "regex", "regex-syntax", "structmeta", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -1448,7 +1596,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -1476,13 +1624,13 @@ dependencies = [ [[package]] name = "polling" -version = "3.7.3" +version = "3.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" +checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" dependencies = [ "cfg-if", "concurrent-queue", - "hermit-abi 0.4.0", + "hermit-abi", "pin-project-lite", "rustix", "tracing", @@ -1511,7 +1659,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -1525,9 +1673,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -1558,7 +1706,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.87", + "syn 2.0.94", "tempfile", ] @@ -1572,7 +1720,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -1599,9 +1747,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -1621,7 +1769,7 @@ dependencies = [ "rabbitmq-stream-protocol", "rand", "rustls-pemfile 1.0.4", - "thiserror 2.0.8", + "thiserror 2.0.9", "tokio", "tokio-rustls 0.24.1", "tokio-stream", @@ -1778,15 +1926,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.38" +version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1875,9 +2023,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "ryu" @@ -1941,22 +2089,22 @@ checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" [[package]] name = "serde" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -1979,7 +2127,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -1996,9 +2144,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" dependencies = [ "base64 0.22.1", "chrono", @@ -2014,14 +2162,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -2062,9 +2210,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -2076,6 +2224,12 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.11.1" @@ -2091,7 +2245,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta-derive", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -2102,7 +2256,7 @@ checksum = "152a0b65a590ff6c3da95cabe2353ee04e6167c896b28e3b14478c2636c922fc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -2124,9 +2278,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3" dependencies = [ "proc-macro2", "quote", @@ -2139,14 +2293,26 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.94", +] + [[package]] name = "tempfile" -version = "3.13.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", + "getrandom", "once_cell", "rustix", "windows-sys 0.59.0", @@ -2192,11 +2358,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.8" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f5383f3e0071702bf93ab5ee99b52d26936be9dedd9413067cbdcddcb6141a" +checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" dependencies = [ - "thiserror-impl 2.0.8", + "thiserror-impl 2.0.9", ] [[package]] @@ -2207,18 +2373,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] name = "thiserror-impl" -version = "2.0.8" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f357fcec90b3caef6623a099691be676d033b40a058ac95d2a6ade6fa0c943" +checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -2253,20 +2419,15 @@ dependencies = [ ] [[package]] -name = "tinyvec" -version = "1.8.0" +name = "tinystr" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" dependencies = [ - "tinyvec_macros", + "displaydoc", + "zerovec", ] -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "tokio" version = "1.42.0" @@ -2293,7 +2454,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -2344,9 +2505,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", @@ -2413,7 +2574,7 @@ dependencies = [ "prost-build", "prost-types", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] @@ -2464,9 +2625,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-attributes", @@ -2481,14 +2642,14 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", ] [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", ] @@ -2514,26 +2675,11 @@ dependencies = [ "tonic-build", ] -[[package]] -name = "unicode-bidi" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" - [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" - -[[package]] -name = "unicode-normalization" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" -dependencies = [ - "tinyvec", -] +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-segmentation" @@ -2549,9 +2695,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -2559,6 +2705,18 @@ dependencies = [ "serde", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "uuid" version = "1.11.0" @@ -2588,9 +2746,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -2599,36 +2757,36 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.45" +version = "0.4.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2636,28 +2794,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" dependencies = [ "js-sys", "wasm-bindgen", @@ -2844,13 +3002,25 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "39281189af81c07ec09db316b302a3e67bf9bd7cbf6c820b50e35fee9c2fa980" dependencies = [ "memchr", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "xattr" version = "1.3.1" @@ -2862,6 +3032,30 @@ dependencies = [ "rustix", ] +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.94", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -2880,7 +3074,28 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.94", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.94", + "synstructure", ] [[package]] @@ -2888,3 +3103,25 @@ name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.94", +] diff --git a/Cargo.toml b/Cargo.toml index d52ca43..211561b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ members = [ "aquila", "aquila_cache", "aquila_container", + "aquila_grpc", "aquila_queue", "aquila_store", ] @@ -31,5 +32,8 @@ path = "../aquila/aquila_container" [workspace.dependencies.aquila_queue] path = "../aquila/aquila_queue" +[workspace.dependencies.aquila_grpc] +path = "../aquila/aquila_grpc" + [workspace.dependencies.aquila_store] path = "../aquila/aquila_store" \ No newline at end of file diff --git a/aquila/Cargo.toml b/aquila/Cargo.toml index 08a8d07..606fbbc 100644 --- a/aquila/Cargo.toml +++ b/aquila/Cargo.toml @@ -17,6 +17,7 @@ serde_json = { workspace = true } tucana = { workspace = true } tonic = { workspace = true } tokio = { workspace = true } +aquila_grpc = {workspace = true} [dev-dependencies] aquila_container = { workspace = true } \ No newline at end of file diff --git a/aquila/src/client/sagittarius/action_client.rs b/aquila/src/client/sagittarius/action_client.rs index 2dcd6d2..239ea88 100644 --- a/aquila/src/client/sagittarius/action_client.rs +++ b/aquila/src/client/sagittarius/action_client.rs @@ -1,24 +1,34 @@ +use aquila_grpc::get_authorization_metadata; use async_trait::async_trait; use log::{error, info}; use tonic::transport::Channel; -use tonic::{Request, Response}; +use tonic::{Extensions, Request, Response}; use tucana::aquila::InformationRequest; use tucana::sagittarius::action_service_client::ActionServiceClient; -use tucana::sagittarius::{ActionLogoffRequest, ActionLogoffResponse, ActionLogonRequest, ActionLogonResponse}; +use tucana::sagittarius::{ + ActionLogoffRequest, ActionLogoffResponse, ActionLogonRequest, ActionLogonResponse, +}; /// Struct representing a service for sending flows received from an `Action` to `Sagittarius`. /// Part that informs `Sagittarius` pub struct SagittariusActionClientBase { client: ActionServiceClient, + token: String, } /// Trait representing a service for sending flows received from an `Action` to `Sagittarius`. /// Part that informs `Sagittarius` #[async_trait] pub trait SagittariusActionClient { - async fn new(sagittarius_url: String) -> SagittariusActionClientBase; - async fn send_action_logon_request(&mut self, information: InformationRequest) -> Result, tonic::Status>; - async fn send_action_logoff_request(&mut self, identifier: String) -> Result, tonic::Status>; + async fn new(sagittarius_url: String, token: String) -> SagittariusActionClientBase; + async fn send_action_logon_request( + &mut self, + information: InformationRequest, + ) -> Result, tonic::Status>; + async fn send_action_logoff_request( + &mut self, + identifier: String, + ) -> Result, tonic::Status>; } /// Implementation of the service for sending flows received from an `Action` to `Sagittarius`. @@ -29,24 +39,31 @@ impl SagittariusActionClient for SagittariusActionClientBase { /// /// Behavior: /// Will panic when a connection can`t be established - async fn new(sagittarius_url: String) -> SagittariusActionClientBase { + async fn new(sagittarius_url: String, token: String) -> SagittariusActionClientBase { let client = match ActionServiceClient::connect(sagittarius_url).await { - Ok(res) => { res } + Ok(res) => res, Err(start_error) => { panic!("Can't start client {:?}", start_error); } }; - SagittariusActionClientBase { client } + SagittariusActionClientBase { client, token } } /// Sends `Sagittarius` the information that a `Action` went online. - async fn send_action_logon_request(&mut self, information: InformationRequest) -> Result, tonic::Status> { - let request = Request::new(ActionLogonRequest { - identifier: information.identifier, - function_definition: information.function_definition, - parameter_definition: information.parameter_definition, - }); + async fn send_action_logon_request( + &mut self, + information: InformationRequest, + ) -> Result, tonic::Status> { + let request = Request::from_parts( + get_authorization_metadata(&self.token), + Extensions::new(), + ActionLogonRequest { + identifier: information.identifier, + function_definition: information.function_definition, + parameter_definition: information.parameter_definition, + }, + ); match self.client.logon(request).await { Err(status) => { @@ -61,10 +78,15 @@ impl SagittariusActionClient for SagittariusActionClientBase { } /// Sends `Sagittarius` the information that a `Action` went offline. - async fn send_action_logoff_request(&mut self, identifier: String) -> Result, tonic::Status> { - let request = Request::new(ActionLogoffRequest { - identifier - }); + async fn send_action_logoff_request( + &mut self, + identifier: String, + ) -> Result, tonic::Status> { + let request = Request::from_parts( + get_authorization_metadata(&self.token), + Extensions::new(), + ActionLogoffRequest { identifier }, + ); match self.client.logoff(request).await { Err(status) => { @@ -82,13 +104,13 @@ impl SagittariusActionClient for SagittariusActionClientBase { #[cfg(test)] mod tests { use super::*; + use std::net::SocketAddr; + use tokio::task::JoinHandle; use tonic::{transport::Server, Request, Response, Status}; use tucana::sagittarius::{ action_service_server::{ActionService, ActionServiceServer}, ActionLogoffRequest, ActionLogoffResponse, ActionLogonRequest, ActionLogonResponse, }; - use std::net::SocketAddr; - use tokio::task::JoinHandle; use tucana::shared::{RuntimeFunctionDefinition, RuntimeParameterDefinition}; #[derive(Debug, Default)] @@ -168,36 +190,44 @@ mod tests { #[tokio::test] async fn test_sagittarius_action_client_integration() { let (sagittarius, url) = setup_sagittarius_mock().await; - let mut client = SagittariusActionClientBase::new(url).await; + let mut client = SagittariusActionClientBase::new(url, String::from("")).await; let information = InformationRequest { identifier: "test_identifier".to_string(), function_definition: vec![RuntimeFunctionDefinition { id: "".to_string() }], - parameter_definition: vec![RuntimeParameterDefinition { name: "".to_string() }], + parameter_definition: vec![RuntimeParameterDefinition { + name: "".to_string(), + }], }; let logon_result = client.send_action_logon_request(information.clone()).await; assert!(logon_result.is_ok()); - let logoff_result = client.send_action_logoff_request(information.identifier.clone()).await; + let logoff_result = client + .send_action_logoff_request(information.identifier.clone()) + .await; assert!(logoff_result.is_ok()); } #[tokio::test] async fn test_broken_sagittarius_action_client_integration() { let (sagittarius, url) = setup_broken_sagittarius_mock().await; - let mut client = SagittariusActionClientBase::new(url).await; + let mut client = SagittariusActionClientBase::new(url, String::from("")).await; let information: InformationRequest = InformationRequest { identifier: "test_identifier".to_string(), function_definition: vec![RuntimeFunctionDefinition { id: "".to_string() }], - parameter_definition: vec![RuntimeParameterDefinition { name: "".to_string() }], + parameter_definition: vec![RuntimeParameterDefinition { + name: "".to_string(), + }], }; let logon_result = client.send_action_logon_request(information.clone()).await; assert!(logon_result.is_err()); - let logoff_result = client.send_action_logoff_request(information.identifier.clone()).await; + let logoff_result = client + .send_action_logoff_request(information.identifier.clone()) + .await; assert!(logoff_result.is_err()); drop(sagittarius) } @@ -206,6 +236,6 @@ mod tests { #[should_panic(expected = "Can't start client")] async fn test_sagittarius_action_client_new_should_panic() { let sagittarius_url = "http://127.0.0.1:12345".to_string(); - let _client = SagittariusActionClientBase::new(sagittarius_url).await; + let _client = SagittariusActionClientBase::new(sagittarius_url, String::from("")).await; } -} \ No newline at end of file +} diff --git a/aquila/src/client/sagittarius/flow_client.rs b/aquila/src/client/sagittarius/flow_client.rs index 8403f85..c3c65df 100644 --- a/aquila/src/client/sagittarius/flow_client.rs +++ b/aquila/src/client/sagittarius/flow_client.rs @@ -1,3 +1,4 @@ +use aquila_grpc::get_authorization_metadata; use aquila_store::{FlowService, FlowServiceBase}; use async_trait::async_trait; use futures::StreamExt; @@ -5,7 +6,7 @@ use log::{debug, error}; use std::sync::Arc; use tokio::sync::Mutex; use tonic::transport::Channel; -use tonic::Request; +use tonic::{Extensions, Request}; use tucana::sagittarius::flow_response::Data; use tucana::sagittarius::flow_service_client::FlowServiceClient; use tucana::sagittarius::{FlowLogonRequest, FlowResponse}; @@ -15,6 +16,7 @@ use tucana::sagittarius::{FlowLogonRequest, FlowResponse}; pub struct SagittariusFlowClientBase { flow_service: Arc>, client: FlowServiceClient, + token: String, } /// Trait representing a service for receiving flows from `Sagittarius`. @@ -23,7 +25,9 @@ pub trait SagittariusFlowClient { async fn new( sagittarius_url: String, flow_service: Arc>, + token: String, ) -> SagittariusFlowClientBase; + async fn handle_response(response: FlowResponse, flow_service: Arc>); async fn init_flow_stream(&mut self); } @@ -38,6 +42,7 @@ impl SagittariusFlowClient for SagittariusFlowClientBase { async fn new( sagittarius_url: String, flow_service: Arc>, + token: String, ) -> SagittariusFlowClientBase { let client = match FlowServiceClient::connect(sagittarius_url).await { Ok(res) => res, @@ -49,6 +54,46 @@ impl SagittariusFlowClient for SagittariusFlowClientBase { SagittariusFlowClientBase { flow_service, client, + token, + } + } + + async fn handle_response(response: FlowResponse, flow_service: Arc>) { + let data = match response.data { + Some(data) => data, + None => { + debug!("Received a FlowLogonResponse but no FlowLogonResponse"); + return; + } + }; + + match data { + // Will delete the flow id it receives + Data::DeletedFlowId(id) => { + let mut flow_service = flow_service.lock().await; + flow_service.delete_flow(id).await; + } + //Will update the flow it receives + Data::UpdatedFlow(flow) => { + let mut flow_service = flow_service.lock().await; + flow_service.insert_flow(flow).await; + } + //WIll drop all flows that it holds and insert all new ones + Data::Flows(flows) => { + let mut flow_service = flow_service.lock().await; + let result_ids = flow_service.get_all_flow_ids().await; + + let ids = match result_ids { + Ok(ids) => ids, + Err(err) => { + error!("Service wasn't able to get ids {}", err); + return; + } + }; + + flow_service.delete_flows(ids).await; + flow_service.insert_flows(flows.flows).await; + } } } @@ -56,7 +101,12 @@ impl SagittariusFlowClient for SagittariusFlowClientBase { /// Will establish a stream. /// `Sagittarius` will send update/delete commands and the flow to do that with. async fn init_flow_stream(&mut self) { - let request = Request::new(FlowLogonRequest {}); + let request = Request::from_parts( + get_authorization_metadata(&self.token), + Extensions::new(), + FlowLogonRequest {}, + ); + let response = match self.client.update(request).await { Ok(res) => res, Err(status) => { @@ -67,52 +117,10 @@ impl SagittariusFlowClient for SagittariusFlowClientBase { let mut stream = response.into_inner(); - async fn handle_response( - response: FlowResponse, - flow_service: Arc>, - ) { - let data = match response.data { - Some(data) => data, - None => { - debug!("Received a FlowLogonResponse but no FlowLogonResponse"); - return; - } - }; - - match data { - // Will delete the flow id it receives - Data::DeletedFlowId(id) => { - let mut flow_service = flow_service.lock().await; - flow_service.delete_flow(id).await; - } - //Will update the flow it receives - Data::UpdatedFlow(flow) => { - let mut flow_service = flow_service.lock().await; - flow_service.insert_flow(flow).await; - } - //WIll drop all flows that it holds and insert all new ones - Data::Flows(flows) => { - let mut flow_service = flow_service.lock().await; - let result_ids = flow_service.get_all_flow_ids().await; - - let ids = match result_ids { - Ok(ids) => ids, - Err(err) => { - error!("Service wasn't able to get ids {}", err); - return; - } - }; - - flow_service.delete_flows(ids).await; - flow_service.insert_flows(flows.flows).await; - } - } - } - while let Some(result) = stream.next().await { match result { Ok(res) => { - handle_response(res, self.flow_service.clone()).await; + Self::handle_response(res, self.flow_service.clone()).await; } Err(status) => { error!("Received a {status}, can't retrieve flows from Sagittarius"); diff --git a/aquila/src/configuration/config.rs b/aquila/src/configuration/config.rs index 62196ac..bcbbb40 100644 --- a/aquila/src/configuration/config.rs +++ b/aquila/src/configuration/config.rs @@ -30,7 +30,7 @@ pub struct Config { pub flow_fallback_path: String, /// Verification Token required for internal communication - pub session_token: String, + pub runtime_token: String, /// URL to the `Sagittarius` Server. pub backend_url: String, @@ -56,7 +56,7 @@ impl Config { "FLOW_FALLBACK_PATH", "configuration/configuration.json", ), - session_token: Self::get_string("SESSION_TOKEN", "default_session_token"), + runtime_token: Self::get_string("RUNTIME_TOKEN", "default_session_token"), backend_url: Self::get_string("BACKEND_URL", "http://localhost:8080"), } } diff --git a/aquila/src/configuration/start_configuration.rs b/aquila/src/configuration/start_configuration.rs index 6196698..12b3b87 100644 --- a/aquila/src/configuration/start_configuration.rs +++ b/aquila/src/configuration/start_configuration.rs @@ -56,8 +56,12 @@ impl StartConfiguration for StartConfigurationBase { 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, + self.config.runtime_token.clone(), + ) + .await; sagittarius_client.init_flow_stream().await } diff --git a/aquila_grpc/Cargo.toml b/aquila_grpc/Cargo.toml new file mode 100644 index 0000000..2204e71 --- /dev/null +++ b/aquila_grpc/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "aquila_grpc" +version = "0.1.0" +edition = "2021" + +[dependencies] +tonic = {workspace = true} + +[lib] +doctest = true \ No newline at end of file diff --git a/aquila_grpc/src/lib.rs b/aquila_grpc/src/lib.rs new file mode 100644 index 0000000..9b6ed40 --- /dev/null +++ b/aquila_grpc/src/lib.rs @@ -0,0 +1,32 @@ +use std::str::FromStr; +use tonic::metadata::{MetadataMap, MetadataValue}; + +/// get_authorization_metadata +/// +/// Creates a `MetadataMap` that contains the defined token as a value of the `authorization` key +/// Used for setting the runtime_token to authorize Sagittarius request +/// +/// # Examples +/// +/// ``` +/// use aquila_grpc::get_authorization_metadata; +/// let token = String::from("token"); +/// let metadata = get_authorization_metadata(&token); +/// assert!(metadata.get("authorization").is_some()); +/// assert_eq!(metadata.get("authorization").unwrap(), "token"); +/// ``` +pub fn get_authorization_metadata(token: &String) -> MetadataMap { + let metadata_value = match MetadataValue::from_str(token) { + Ok(value) => value, + Err(error) => { + panic!( + "An error occurred trying to convert runtime_token into metadata: {}", + error + ); + } + }; + + let mut map = MetadataMap::new(); + map.insert("authorization", metadata_value); + map +}