diff --git a/Cargo.lock b/Cargo.lock index 44f3f0074..c57b1e9b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,9 +152,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 = "arbitrary" @@ -201,9 +201,9 @@ dependencies = [ [[package]] name = "async-broadcast" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cd0e2e25ea8e5f7e9df04578dc6cf5c83577fd09b1a46aaf5c85e1c33f2a7e" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" dependencies = [ "event-listener", "event-listener-strategy", @@ -233,7 +233,7 @@ dependencies = [ "async-trait", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "tokio", ] @@ -291,7 +291,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -302,7 +302,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -365,9 +365,9 @@ dependencies = [ [[package]] name = "aws-lc-rs" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f47bb8cc16b669d267eeccf585aea077d0882f4777b1c1f740217885d6e6e5a3" +checksum = "f409eb70b561706bf8abba8ca9c112729c481595893fd06a2dd9af8ed8441148" dependencies = [ "aws-lc-sys", "paste", @@ -376,9 +376,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.23.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2101df3813227bbaaaa0b04cd61c534c7954b22bd68d399b440be937dc63ff7" +checksum = "8478a5c29ead3f3be14aff8a202ad965cf7da6856860041bfca271becf8ba48b" dependencies = [ "bindgen", "cc", @@ -411,7 +411,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "itoa", "matchit", @@ -424,9 +424,9 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", - "tower 0.5.1", + "tower 0.5.2", "tower-layer", "tower-service", "tracing", @@ -447,7 +447,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.2", + "sync_wrapper", "tower-layer", "tower-service", "tracing", @@ -465,7 +465,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "pin-project-lite", "rustls", @@ -568,7 +568,7 @@ dependencies = [ "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.90", + "syn 2.0.93", "which", ] @@ -648,14 +648,14 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] name = "bstr" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" +checksum = "786a307d683a5bf92e6fd5fd69a7eb613751668d1d8d67d802846dfe367c62c8" dependencies = [ "memchr", "regex-automata 0.4.9", @@ -703,9 +703,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.20.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" [[package]] name = "byteorder" @@ -774,9 +774,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.3" +version = "1.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27f657647bcff5394bf56c7317665bbf790a137a50eaaa5c6bfbb9e27a518f2d" +checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333" dependencies = [ "jobserver", "libc", @@ -812,9 +812,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[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", @@ -870,9 +870,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.38" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9647a559c112175f17cf724dc72d3645680a883c58481332779192b0d8e7a01" +checksum = "ac2e663e3e3bed2d32d065a8404024dad306e699a04263ec59919529f803aee9" dependencies = [ "clap", ] @@ -886,7 +886,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -912,12 +912,12 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "colored" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -1076,18 +1076,18 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.13" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -1104,9 +1104,9 @@ dependencies = [ [[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 = "crossterm" @@ -1175,7 +1175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" dependencies = [ "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1208,7 +1208,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1219,7 +1219,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1285,7 +1285,7 @@ checksum = "2cdc8d50f426189eef89dac62fabfa0abb27d5cc008f25bf4156a0203325becc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1296,7 +1296,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1317,7 +1317,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1327,7 +1327,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1348,7 +1348,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "unicode-xid", ] @@ -1398,7 +1398,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1451,9 +1451,9 @@ dependencies = [ [[package]] name = "env_filter" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ "log", "regex", @@ -1461,9 +1461,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0" dependencies = [ "anstream", "anstyle", @@ -1478,6 +1478,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "err_trail" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf171eed0f19d57286fabcc6634d5c85b1054921f531a44c962225bbb06190b4" +dependencies = [ + "tracing", +] + [[package]] name = "errno" version = "0.3.10" @@ -1490,24 +1499,26 @@ dependencies = [ [[package]] name = "error_set" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ad3479a6b04587258cc631600172b97e955d63109f85bc84c78a935960f135" +checksum = "7a5cfac9e0befd56d4a6f7ffdad3558f798d1fc005dfaaa99ed5202efd7abec6" dependencies = [ + "err_trail", "error_set_impl", "tracing", ] [[package]] name = "error_set_impl" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a43c6448a712f52898b4b25a4efe8a802fa933d6ba0d4e8695346a562dc7aa53" +checksum = "a4937429fd4e1421897226f4337c9e1a4c4206f886828e51dea621cbdcb9fd38" dependencies = [ "indices", "proc-macro2", "quote", - "syn 2.0.90", + "regex", + "syn 2.0.93", ] [[package]] @@ -1539,9 +1550,9 @@ checksum = "b877ceff2e3d2922823bab7960826ce198181f9c25f75d67b913fde9237e2da6" [[package]] name = "fastrand" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "figlet-rs" @@ -1576,9 +1587,9 @@ dependencies = [ [[package]] name = "float-cmp" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8" dependencies = [ "num-traits", ] @@ -1693,7 +1704,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1780,9 +1791,9 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "h2" @@ -1866,11 +1877,11 @@ dependencies = [ [[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]] @@ -1955,9 +1966,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.31" +version = "0.14.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" dependencies = [ "bytes", "futures-channel", @@ -1978,9 +1989,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", @@ -1999,13 +2010,13 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.3" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", "http 1.2.0", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "rustls", "rustls-pki-types", @@ -2021,7 +2032,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "pin-project-lite", "tokio", @@ -2035,7 +2046,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper 0.14.31", + "hyper 0.14.32", "native-tls", "tokio", "tokio-native-tls", @@ -2049,7 +2060,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "native-tls", "tokio", @@ -2068,7 +2079,7 @@ dependencies = [ "futures-util", "http 1.2.0", "http-body 1.0.1", - "hyper 1.5.1", + "hyper 1.5.2", "pin-project-lite", "socket2", "tokio", @@ -2214,7 +2225,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -2531,9 +2542,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.167" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libdbus-sys" @@ -2666,7 +2677,7 @@ checksum = "5cf92c10c7e361d6b99666ec1c6f9805b0bea2c3bd8c78dc6fe98ac5bd78db11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -2713,9 +2724,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[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", ] @@ -2912,9 +2923,9 @@ dependencies = [ [[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", ] @@ -2954,7 +2965,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -3156,16 +3167,16 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.7", + "redox_syscall 0.5.8", "smallvec", "windows-targets 0.52.6", ] [[package]] name = "passterm" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1e7a4c22a6cce262e8c126b3052e6baf05d4dd5699ef23ed6dadd85c2a1194a" +checksum = "150ca2316c7813c688677784f20bb0a9efab639415ae1961869863ee99a81e51" dependencies = [ "libc", ] @@ -3206,7 +3217,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -3242,7 +3253,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -3292,9 +3303,9 @@ dependencies = [ [[package]] name = "predicates" -version = "3.1.2" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" +checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" dependencies = [ "anstyle", "difflib", @@ -3306,15 +3317,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" +checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" [[package]] name = "predicates-tree" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" +checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" dependencies = [ "predicates-core", "termtree", @@ -3327,7 +3338,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -3380,7 +3391,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "version_check", "yansi", ] @@ -3405,7 +3416,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -3428,7 +3439,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -3462,9 +3473,9 @@ dependencies = [ [[package]] name = "quanta" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5" +checksum = "773ce68d0bb9bc7ef20be3536ffe94e223e1f365bd374108b2659fac0c65cfe6" dependencies = [ "crossbeam-utils", "libc", @@ -3526,9 +3537,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.7" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" +checksum = "1c40286217b4ba3a71d644d752e6a0b71f13f1b6a2c5311acfcbe0c2418ed904" dependencies = [ "cfg_aliases", "libc", @@ -3540,9 +3551,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", ] @@ -3614,9 +3625,9 @@ dependencies = [ [[package]] name = "rcgen" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54077e1872c46788540de1ea3d7f4ccb1983d12f9aa909b234468676c1a36779" +checksum = "75e669e5202259b5314d1ea5397316ad400819437857b90861765f24c4cf80a2" dependencies = [ "pem", "ring", @@ -3636,9 +3647,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", ] @@ -3709,9 +3720,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.9" +version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +checksum = "7fe060fe50f524be480214aba758c71f99f90ee8c83c5a36b5e9e1d568eb4eb3" dependencies = [ "base64 0.22.1", "bytes", @@ -3723,7 +3734,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-rustls", "hyper-tls 0.6.0", "hyper-util", @@ -3742,11 +3753,12 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.2", + "sync_wrapper", "system-configuration", "tokio", "tokio-native-tls", "tokio-rustls", + "tower 0.5.2", "tower-service", "url", "wasm-bindgen", @@ -3782,7 +3794,7 @@ dependencies = [ "futures", "getrandom", "http 1.2.0", - "hyper 1.5.1", + "hyper 1.5.2", "parking_lot 0.11.2", "reqwest", "reqwest-middleware", @@ -3872,7 +3884,7 @@ dependencies = [ "hex", "hmac", "http 0.2.12", - "hyper 0.14.31", + "hyper 0.14.32", "hyper-tls 0.5.0", "log", "maybe-async", @@ -3938,22 +3950,22 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.41" +version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "rustls" -version = "0.23.19" +version = "0.23.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" +checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" dependencies = [ "aws-lc-rs", "log", @@ -3989,9 +4001,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" dependencies = [ "web-time", ] @@ -4037,9 +4049,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 = "rxml" @@ -4075,9 +4087,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.2.5" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b202022bb57c049555430e11fc22fea12909276a80a4c3d368da36ac1d88ed" +checksum = "28e1c91382686d21b5ac7959341fcb9780fa7c03773646995a87c950fa7be640" dependencies = [ "sdd", ] @@ -4099,9 +4111,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sdd" -version = "3.0.4" +version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49c1eeaf4b6a87c7479688c6d52b9f1153cedd3c489300564f932b065c6eab95" +checksum = "478f121bb72bbf63c52c93011ea1791dca40140dfe13f8336c4c5ac952c33aa9" [[package]] name = "seahash" @@ -4125,9 +4137,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" dependencies = [ "core-foundation-sys", "libc", @@ -4135,31 +4147,31 @@ 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" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -4207,9 +4219,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", @@ -4225,14 +4237,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.90", + "syn 2.0.93", ] [[package]] @@ -4257,7 +4269,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -4309,7 +4321,7 @@ dependencies = [ "static-toml", "strip-ansi-escapes", "strum", - "sysinfo 0.33.0", + "sysinfo 0.33.1", "thiserror 2.0.9", "tokio", "tokio-native-tls", @@ -4449,15 +4461,15 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "static-toml" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf47a76b3a01cafdeebf4feeb2691f28398a4ac028e6dd33fd61ed04306950c" +checksum = "b4df9e050de84b640ece7b8959a4a040600598c15f007bb39a7eeefe52f7a8cf" dependencies = [ "convert_case", "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "toml", ] @@ -4501,7 +4513,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -4523,21 +4535,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.90" +version = "2.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[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.2" @@ -4555,7 +4561,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -4574,9 +4580,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.33.0" +version = "0.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "948512566b1895f93b1592c7574baeb2de842f224f2aab158799ecadb8ebbb46" +checksum = "4fc858248ea01b66f19d8e8a6d55f41deaf91e9d495246fd01368d99935c6c01" dependencies = [ "core-foundation-sys", "libc", @@ -4634,9 +4640,9 @@ dependencies = [ [[package]] name = "termtree" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" [[package]] name = "thiserror" @@ -4664,7 +4670,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -4675,7 +4681,7 @@ checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -4742,9 +4748,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" dependencies = [ "tinyvec_macros", ] @@ -4782,7 +4788,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -4878,7 +4884,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-timeout", "hyper-util", "percent-encoding", @@ -4928,14 +4934,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", "tokio", "tower-layer", "tower-service", @@ -5002,7 +5008,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -5183,7 +5189,7 @@ checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ "getrandom", "rand", - "zerocopy 0.8.13", + "zerocopy 0.8.14", ] [[package]] @@ -5322,7 +5328,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "wasm-bindgen-shared", ] @@ -5357,7 +5363,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5503,7 +5509,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -5514,7 +5520,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -5736,9 +5742,9 @@ dependencies = [ [[package]] name = "xxhash-rust" -version = "0.8.12" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a5cbf750400958819fb6178eaa83bee5cd9c29a26a40cc241df8c70fdd46984" +checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3" [[package]] name = "yansi" @@ -5775,7 +5781,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "synstructure", ] @@ -5791,11 +5797,11 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67914ab451f3bfd2e69e5e9d2ef3858484e7074d63f204fd166ec391b54de21d" +checksum = "a367f292d93d4eab890745e75a778da40909cab4d6ff8173693812f79c4a2468" dependencies = [ - "zerocopy-derive 0.8.13", + "zerocopy-derive 0.8.14", ] [[package]] @@ -5806,18 +5812,18 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] name = "zerocopy-derive" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7988d73a4303ca289df03316bc490e934accf371af6bc745393cf3c2c5c4f25d" +checksum = "d3931cb58c62c13adec22e38686b559c86a30565e16ad6e8510a337cedc611e1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -5837,7 +5843,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "synstructure", ] @@ -5858,7 +5864,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -5880,14 +5886,14 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] name = "zip" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d52293fc86ea7cf13971b3bb81eb21683636e7ae24c729cdaf1b7c4157a352" +checksum = "ae9c1ea7b3a5e1f4b922ff856a129881167511563dc219869afe3787fc0c1a45" dependencies = [ "aes", "arbitrary", diff --git a/server/src/archiver/disk.rs b/server/src/archiver/disk.rs index f55097ea2..222c64c0c 100644 --- a/server/src/archiver/disk.rs +++ b/server/src/archiver/disk.rs @@ -2,7 +2,7 @@ use crate::archiver::{Archiver, COMPONENT}; use crate::configs::server::DiskArchiverConfig; use crate::server_error::ArchiverError; use async_trait::async_trait; -use error_set::ResultContext; +use error_set::ErrContext; use std::path::Path; use tokio::fs; use tracing::{debug, info}; @@ -25,7 +25,7 @@ impl Archiver for DiskArchiver { info!("Creating disk archiver directory: {}", self.config.path); fs::create_dir_all(&self.config.path) .await - .with_error(|err| { + .with_error_context(|err| { format!( "ARCHIVER - failed to create directory: {} with error: {err}", self.config.path @@ -68,10 +68,10 @@ impl Archiver for DiskArchiver { let destination_path = destination.to_str().unwrap_or_default().to_owned(); fs::create_dir_all(destination.parent().unwrap()) .await - .with_error(|err| { + .with_error_context(|err| { format!("{COMPONENT} - failed to create file: {file} at path: {destination_path} with error: {err}",) })?; - fs::copy(source, destination).await.with_error(|err| { + fs::copy(source, destination).await.with_error_context(|err| { format!("{COMPONENT} - failed to copy file: {file} to destination: {destination_path} with error: {err}") })?; debug!("Archived file: {file} at: {destination_path}"); diff --git a/server/src/archiver/s3.rs b/server/src/archiver/s3.rs index 45806027e..901579ee5 100644 --- a/server/src/archiver/s3.rs +++ b/server/src/archiver/s3.rs @@ -3,7 +3,7 @@ use crate::configs::server::S3ArchiverConfig; use crate::server_error::ArchiverError; use crate::streaming::utils::file; use async_trait::async_trait; -use error_set::ResultContext; +use error_set::ErrContext; use s3::creds::Credentials; use s3::{Bucket, Region}; use std::path::Path; @@ -61,13 +61,13 @@ impl S3Archiver { debug!("Creating temporary S3 upload directory: {destination_path}"); fs::create_dir_all(destination.parent().unwrap()) .await - .with_error(|err| { + .with_error_context(|err| { format!( "{COMPONENT} - failed to create temporary S3 upload directory for path: {destination_path} with error: {err}" ) })?; debug!("Copying file: {path} to temporary S3 upload path: {destination_path}"); - fs::copy(source, &destination).await.with_error(|err| { + fs::copy(source, &destination).await.with_error_context(|err| { format!("{COMPONENT} - failed to copy file: {path} to temporary S3 upload path: {destination_path} with error: {err}") })?; debug!("File: {path} copied to temporary S3 upload path: {destination_path}"); @@ -140,7 +140,7 @@ impl Archiver for S3Archiver { debug!("Archiving file: {source} on S3."); let mut file = file::open(&source) .await - .with_error(|err| format!("{COMPONENT} - failed to open source file: {source} for archiving with error: {err}"))?; + .with_error_context(|err| format!("{COMPONENT} - failed to open source file: {source} for archiving with error: {err}"))?; let base_directory = base_directory.as_deref().unwrap_or_default(); let destination = Path::new(&base_directory).join(path); let destination_path = destination.to_str().unwrap_or_default().to_owned(); @@ -150,7 +150,7 @@ impl Archiver for S3Archiver { .await; if let Err(error) = response { error!("Cannot archive file: {path} on S3: {}", error); - fs::remove_file(&source).await.with_error(|err| { + fs::remove_file(&source).await.with_error_context(|err| { format!("{COMPONENT} - failed to remove temporary file: {source} after S3 failure with error: {err}") })?; return Err(ArchiverError::CannotArchiveFile { @@ -162,14 +162,14 @@ impl Archiver for S3Archiver { let status = response.status_code(); if status == 200 { debug!("Archived file: {path} on S3."); - fs::remove_file(&source).await.with_error(|err| { + fs::remove_file(&source).await.with_error_context(|err| { format!("{COMPONENT} - failed to remove temporary file: {source} after successful archive with error: {err}") })?; continue; } error!("Cannot archive file: {path} on S3, received an invalid status code: {status}."); - fs::remove_file(&source).await.with_error(|err| { + fs::remove_file(&source).await.with_error_context(|err| { format!("{COMPONENT} - failed to remove temporary file: {source} after invalid status code with error: {err}") })?; return Err(ArchiverError::CannotArchiveFile { diff --git a/server/src/binary/command.rs b/server/src/binary/command.rs index 4e92238a4..6da26bf62 100644 --- a/server/src/binary/command.rs +++ b/server/src/binary/command.rs @@ -22,7 +22,7 @@ use crate::binary::COMPONENT; use crate::command::ServerCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use tracing::{debug, error}; @@ -40,16 +40,22 @@ pub async fn handle( Err(error) => { error!("Command was not handled successfully, session: {session}, error: {error}."); if let IggyError::ClientNotFound(_) = error { - sender.send_error_response(error).await.with_error(|_| { - format!("{COMPONENT} - failed to send error response, session: {session}") - })?; + sender + .send_error_response(error) + .await + .with_error_context(|_| { + format!("{COMPONENT} - failed to send error response, session: {session}") + })?; debug!("TCP error response was sent to: {session}."); error!("Session: {session} will be deleted."); Err(IggyError::ClientNotFound(session.client_id)) } else { - sender.send_error_response(error).await.with_error(|_| { - format!("{COMPONENT} - failed to send error response, session: {session}") - })?; + sender + .send_error_response(error) + .await + .with_error_context(|_| { + format!("{COMPONENT} - failed to send error response, session: {session}") + })?; debug!("TCP error response was sent to: {session}."); Ok(()) } diff --git a/server/src/binary/handlers/consumer_groups/create_consumer_group_handler.rs b/server/src/binary/handlers/consumer_groups/create_consumer_group_handler.rs index 6b73230cc..12068517a 100644 --- a/server/src/binary/handlers/consumer_groups/create_consumer_group_handler.rs +++ b/server/src/binary/handlers/consumer_groups/create_consumer_group_handler.rs @@ -5,7 +5,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer_groups::create_consumer_group::CreateConsumerGroup; use iggy::error::IggyError; use tracing::{debug, instrument}; @@ -30,7 +30,7 @@ pub async fn handle( &command.name, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to create consumer group for stream_id: {}, topic_id: {}, group_id: {:?}, session: {:?}", command.stream_id, command.topic_id, command.group_id, session @@ -52,7 +52,7 @@ pub async fn handle( EntryCommand::CreateConsumerGroup(command), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply create consumer group for stream_id: {}, topic_id: {}, group_id: {:?}, session: {}", stream_id, topic_id, group_id, session diff --git a/server/src/binary/handlers/consumer_groups/delete_consumer_group_handler.rs b/server/src/binary/handlers/consumer_groups/delete_consumer_group_handler.rs index 503d89d0c..c0eef296a 100644 --- a/server/src/binary/handlers/consumer_groups/delete_consumer_group_handler.rs +++ b/server/src/binary/handlers/consumer_groups/delete_consumer_group_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer_groups::delete_consumer_group::DeleteConsumerGroup; use iggy::error::IggyError; use tracing::{debug, instrument}; @@ -26,7 +26,7 @@ pub async fn handle( &command.topic_id, &command.group_id, ) - .await.with_error(|_| format!( + .await.with_error_context(|_| format!( "{COMPONENT} - failed to delete consumer group for stream_id: {}, topic_id: {}, group_id: {:?}, session: {}", command.stream_id, command.topic_id, command.group_id, session ))?; @@ -44,7 +44,7 @@ pub async fn handle( EntryCommand::DeleteConsumerGroup(command), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply delete consumer group for stream_id: {}, topic_id: {}, group_id: {:?}, session: {}", stream_id, topic_id, group_id, session diff --git a/server/src/binary/handlers/consumer_groups/get_consumer_groups_handler.rs b/server/src/binary/handlers/consumer_groups/get_consumer_groups_handler.rs index 46064c597..e027d407c 100644 --- a/server/src/binary/handlers/consumer_groups/get_consumer_groups_handler.rs +++ b/server/src/binary/handlers/consumer_groups/get_consumer_groups_handler.rs @@ -4,7 +4,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer_groups::get_consumer_groups::GetConsumerGroups; use iggy::error::IggyError; use tracing::debug; @@ -19,7 +19,7 @@ pub async fn handle( let system = system.read().await; let consumer_groups = system .get_consumer_groups(session, &command.stream_id, &command.topic_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed on getting consumer groups for stream_id: {}, topic_id: {}, session: {}", command.stream_id, command.topic_id, session diff --git a/server/src/binary/handlers/consumer_groups/join_consumer_group_handler.rs b/server/src/binary/handlers/consumer_groups/join_consumer_group_handler.rs index 5cefe5a31..f105a5f8a 100644 --- a/server/src/binary/handlers/consumer_groups/join_consumer_group_handler.rs +++ b/server/src/binary/handlers/consumer_groups/join_consumer_group_handler.rs @@ -3,7 +3,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer_groups::join_consumer_group::JoinConsumerGroup; use iggy::error::IggyError; use tracing::{debug, instrument}; @@ -25,7 +25,7 @@ pub async fn handle( &command.group_id, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to join consumer group for stream_id: {}, topic_id: {}, group_id: {}, session: {}", command.stream_id, command.topic_id, command.group_id, session diff --git a/server/src/binary/handlers/consumer_groups/leave_consumer_group_handler.rs b/server/src/binary/handlers/consumer_groups/leave_consumer_group_handler.rs index 7b6b59cf1..0dbcaa672 100644 --- a/server/src/binary/handlers/consumer_groups/leave_consumer_group_handler.rs +++ b/server/src/binary/handlers/consumer_groups/leave_consumer_group_handler.rs @@ -3,7 +3,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer_groups::leave_consumer_group::LeaveConsumerGroup; use iggy::error::IggyError; use tracing::{debug, instrument}; @@ -25,7 +25,7 @@ pub async fn handle( &command.group_id, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to leave consumer group for stream_id: {}, topic_id: {}, group_id: {}, session: {}", command.stream_id, command.topic_id, command.group_id, session diff --git a/server/src/binary/handlers/consumer_offsets/store_consumer_offset_handler.rs b/server/src/binary/handlers/consumer_offsets/store_consumer_offset_handler.rs index fb079eacf..3a19818dc 100644 --- a/server/src/binary/handlers/consumer_offsets/store_consumer_offset_handler.rs +++ b/server/src/binary/handlers/consumer_offsets/store_consumer_offset_handler.rs @@ -3,7 +3,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer_offsets::store_consumer_offset::StoreConsumerOffset; use iggy::error::IggyError; use tracing::debug; @@ -26,7 +26,7 @@ pub async fn handle( command.offset, ) .await - .with_error(|_| format!("{COMPONENT} - failed to store consumer offset for stream_id: {}, topic_id: {}, partition_id: {:?}, offset: {}, session: {}", + .with_error_context(|_| format!("{COMPONENT} - failed to store consumer offset for stream_id: {}, topic_id: {}, partition_id: {:?}, offset: {}, session: {}", command.stream_id, command.topic_id, command.partition_id, command.offset, session ))?; sender.send_empty_ok_response().await?; diff --git a/server/src/binary/handlers/messages/flush_unsaved_buffer_handler.rs b/server/src/binary/handlers/messages/flush_unsaved_buffer_handler.rs index c91d53bc7..618ca6a0e 100644 --- a/server/src/binary/handlers/messages/flush_unsaved_buffer_handler.rs +++ b/server/src/binary/handlers/messages/flush_unsaved_buffer_handler.rs @@ -3,7 +3,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::messages::flush_unsaved_buffer::FlushUnsavedBuffer; use tracing::{debug, instrument}; @@ -24,7 +24,7 @@ pub async fn handle( system .flush_unsaved_buffer(session, stream_id, topic_id, partition_id, fsync) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to flush unsaved buffer for stream_id: {}, topic_id: {}, partition_id: {}, session: {}", command.stream_id, command.topic_id, command.partition_id, session diff --git a/server/src/binary/handlers/messages/poll_messages_handler.rs b/server/src/binary/handlers/messages/poll_messages_handler.rs index 84da328c1..338fce064 100644 --- a/server/src/binary/handlers/messages/poll_messages_handler.rs +++ b/server/src/binary/handlers/messages/poll_messages_handler.rs @@ -5,7 +5,7 @@ use crate::streaming::session::Session; use crate::streaming::systems::messages::PollingArgs; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::messages::poll_messages::PollMessages; use tracing::debug; @@ -28,7 +28,7 @@ pub async fn handle( PollingArgs::new(command.strategy, command.count, command.auto_commit), ) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "{COMPONENT} - failed to poll messages for consumer: {}, stream_id: {}, topic_id: {}, partition_id: {:?}, session: {}", command.consumer, command.stream_id, command.topic_id, command.partition_id, session ))?; diff --git a/server/src/binary/handlers/messages/send_messages_handler.rs b/server/src/binary/handlers/messages/send_messages_handler.rs index c150b02c0..8726f0bc1 100644 --- a/server/src/binary/handlers/messages/send_messages_handler.rs +++ b/server/src/binary/handlers/messages/send_messages_handler.rs @@ -3,7 +3,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::messages::send_messages::SendMessages; use tracing::debug; @@ -23,7 +23,7 @@ pub async fn handle( system .append_messages(session, stream_id, topic_id, partitioning, messages) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to append messages for stream_id: {}, topic_id: {}, partitioning: {}, session: {}", command.stream_id, command.topic_id, command.partitioning, session diff --git a/server/src/binary/handlers/partitions/create_partitions_handler.rs b/server/src/binary/handlers/partitions/create_partitions_handler.rs index fd3bb6995..b2dfd20ed 100644 --- a/server/src/binary/handlers/partitions/create_partitions_handler.rs +++ b/server/src/binary/handlers/partitions/create_partitions_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::partitions::create_partitions::CreatePartitions; use tracing::{debug, instrument}; @@ -27,7 +27,7 @@ pub async fn handle( command.partitions_count, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to create partitions for stream_id: {}, topic_id: {}, session: {}", command.stream_id, command.topic_id, session @@ -46,7 +46,7 @@ pub async fn handle( EntryCommand::CreatePartitions(command), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply create partitions for stream_id: {}, topic_id: {}, session: {}", stream_id, topic_id, session diff --git a/server/src/binary/handlers/partitions/delete_partitions_handler.rs b/server/src/binary/handlers/partitions/delete_partitions_handler.rs index 20370c901..4321ab2ba 100644 --- a/server/src/binary/handlers/partitions/delete_partitions_handler.rs +++ b/server/src/binary/handlers/partitions/delete_partitions_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::partitions::delete_partitions::DeletePartitions; use tracing::{debug, instrument}; @@ -30,7 +30,7 @@ pub async fn handle( command.partitions_count, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to delete partitions for stream_id: {}, topic_id: {}, session: {}", stream_id, topic_id, session @@ -46,7 +46,7 @@ pub async fn handle( EntryCommand::DeletePartitions(command), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply delete partitions for stream_id: {}, topic_id: {}, session: {}", stream_id, topic_id, session diff --git a/server/src/binary/handlers/personal_access_tokens/create_personal_access_token_handler.rs b/server/src/binary/handlers/personal_access_tokens/create_personal_access_token_handler.rs index 26c30c25f..d42ed1859 100644 --- a/server/src/binary/handlers/personal_access_tokens/create_personal_access_token_handler.rs +++ b/server/src/binary/handlers/personal_access_tokens/create_personal_access_token_handler.rs @@ -7,7 +7,7 @@ use crate::streaming::personal_access_tokens::personal_access_token::PersonalAcc use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::personal_access_tokens::create_personal_access_token::CreatePersonalAccessToken; use tracing::{debug, instrument}; @@ -27,7 +27,7 @@ pub async fn handle( let token = system .create_personal_access_token(session, &command.name, command.expiry) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to create personal access token with name: {}, session: {session}", command.name @@ -51,7 +51,7 @@ pub async fn handle( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to create personal access token with name: {}, session: {session}", command.name diff --git a/server/src/binary/handlers/personal_access_tokens/delete_personal_access_token_handler.rs b/server/src/binary/handlers/personal_access_tokens/delete_personal_access_token_handler.rs index 3d588327b..b5780741b 100644 --- a/server/src/binary/handlers/personal_access_tokens/delete_personal_access_token_handler.rs +++ b/server/src/binary/handlers/personal_access_tokens/delete_personal_access_token_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::personal_access_tokens::delete_personal_access_token::DeletePersonalAccessToken; use tracing::{debug, instrument}; @@ -24,7 +24,7 @@ pub async fn handle( system .delete_personal_access_token(session, &command.name) .await - .with_error(|_| {format!( + .with_error_context(|_| {format!( "{COMPONENT} - failed to delete personal access token with name: {token_name}, session: {session}" )})?; } @@ -37,7 +37,7 @@ pub async fn handle( EntryCommand::DeletePersonalAccessToken(command), ) .await - .with_error(|_| {format!( + .with_error_context(|_| {format!( "{COMPONENT} - failed to apply delete personal access token with name: {token_name}, session: {session}" )})?; sender.send_empty_ok_response().await?; diff --git a/server/src/binary/handlers/personal_access_tokens/get_personal_access_tokens_handler.rs b/server/src/binary/handlers/personal_access_tokens/get_personal_access_tokens_handler.rs index e4728d5ee..23d8fd468 100644 --- a/server/src/binary/handlers/personal_access_tokens/get_personal_access_tokens_handler.rs +++ b/server/src/binary/handlers/personal_access_tokens/get_personal_access_tokens_handler.rs @@ -3,7 +3,7 @@ use crate::binary::mapper; use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::personal_access_tokens::get_personal_access_tokens::GetPersonalAccessTokens; use tracing::debug; @@ -19,7 +19,7 @@ pub async fn handle( let personal_access_tokens = system .get_personal_access_tokens(session) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to get personal access tokens with session: {session}") })?; let personal_access_tokens = mapper::map_personal_access_tokens(&personal_access_tokens); diff --git a/server/src/binary/handlers/personal_access_tokens/login_with_personal_access_token_handler.rs b/server/src/binary/handlers/personal_access_tokens/login_with_personal_access_token_handler.rs index 57780bb9e..ba9452ced 100644 --- a/server/src/binary/handlers/personal_access_tokens/login_with_personal_access_token_handler.rs +++ b/server/src/binary/handlers/personal_access_tokens/login_with_personal_access_token_handler.rs @@ -4,7 +4,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::personal_access_tokens::login_with_personal_access_token::LoginWithPersonalAccessToken; use tracing::{debug, instrument}; @@ -21,7 +21,7 @@ pub async fn handle( let user = system .login_with_personal_access_token(&command.token, Some(session)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to login with personal access token: {}, session: {session}", command.token diff --git a/server/src/binary/handlers/streams/create_stream_handler.rs b/server/src/binary/handlers/streams/create_stream_handler.rs index 7c540a719..28ed78ccf 100644 --- a/server/src/binary/handlers/streams/create_stream_handler.rs +++ b/server/src/binary/handlers/streams/create_stream_handler.rs @@ -5,7 +5,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::streams::create_stream::CreateStream; use tracing::{debug, instrument}; @@ -26,7 +26,7 @@ pub async fn handle( let stream = system .create_stream(session, command.stream_id, &command.name) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to create stream with id: {:?}, session: {session}", stream_id @@ -40,7 +40,7 @@ pub async fn handle( .state .apply(session.get_user_id(), EntryCommand::CreateStream(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply create stream for id: {:?}, session: {session}", stream_id diff --git a/server/src/binary/handlers/streams/delete_stream_handler.rs b/server/src/binary/handlers/streams/delete_stream_handler.rs index 655b90651..9bc5072e6 100644 --- a/server/src/binary/handlers/streams/delete_stream_handler.rs +++ b/server/src/binary/handlers/streams/delete_stream_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::streams::delete_stream::DeleteStream; use tracing::{debug, instrument}; @@ -23,7 +23,7 @@ pub async fn handle( system .delete_stream(session, &command.stream_id) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to delete stream with id: {stream_id}, session: {session}") })?; } @@ -33,7 +33,7 @@ pub async fn handle( .state .apply(session.get_user_id(), EntryCommand::DeleteStream(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to apply delete stream with id: {stream_id}, session: {session}") })?; sender.send_empty_ok_response().await?; diff --git a/server/src/binary/handlers/streams/get_streams_handler.rs b/server/src/binary/handlers/streams/get_streams_handler.rs index 81b1d5caa..97932d430 100644 --- a/server/src/binary/handlers/streams/get_streams_handler.rs +++ b/server/src/binary/handlers/streams/get_streams_handler.rs @@ -4,7 +4,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::streams::get_streams::GetStreams; use tracing::debug; @@ -17,9 +17,9 @@ pub async fn handle( ) -> Result<(), IggyError> { debug!("session: {session}, command: {command}"); let system = system.read().await; - let streams = system - .find_streams(session) - .with_error(|_| format!("{COMPONENT} - failed to find streams for session: {session}"))?; + let streams = system.find_streams(session).with_error_context(|_| { + format!("{COMPONENT} - failed to find streams for session: {session}") + })?; let response = mapper::map_streams(&streams); sender.send_ok_response(&response).await?; Ok(()) diff --git a/server/src/binary/handlers/streams/purge_stream_handler.rs b/server/src/binary/handlers/streams/purge_stream_handler.rs index b37c6f665..14dfe61c2 100644 --- a/server/src/binary/handlers/streams/purge_stream_handler.rs +++ b/server/src/binary/handlers/streams/purge_stream_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::streams::purge_stream::PurgeStream; use tracing::{debug, instrument}; @@ -23,7 +23,7 @@ pub async fn handle( system .purge_stream(session, &command.stream_id) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to purge stream with id: {stream_id}, session: {session}") })?; @@ -31,7 +31,7 @@ pub async fn handle( .state .apply(session.get_user_id(), EntryCommand::PurgeStream(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to apply purge stream with id: {stream_id}, session: {session}") })?; sender.send_empty_ok_response().await?; diff --git a/server/src/binary/handlers/streams/update_stream_handler.rs b/server/src/binary/handlers/streams/update_stream_handler.rs index 4a2f86e2c..c483c8063 100644 --- a/server/src/binary/handlers/streams/update_stream_handler.rs +++ b/server/src/binary/handlers/streams/update_stream_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::streams::update_stream::UpdateStream; use tracing::{debug, instrument}; @@ -24,7 +24,7 @@ pub async fn handle( system .update_stream(session, &command.stream_id, &command.name) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to update stream with id: {stream_id}, session: {session}") })?; } @@ -35,7 +35,7 @@ pub async fn handle( .state .apply(session.get_user_id(), EntryCommand::UpdateStream(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to apply update stream with id: {stream_id}, session: {session}") })?; sender.send_empty_ok_response().await?; diff --git a/server/src/binary/handlers/system/get_clients_handler.rs b/server/src/binary/handlers/system/get_clients_handler.rs index 748113494..f4025b0e0 100644 --- a/server/src/binary/handlers/system/get_clients_handler.rs +++ b/server/src/binary/handlers/system/get_clients_handler.rs @@ -3,7 +3,7 @@ use crate::binary::mapper; use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::system::get_clients::GetClients; use tracing::debug; @@ -16,10 +16,9 @@ pub async fn handle( ) -> Result<(), IggyError> { debug!("session: {session}, command: {command}"); let system = system.read().await; - let clients = system - .get_clients(session) - .await - .with_error(|_| format!("{COMPONENT} - failed to get clients, session: {session}"))?; + let clients = system.get_clients(session).await.with_error_context(|_| { + format!("{COMPONENT} - failed to get clients, session: {session}") + })?; let clients = mapper::map_clients(&clients).await; sender.send_ok_response(&clients).await?; Ok(()) diff --git a/server/src/binary/handlers/system/get_me_handler.rs b/server/src/binary/handlers/system/get_me_handler.rs index ac0068ad5..ab490c3f6 100644 --- a/server/src/binary/handlers/system/get_me_handler.rs +++ b/server/src/binary/handlers/system/get_me_handler.rs @@ -3,7 +3,7 @@ use crate::binary::mapper; use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::locking::IggySharedMutFn; use iggy::system::get_me::GetMe; @@ -22,7 +22,9 @@ pub async fn handle( let client = system .get_client(session, session.client_id) .await - .with_error(|_| format!("{COMPONENT} - failed to get client, session: {session}"))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to get client, session: {session}") + })?; { let client = client.read().await; bytes = mapper::map_client(&client); diff --git a/server/src/binary/handlers/system/get_stats_handler.rs b/server/src/binary/handlers/system/get_stats_handler.rs index e56fc202f..13a2f34b2 100644 --- a/server/src/binary/handlers/system/get_stats_handler.rs +++ b/server/src/binary/handlers/system/get_stats_handler.rs @@ -3,7 +3,7 @@ use crate::binary::mapper; use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::system::get_stats::GetStats; use tracing::debug; @@ -19,7 +19,7 @@ pub async fn handle( let stats = system .get_stats() .await - .with_error(|_| format!("{COMPONENT} - failed to get stats, session: {session}"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to get stats, session: {session}"))?; let bytes = mapper::map_stats(&stats); sender.send_ok_response(&bytes).await?; Ok(()) diff --git a/server/src/binary/handlers/system/ping_handler.rs b/server/src/binary/handlers/system/ping_handler.rs index 3226ba551..494fc0631 100644 --- a/server/src/binary/handlers/system/ping_handler.rs +++ b/server/src/binary/handlers/system/ping_handler.rs @@ -3,7 +3,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::locking::IggySharedMutFn; use iggy::system::ping::Ping; @@ -21,7 +21,9 @@ pub async fn handle( let client_manager = system.client_manager.read().await; let client = client_manager .get_client(session.client_id) - .with_error(|_| format!("{COMPONENT} - failed to get clients, session: {session}"))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to get clients, session: {session}") + })?; let mut client = client.write().await; let now = IggyTimestamp::now(); client.last_heartbeat = now; diff --git a/server/src/binary/handlers/topics/create_topic_handler.rs b/server/src/binary/handlers/topics/create_topic_handler.rs index be0d04b95..fa35bb0e8 100644 --- a/server/src/binary/handlers/topics/create_topic_handler.rs +++ b/server/src/binary/handlers/topics/create_topic_handler.rs @@ -5,7 +5,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::topics::create_topic::CreateTopic; use tracing::{debug, instrument}; @@ -37,7 +37,7 @@ pub async fn handle( command.replication_factor, ) .await - .with_error(|_| format!("{COMPONENT} - failed to create topic for stream_id: {stream_id}, topic_id: {:?}", + .with_error_context(|_| format!("{COMPONENT} - failed to create topic for stream_id: {stream_id}, topic_id: {:?}", topic_id ))?; command.message_expiry = topic.message_expiry; @@ -50,7 +50,7 @@ pub async fn handle( .state .apply(session.get_user_id(), EntryCommand::CreateTopic(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply create topic for stream_id: {stream_id}, topic_id: {:?}", topic_id diff --git a/server/src/binary/handlers/topics/delete_topic_handler.rs b/server/src/binary/handlers/topics/delete_topic_handler.rs index 50974976a..3b21afa76 100644 --- a/server/src/binary/handlers/topics/delete_topic_handler.rs +++ b/server/src/binary/handlers/topics/delete_topic_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::topics::delete_topic::DeleteTopic; use tracing::{debug, instrument}; @@ -25,7 +25,7 @@ pub async fn handle( system .delete_topic(session, &command.stream_id, &command.topic_id) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "{COMPONENT} - failed to delete topic for stream_id: {stream_id}, topic_id: {topic_id}", ))?; } @@ -35,7 +35,7 @@ pub async fn handle( .state .apply(session.get_user_id(), EntryCommand::DeleteTopic(command)) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "{COMPONENT} - failed to apply delete topic for stream_id: {stream_id}, topic_id: {topic_id}", ))?; sender.send_empty_ok_response().await?; diff --git a/server/src/binary/handlers/topics/get_topics_handler.rs b/server/src/binary/handlers/topics/get_topics_handler.rs index a4bbebbd1..98925e593 100644 --- a/server/src/binary/handlers/topics/get_topics_handler.rs +++ b/server/src/binary/handlers/topics/get_topics_handler.rs @@ -4,7 +4,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::topics::get_topics::GetTopics; use tracing::debug; @@ -19,7 +19,7 @@ pub async fn handle( let system = system.read().await; let topics = system .find_topics(session, &command.stream_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to find topics, stream_id: {}, session: {session}", command.stream_id diff --git a/server/src/binary/handlers/topics/purge_topic_handler.rs b/server/src/binary/handlers/topics/purge_topic_handler.rs index b210f157b..0f8bd0fad 100644 --- a/server/src/binary/handlers/topics/purge_topic_handler.rs +++ b/server/src/binary/handlers/topics/purge_topic_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::topics::purge_topic::PurgeTopic; use tracing::{debug, instrument}; @@ -21,7 +21,7 @@ pub async fn handle( system .purge_topic(session, &command.stream_id, &command.topic_id) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to purge topic with id: {}, stream_id: {}", command.topic_id, command.stream_id @@ -34,7 +34,7 @@ pub async fn handle( .state .apply(session.get_user_id(), EntryCommand::PurgeTopic(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply purge topic with id: {topic_id}, stream_id: {stream_id}", ) diff --git a/server/src/binary/handlers/topics/update_topic_handler.rs b/server/src/binary/handlers/topics/update_topic_handler.rs index c2593a98f..4ffc9bf98 100644 --- a/server/src/binary/handlers/topics/update_topic_handler.rs +++ b/server/src/binary/handlers/topics/update_topic_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::topics::update_topic::UpdateTopic; use tracing::{debug, instrument}; @@ -32,7 +32,7 @@ pub async fn handle( command.replication_factor, ) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "{COMPONENT} - failed to update topic with id: {}, stream_id: {}, session: {session}", command.topic_id, command.stream_id ))?; @@ -48,7 +48,7 @@ pub async fn handle( .state .apply(session.get_user_id(), EntryCommand::UpdateTopic(command)) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "{COMPONENT} - failed to apply update topic with id: {}, stream_id: {}, session: {session}", topic_id, stream_id ))?; diff --git a/server/src/binary/handlers/users/change_password_handler.rs b/server/src/binary/handlers/users/change_password_handler.rs index 95e8b7d4c..ee4849a43 100644 --- a/server/src/binary/handlers/users/change_password_handler.rs +++ b/server/src/binary/handlers/users/change_password_handler.rs @@ -5,7 +5,7 @@ use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use crate::streaming::utils::crypto; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::users::change_password::ChangePassword; use tracing::{debug, instrument}; @@ -28,7 +28,7 @@ pub async fn handle( &command.new_password, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to change password for user_id: {}, session: {session}", command.user_id @@ -49,7 +49,7 @@ pub async fn handle( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply change password for user_id: {}, session: {session}", command.user_id diff --git a/server/src/binary/handlers/users/create_user_handler.rs b/server/src/binary/handlers/users/create_user_handler.rs index 8ca234b65..6bf6ee977 100644 --- a/server/src/binary/handlers/users/create_user_handler.rs +++ b/server/src/binary/handlers/users/create_user_handler.rs @@ -6,7 +6,7 @@ use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use crate::streaming::utils::crypto; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::users::create_user::CreateUser; use tracing::{debug, instrument}; @@ -31,7 +31,7 @@ pub async fn handle( command.permissions.clone(), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to create user with name: {}, session: {session}", command.username @@ -54,7 +54,7 @@ pub async fn handle( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply create user with name: {}, session: {session}", command.username diff --git a/server/src/binary/handlers/users/delete_user_handler.rs b/server/src/binary/handlers/users/delete_user_handler.rs index fef6a9d25..b41d1f298 100644 --- a/server/src/binary/handlers/users/delete_user_handler.rs +++ b/server/src/binary/handlers/users/delete_user_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::users::delete_user::DeleteUser; use tracing::{debug, instrument}; @@ -22,7 +22,7 @@ pub async fn handle( system .delete_user(session, &command.user_id) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to delete user with id: {}, session: {session}", command.user_id @@ -36,7 +36,7 @@ pub async fn handle( .state .apply(session.get_user_id(), EntryCommand::DeleteUser(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply delete user with id: {}, session: {session}", user_id diff --git a/server/src/binary/handlers/users/get_users_handler.rs b/server/src/binary/handlers/users/get_users_handler.rs index 32213542d..b4a7e54ac 100644 --- a/server/src/binary/handlers/users/get_users_handler.rs +++ b/server/src/binary/handlers/users/get_users_handler.rs @@ -3,7 +3,7 @@ use crate::binary::mapper; use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::users::get_users::GetUsers; use tracing::debug; @@ -19,7 +19,7 @@ pub async fn handle( let users = system .get_users(session) .await - .with_error(|_| format!("{COMPONENT} - failed to get users, session: {session}"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to get users, session: {session}"))?; let users = mapper::map_users(&users); sender.send_ok_response(&users).await?; Ok(()) diff --git a/server/src/binary/handlers/users/login_user_handler.rs b/server/src/binary/handlers/users/login_user_handler.rs index 674d09155..322ce3bf3 100644 --- a/server/src/binary/handlers/users/login_user_handler.rs +++ b/server/src/binary/handlers/users/login_user_handler.rs @@ -4,7 +4,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::users::login_user::LoginUser; use tracing::{debug, instrument}; @@ -21,7 +21,7 @@ pub async fn handle( let user = system .login_user(&command.username, &command.password, Some(session)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to login user with name: {}, session: {session}", command.username diff --git a/server/src/binary/handlers/users/logout_user_handler.rs b/server/src/binary/handlers/users/logout_user_handler.rs index ebec87369..08984705e 100644 --- a/server/src/binary/handlers/users/logout_user_handler.rs +++ b/server/src/binary/handlers/users/logout_user_handler.rs @@ -3,7 +3,7 @@ use crate::binary::sender::Sender; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::users::logout_user::LogoutUser; use tracing::{debug, instrument}; @@ -17,10 +17,9 @@ pub async fn handle( ) -> Result<(), IggyError> { debug!("session: {session}, command: {command}"); let system = system.read().await; - system - .logout_user(session) - .await - .with_error(|_| format!("{COMPONENT} - failed to logout user, session: {session}"))?; + system.logout_user(session).await.with_error_context(|_| { + format!("{COMPONENT} - failed to logout user, session: {session}") + })?; session.clear_user_id(); sender.send_empty_ok_response().await?; Ok(()) diff --git a/server/src/binary/handlers/users/update_permissions_handler.rs b/server/src/binary/handlers/users/update_permissions_handler.rs index 6ac0018cc..5c165a36d 100644 --- a/server/src/binary/handlers/users/update_permissions_handler.rs +++ b/server/src/binary/handlers/users/update_permissions_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::users::update_permissions::UpdatePermissions; use tracing::{debug, instrument}; @@ -22,7 +22,7 @@ pub async fn handle( system .update_permissions(session, &command.user_id, command.permissions.clone()) .await - .with_error(|_| format!("{COMPONENT} - failed to update permissions for user_id: {}, session: {session}", + .with_error_context(|_| format!("{COMPONENT} - failed to update permissions for user_id: {}, session: {session}", command.user_id ))?; } diff --git a/server/src/binary/handlers/users/update_user_handler.rs b/server/src/binary/handlers/users/update_user_handler.rs index c6ad95103..6ca21d6e9 100644 --- a/server/src/binary/handlers/users/update_user_handler.rs +++ b/server/src/binary/handlers/users/update_user_handler.rs @@ -4,7 +4,7 @@ use crate::state::command::EntryCommand; use crate::streaming::session::Session; use crate::streaming::systems::system::SharedSystem; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::users::update_user::UpdateUser; use tracing::{debug, instrument}; @@ -27,7 +27,7 @@ pub async fn handle( command.status, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to update user with user_id: {}, session: {session}", command.user_id @@ -42,7 +42,7 @@ pub async fn handle( .state .apply(session.get_user_id(), EntryCommand::UpdateUser(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply update user with user_id: {}, session: {session}", user_id diff --git a/server/src/channels/commands/maintain_messages.rs b/server/src/channels/commands/maintain_messages.rs index a39758a4f..f86b67cdb 100644 --- a/server/src/channels/commands/maintain_messages.rs +++ b/server/src/channels/commands/maintain_messages.rs @@ -5,7 +5,7 @@ use crate::map_toggle_str; use crate::streaming::systems::system::SharedSystem; use crate::streaming::topics::topic::Topic; use async_trait::async_trait; -use error_set::ResultContext; +use error_set::ErrContext; use flume::Sender; use iggy::error::IggyError; use iggy::locking::IggySharedMutFn; @@ -212,7 +212,7 @@ async fn handle_expired_segments( "Archiving expired segments for stream ID: {}, topic ID: {}", topic.stream_id, topic.topic_id ); - archive_segments(topic, &expired_segments, archiver.clone()).await.with_error(|_| { + archive_segments(topic, &expired_segments, archiver.clone()).await.with_error_context(|_| { format!("CHANNEL_COMMAND - failed to archive expired segments for stream ID: {}, topic ID: {}", topic.stream_id, topic.topic_id) })?; } else { @@ -322,7 +322,7 @@ async fn handle_oldest_segments( ); archive_segments(topic, &segments_to_archive, archiver.clone()) .await - .with_error(|_| { + .with_error_context(|_| { format!( "CHANNEL_COMMAND - failed to archive segments for stream ID: {}, topic ID: {}", topic.stream_id, topic.topic_id @@ -496,7 +496,7 @@ async fn delete_segments( let mut partition = partition.write().await; let mut last_end_offset = 0; for start_offset in &segment_to_delete.start_offsets { - let deleted_segment = partition.delete_segment(*start_offset).await.with_error(|_| { + let deleted_segment = partition.delete_segment(*start_offset).await.with_error_context(|_| { format!("CHANNEL_COMMAND - failed to delete segment for stream ID: {}, topic ID: {}", topic.stream_id, topic.topic_id) })?; last_end_offset = deleted_segment.end_offset; @@ -506,7 +506,7 @@ async fn delete_segments( if partition.get_segments().is_empty() { let start_offset = last_end_offset + 1; - partition.add_persisted_segment(start_offset).await.with_error(|_| { + partition.add_persisted_segment(start_offset).await.with_error_context(|_| { format!("CHANNEL_COMMAND - failed to add persisted segment for stream ID: {}, topic ID: {}", topic.stream_id, topic.topic_id) })?; } diff --git a/server/src/configs/server.rs b/server/src/configs/server.rs index 125cfa9bf..55b96671b 100644 --- a/server/src/configs/server.rs +++ b/server/src/configs/server.rs @@ -7,7 +7,7 @@ use crate::configs::tcp::TcpConfig; use crate::configs::COMPONENT; use crate::server_error::ConfigError; use derive_more::Display; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::utils::duration::IggyDuration; use iggy::validatable::Validatable; use serde::{Deserialize, Serialize}; @@ -154,10 +154,12 @@ impl ServerConfig { let server_config = config_provider .load_config() .await - .with_error(|_| format!("{COMPONENT} - failed to load config provider config"))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to load config provider config") + })?; server_config .validate() - .with_error(|_| format!("{COMPONENT} - failed to validate server config"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to validate server config"))?; Ok(server_config) } } diff --git a/server/src/configs/validators.rs b/server/src/configs/validators.rs index 3476b6f42..ac9150185 100644 --- a/server/src/configs/validators.rs +++ b/server/src/configs/validators.rs @@ -11,7 +11,7 @@ use crate::configs::system::{CacheConfig, SegmentConfig}; use crate::configs::COMPONENT; use crate::server_error::ConfigError; use crate::streaming::segments::segment; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::compression::compression_algorithm::CompressionAlgorithm; use iggy::utils::byte_size::IggyByteSize; use iggy::utils::expiry::IggyExpiry; @@ -22,27 +22,28 @@ use tracing::{info, warn}; impl Validatable for ServerConfig { fn validate(&self) -> Result<(), ConfigError> { - self.data_maintenance - .validate() - .with_error(|_| format!("{COMPONENT} - failed to validate data maintenance config"))?; - self.personal_access_token.validate().with_error(|_| { - format!("{COMPONENT} - failed to validate personal access token config") + self.data_maintenance.validate().with_error_context(|_| { + format!("{COMPONENT} - failed to validate data maintenance config") })?; + self.personal_access_token + .validate() + .with_error_context(|_| { + format!("{COMPONENT} - failed to validate personal access token config") + })?; self.system .segment .validate() - .with_error(|_| format!("{COMPONENT} - failed to validate segment config"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to validate segment config"))?; self.system .cache .validate() - .with_error(|_| format!("{COMPONENT} - failed to validate cache config"))?; - self.system - .compression - .validate() - .with_error(|_| format!("{COMPONENT} - failed to validate compression config"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to validate cache config"))?; + self.system.compression.validate().with_error_context(|_| { + format!("{COMPONENT} - failed to validate compression config") + })?; self.telemetry .validate() - .with_error(|_| format!("{COMPONENT} - failed to validate telemetry config"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to validate telemetry config"))?; let topic_size = match self.system.topic.max_size { MaxTopicSize::Custom(size) => Ok(size.as_bytes_u64()), @@ -170,13 +171,13 @@ impl Validatable for DataMaintenanceConfig { fn validate(&self) -> Result<(), ConfigError> { self.archiver .validate() - .with_error(|_| format!("{COMPONENT} - failed to validate archiver config"))?; - self.messages.validate().with_error(|_| { + .with_error_context(|_| format!("{COMPONENT} - failed to validate archiver config"))?; + self.messages.validate().with_error_context(|_| { format!("{COMPONENT} - failed to validate messages maintenance config") })?; - self.state - .validate() - .with_error(|_| format!("{COMPONENT} - failed to validate state maintenance config"))?; + self.state.validate().with_error_context(|_| { + format!("{COMPONENT} - failed to validate state maintenance config") + })?; Ok(()) } } diff --git a/server/src/http/consumer_groups.rs b/server/src/http/consumer_groups.rs index 9f4088d59..47a60ca20 100644 --- a/server/src/http/consumer_groups.rs +++ b/server/src/http/consumer_groups.rs @@ -9,7 +9,7 @@ use axum::extract::{Path, State}; use axum::http::StatusCode; use axum::routing::get; use axum::{Extension, Json, Router}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer_groups::create_consumer_group::CreateConsumerGroup; use iggy::consumer_groups::delete_consumer_group::DeleteConsumerGroup; use iggy::identifier::Identifier; @@ -47,7 +47,7 @@ async fn get_consumer_group( &identifier_topic_id, &identifier_group_id, ) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get consumer group, stream ID: {}, topic ID: {}, group ID: {}", stream_id, topic_id, group_id, @@ -102,7 +102,7 @@ async fn create_consumer_group( &command.name, ) .await - .with_error(|_| format!("{COMPONENT} - failed to create consumer group, stream ID: {}, topic ID: {}, group ID: {:?}", stream_id, topic_id, command.group_id))?; + .with_error_context(|_| format!("{COMPONENT} - failed to create consumer group, stream ID: {}, topic ID: {}, group ID: {:?}", stream_id, topic_id, command.group_id))?; let consumer_group = consumer_group.read().await; consumer_group_details = mapper::map_consumer_group(&consumer_group).await; } @@ -135,7 +135,7 @@ async fn delete_consumer_group( &identifier_group_id, ) .await - .with_error(|_| format!("{COMPONENT} - failed to delete consumer group, stream ID: {}, topic ID: {}, group ID: {}", stream_id, topic_id, group_id))?; + .with_error_context(|_| format!("{COMPONENT} - failed to delete consumer group, stream ID: {}, topic ID: {}, group ID: {}", stream_id, topic_id, group_id))?; } let system = state.system.read().await; diff --git a/server/src/http/consumer_offsets.rs b/server/src/http/consumer_offsets.rs index bfb93fc1b..66373c2aa 100644 --- a/server/src/http/consumer_offsets.rs +++ b/server/src/http/consumer_offsets.rs @@ -7,7 +7,7 @@ use axum::extract::{Path, Query, State}; use axum::http::StatusCode; use axum::routing::get; use axum::{Extension, Json, Router}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer::Consumer; use iggy::consumer_offsets::get_consumer_offset::GetConsumerOffset; use iggy::consumer_offsets::store_consumer_offset::StoreConsumerOffset; @@ -45,7 +45,7 @@ async fn get_consumer_offset( query.0.partition_id, ) .await - .with_error(|_| format!("{COMPONENT} - failed to get consumer offset, stream ID: {}, topic ID: {}, patition ID: {:?}", stream_id, topic_id, query.0.partition_id)); + .with_error_context(|_| format!("{COMPONENT} - failed to get consumer offset, stream ID: {}, topic ID: {}, patition ID: {:?}", stream_id, topic_id, query.0.partition_id)); if offset.is_err() { return Err(CustomError::ResourceNotFound); } @@ -74,6 +74,6 @@ async fn store_consumer_offset( command.0.offset, ) .await - .with_error(|_| format!("{COMPONENT} - failed to store consumer offset, stream ID: {}, topic ID: {}, partition ID: {:?}", stream_id, topic_id, command.0.partition_id))?; + .with_error_context(|_| format!("{COMPONENT} - failed to store consumer offset, stream ID: {}, topic ID: {}, partition ID: {:?}", stream_id, topic_id, command.0.partition_id))?; Ok(StatusCode::NO_CONTENT) } diff --git a/server/src/http/jwt/jwt_manager.rs b/server/src/http/jwt/jwt_manager.rs index dad9a10a9..bd632bd11 100644 --- a/server/src/http/jwt/jwt_manager.rs +++ b/server/src/http/jwt/jwt_manager.rs @@ -3,7 +3,7 @@ use crate::http::jwt::json_web_token::{GeneratedToken, JwtClaims, RevokedAccessT use crate::http::jwt::storage::TokenStorage; use crate::http::jwt::COMPONENT; use crate::streaming::persistence::persister::Persister; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::locking::IggySharedMut; use iggy::locking::IggySharedMutFn; @@ -76,7 +76,7 @@ impl JwtManager { not_before: config.not_before, key: config .get_encoding_key() - .with_error(|_| format!("{COMPONENT} - failed to get encoding key"))?, + .with_error_context(|_| format!("{COMPONENT} - failed to get encoding key"))?, algorithm, }; let validator = ValidatorOptions { @@ -85,7 +85,7 @@ impl JwtManager { clock_skew: config.clock_skew, key: config .get_decoding_key() - .with_error(|_| format!("{COMPONENT} - failed to get decoding key"))?, + .with_error_context(|_| format!("{COMPONENT} - failed to get decoding key"))?, }; JwtManager::new(persister, path, issuer, validator) } @@ -137,7 +137,7 @@ impl JwtManager { self.tokens_storage .delete_revoked_access_tokens(&tokens_to_delete) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to delete revoked access tokens, IDs {:?}", tokens_to_delete @@ -211,7 +211,9 @@ impl JwtManager { expiry, }) .await - .with_error(|_| format!("{COMPONENT} - failed to save revoked access token: {}", id))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to save revoked access token: {}", id) + })?; self.generate(jwt_claims.claims.sub) } @@ -256,7 +258,7 @@ impl JwtManager { expiry, }) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to save revoked access token: {}", token_id diff --git a/server/src/http/jwt/middleware.rs b/server/src/http/jwt/middleware.rs index c1ec6c399..ffc713154 100644 --- a/server/src/http/jwt/middleware.rs +++ b/server/src/http/jwt/middleware.rs @@ -7,7 +7,7 @@ use axum::{ middleware::Next, response::Response, }; -use error_set::ResultContext; +use error_set::ErrContext; use std::sync::Arc; const AUTHORIZATION: &str = "authorization"; @@ -37,9 +37,9 @@ pub async fn jwt_auth( .headers() .get(AUTHORIZATION) .ok_or(UNAUTHORIZED) - .with_error(|_| "{COMPONENT} - missing or inaccessible Authorization header")? + .with_error_context(|_| "{COMPONENT} - missing or inaccessible Authorization header")? .to_str() - .with_error(|_| "{COMPONENT} - invalid authorization header format") + .with_error_context(|_| "{COMPONENT} - invalid authorization header format") .map_err(|_| UNAUTHORIZED)?; if !bearer.starts_with(BEARER) { @@ -48,12 +48,12 @@ pub async fn jwt_auth( let jwt_token = &bearer[BEARER.len()..]; let token_header = jsonwebtoken::decode_header(jwt_token) - .with_error(|_| "{COMPONENT} - failed to decode JWT header") + .with_error_context(|_| "{COMPONENT} - failed to decode JWT header") .map_err(|_| UNAUTHORIZED)?; let jwt_claims = state .jwt_manager .decode(jwt_token, token_header.alg) - .with_error(|_| "{COMPONENT} - failed to decode JWT with provided algorithm") + .with_error_context(|_| "{COMPONENT} - failed to decode JWT with provided algorithm") .map_err(|_| UNAUTHORIZED)?; if state .jwt_manager diff --git a/server/src/http/jwt/storage.rs b/server/src/http/jwt/storage.rs index dccf6b047..c233c3dc5 100644 --- a/server/src/http/jwt/storage.rs +++ b/server/src/http/jwt/storage.rs @@ -4,7 +4,7 @@ use crate::streaming::persistence::persister::Persister; use crate::streaming::utils::file; use anyhow::Context; use bytes::{BufMut, BytesMut}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use std::collections::HashMap; use std::sync::Arc; @@ -42,7 +42,7 @@ impl TokenStorage { let file_size = file .metadata() .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to read file metadata, path: {}", self.path @@ -54,7 +54,7 @@ impl TokenStorage { buffer.put_bytes(0, file_size); file.read_exact(&mut buffer) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to read file into buffer, path: {}", self.path @@ -91,7 +91,7 @@ impl TokenStorage { self.persister .overwrite(&self.path, &bytes) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to overwrite file, path: {}", self.path @@ -104,7 +104,7 @@ impl TokenStorage { let tokens = self .load_all_revoked_access_tokens() .await - .with_error(|_| "{COMPONENT} - failed to load revoked access tokens")?; + .with_error_context(|_| "{COMPONENT} - failed to load revoked access tokens")?; if tokens.is_empty() { return Ok(()); } @@ -123,7 +123,7 @@ impl TokenStorage { self.persister .overwrite(&self.path, &bytes) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to overwrite file, path: {}", self.path diff --git a/server/src/http/messages.rs b/server/src/http/messages.rs index 6e7fd65c0..88cbc031b 100644 --- a/server/src/http/messages.rs +++ b/server/src/http/messages.rs @@ -9,7 +9,7 @@ use axum::extract::{Path, Query, State}; use axum::http::StatusCode; use axum::routing::get; use axum::{Extension, Json, Router}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer::Consumer; use iggy::identifier::Identifier; use iggy::messages::poll_messages::PollMessages; @@ -54,7 +54,7 @@ async fn poll_messages( PollingArgs::new(query.0.strategy, query.0.count, query.0.auto_commit), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to poll messages, stream ID: {}, topic ID: {}, partition ID: {:?}", stream_id, topic_id, query.0.partition_id @@ -93,7 +93,7 @@ async fn send_messages( messages, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to append messages, stream ID: {}, topic ID: {}", stream_id, topic_id diff --git a/server/src/http/partitions.rs b/server/src/http/partitions.rs index 75875458c..77d02384d 100644 --- a/server/src/http/partitions.rs +++ b/server/src/http/partitions.rs @@ -8,7 +8,7 @@ use axum::extract::{Path, Query, State}; use axum::http::StatusCode; use axum::routing::post; use axum::{Extension, Json, Router}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::identifier::Identifier; use iggy::partitions::create_partitions::CreatePartitions; use iggy::partitions::delete_partitions::DeletePartitions; @@ -45,7 +45,7 @@ async fn create_partitions( command.partitions_count, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to create partitions, stream ID: {}, topic ID: {}", stream_id, topic_id @@ -58,7 +58,7 @@ async fn create_partitions( .state .apply(identity.user_id, EntryCommand::CreatePartitions(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply create partitions, stream ID: {}, topic ID: {}", stream_id, topic_id @@ -87,7 +87,7 @@ async fn delete_partitions( query.partitions_count, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to delete partitions, stream ID: {}, topic ID: {}", stream_id, topic_id @@ -107,7 +107,7 @@ async fn delete_partitions( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply delete partitions, stream ID: {}, topic ID: {}", stream_id, topic_id diff --git a/server/src/http/personal_access_tokens.rs b/server/src/http/personal_access_tokens.rs index 761fb8c45..dc579ccc6 100644 --- a/server/src/http/personal_access_tokens.rs +++ b/server/src/http/personal_access_tokens.rs @@ -12,7 +12,7 @@ use axum::extract::{Path, State}; use axum::http::StatusCode; use axum::routing::{delete, get, post}; use axum::{Extension, Json, Router}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::models::identity_info::IdentityInfo; use iggy::models::personal_access_token::{PersonalAccessTokenInfo, RawPersonalAccessToken}; use iggy::personal_access_tokens::create_personal_access_token::CreatePersonalAccessToken; @@ -47,7 +47,7 @@ async fn get_personal_access_tokens( let personal_access_tokens = system .get_personal_access_tokens(&Session::stateless(identity.user_id, identity.ip_address)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get personal access tokens, user ID: {}", identity.user_id @@ -74,7 +74,7 @@ async fn create_personal_access_token( command.expiry, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to create personal access token, user ID: {}", identity.user_id @@ -94,7 +94,7 @@ async fn create_personal_access_token( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply create personal access token with hash, user ID: {}", identity.user_id @@ -117,7 +117,7 @@ async fn delete_personal_access_token( &name, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to delete personal access token, user ID: {}", identity.user_id @@ -133,7 +133,7 @@ async fn delete_personal_access_token( EntryCommand::DeletePersonalAccessToken(DeletePersonalAccessToken { name }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply delete personal access token, user ID: {}", identity.user_id @@ -152,7 +152,7 @@ async fn login_with_personal_access_token( let user = system .login_with_personal_access_token(&command.token, None) .await - .with_error(|_| "{COMPONENT} - failed to login with personal access token")?; + .with_error_context(|_| "{COMPONENT} - failed to login with personal access token")?; let tokens = state.jwt_manager.generate(user.id)?; Ok(Json(map_generated_access_token_to_identity_info(tokens))) } diff --git a/server/src/http/streams.rs b/server/src/http/streams.rs index 88a7a85f0..6a7818923 100644 --- a/server/src/http/streams.rs +++ b/server/src/http/streams.rs @@ -8,7 +8,7 @@ use axum::extract::{Path, State}; use axum::http::StatusCode; use axum::routing::{delete, get}; use axum::{Extension, Json, Router}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::identifier::Identifier; use iggy::models::stream::{Stream, StreamDetails}; use iggy::streams::create_stream::CreateStream; @@ -58,7 +58,7 @@ async fn get_streams( let system = state.system.read().await; let streams = system .find_streams(&Session::stateless(identity.user_id, identity.ip_address)) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to find streams, user ID: {}", identity.user_id @@ -85,7 +85,7 @@ async fn create_stream( &command.name, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to create stream, stream ID: {:?}", command.stream_id @@ -100,7 +100,7 @@ async fn create_stream( .state .apply(identity.user_id, EntryCommand::CreateStream(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply create stream, stream ID: {:?}", stream_id @@ -127,7 +127,7 @@ async fn update_stream( &command.name, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to update stream, stream ID: {}", stream_id @@ -140,7 +140,7 @@ async fn update_stream( .state .apply(identity.user_id, EntryCommand::UpdateStream(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply update stream, stream ID: {}", stream_id @@ -164,7 +164,7 @@ async fn delete_stream( &identifier_stream_id, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to delete stream, stream ID: {}", stream_id @@ -182,7 +182,7 @@ async fn delete_stream( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply delete stream, stream ID: {}", stream_id @@ -205,7 +205,7 @@ async fn purge_stream( &identifier_stream_id, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to purge stream, stream ID: {}", stream_id @@ -220,7 +220,7 @@ async fn purge_stream( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply purge stream, stream ID: {}", stream_id diff --git a/server/src/http/system.rs b/server/src/http/system.rs index 829f900cc..07535c212 100644 --- a/server/src/http/system.rs +++ b/server/src/http/system.rs @@ -13,7 +13,7 @@ use axum::routing::{get, post}; use axum::{Extension, Json, Router}; use bytes::Bytes; use chrono::Local; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::locking::IggySharedMutFn; use iggy::models::client_info::{ClientInfo, ClientInfoDetails}; use iggy::models::stats::Stats; @@ -49,7 +49,7 @@ async fn get_stats(State(state): State>) -> Result, Cu let stats = system .get_stats() .await - .with_error(|_| format!("{COMPONENT} - failed to get stats"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to get stats"))?; Ok(Json(stats)) } @@ -65,7 +65,7 @@ async fn get_client( client_id, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get client, user ID: {}", identity.user_id @@ -89,7 +89,7 @@ async fn get_clients( let clients = system .get_clients(&Session::stateless(identity.user_id, identity.ip_address)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get clients, user ID: {}", identity.user_id diff --git a/server/src/http/topics.rs b/server/src/http/topics.rs index 9fe62d013..8eee30fad 100644 --- a/server/src/http/topics.rs +++ b/server/src/http/topics.rs @@ -9,7 +9,7 @@ use axum::extract::{Path, State}; use axum::http::StatusCode; use axum::routing::{delete, get}; use axum::{Extension, Json, Router}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::identifier::Identifier; use iggy::models::topic::{Topic, TopicDetails}; use iggy::topics::create_topic::CreateTopic; @@ -51,7 +51,7 @@ async fn get_topic( &identity_stream_id, &identity_topic_id, ) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to find topic, stream ID: {}, topic ID: {}", stream_id, topic_id @@ -77,7 +77,7 @@ async fn get_topics( &Session::stateless(identity.user_id, identity.ip_address), &stream_id, ) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to find topic, stream ID: {}", stream_id @@ -112,7 +112,7 @@ async fn create_topic( command.replication_factor, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to create topic, stream ID: {}", stream_id @@ -128,7 +128,7 @@ async fn create_topic( .state .apply(identity.user_id, EntryCommand::CreateTopic(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply create topic, stream ID: {}", stream_id @@ -161,7 +161,7 @@ async fn update_topic( command.replication_factor, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to update topic, stream ID: {}, topic ID: {}", stream_id, topic_id @@ -176,7 +176,7 @@ async fn update_topic( .state .apply(identity.user_id, EntryCommand::UpdateTopic(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply update topic, stream ID: {}, topic ID: {}", stream_id, topic_id @@ -202,7 +202,7 @@ async fn delete_topic( &identifier_topic_id, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to delete topic, stream ID: {}, topic ID: {}", stream_id, topic_id @@ -221,7 +221,7 @@ async fn delete_topic( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply delete topic, stream ID: {}, topic ID: {}", stream_id, topic_id @@ -246,7 +246,7 @@ async fn purge_topic( &identifier_topic_id, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to purge topic, stream ID: {}, topic ID: {}", stream_id, topic_id @@ -262,7 +262,7 @@ async fn purge_topic( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply purge topic, stream ID: {}, topic ID: {}", stream_id, topic_id diff --git a/server/src/http/users.rs b/server/src/http/users.rs index c78ea79b5..adb2d5c0a 100644 --- a/server/src/http/users.rs +++ b/server/src/http/users.rs @@ -11,7 +11,7 @@ use axum::extract::{Path, State}; use axum::http::StatusCode; use axum::routing::{delete, get, post, put}; use axum::{Extension, Json, Router}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::identifier::Identifier; use iggy::models::identity_info::IdentityInfo; use iggy::models::user_info::{UserInfo, UserInfoDetails}; @@ -53,7 +53,7 @@ async fn get_user( &Session::stateless(identity.user_id, identity.ip_address), &identifier_user_id, ) - .with_error(|_| format!("{COMPONENT} - failed to find user, user ID: {}", user_id)); + .with_error_context(|_| format!("{COMPONENT} - failed to find user, user ID: {}", user_id)); if user.is_err() { return Err(CustomError::ResourceNotFound); } @@ -70,7 +70,7 @@ async fn get_users( let users = system .get_users(&Session::stateless(identity.user_id, identity.ip_address)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get users, user ID: {}", identity.user_id @@ -99,7 +99,7 @@ async fn create_user( command.permissions.clone(), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to create user, username: {}", command.username @@ -122,7 +122,7 @@ async fn create_user( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply create user, username: {}", command.username @@ -151,7 +151,9 @@ async fn update_user( command.status, ) .await - .with_error(|_| format!("{COMPONENT} - failed to update user, user ID: {}", user_id))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to update user, user ID: {}", user_id) + })?; } let system = state.system.read().await; @@ -159,7 +161,7 @@ async fn update_user( .state .apply(identity.user_id, EntryCommand::UpdateUser(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply update user, user ID: {}", user_id @@ -186,7 +188,7 @@ async fn update_permissions( command.permissions.clone(), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to update permissions, user ID: {}", user_id @@ -199,7 +201,7 @@ async fn update_permissions( .state .apply(identity.user_id, EntryCommand::UpdatePermissions(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply update permissions, user ID: {}", user_id @@ -227,7 +229,7 @@ async fn change_password( &command.new_password, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to change password, user ID: {}", user_id @@ -248,7 +250,7 @@ async fn change_password( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply change password, user ID: {}", user_id @@ -272,7 +274,9 @@ async fn delete_user( &identifier_user_id, ) .await - .with_error(|_| format!("{COMPONENT} - failed to delete user, user ID: {}", user_id))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to delete user, user ID: {}", user_id) + })?; } let system = state.system.read().await; @@ -285,7 +289,7 @@ async fn delete_user( }), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply delete user, user ID: {}", user_id @@ -304,7 +308,7 @@ async fn login_user( let user = system .login_user(&command.username, &command.password, None) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to login, username: {}", command.username @@ -323,7 +327,7 @@ async fn logout_user( system .logout_user(&Session::stateless(identity.user_id, identity.ip_address)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to logout, user ID: {}", identity.user_id @@ -333,7 +337,7 @@ async fn logout_user( .jwt_manager .revoke_token(&identity.token_id, identity.token_expiry) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to revoke token, user ID: {}", identity.user_id @@ -350,7 +354,7 @@ async fn refresh_token( .jwt_manager .refresh_token(&command.token) .await - .with_error(|_| "{COMPONENT} - failed to refresh token")?; + .with_error_context(|_| "{COMPONENT} - failed to refresh token")?; Ok(Json(map_generated_access_token_to_identity_info(token))) } diff --git a/server/src/quic/quic_sender.rs b/server/src/quic/quic_sender.rs index cf77524a5..31f8ebeb4 100644 --- a/server/src/quic/quic_sender.rs +++ b/server/src/quic/quic_sender.rs @@ -1,7 +1,7 @@ use crate::binary::sender::Sender; use crate::quic::COMPONENT; use async_trait::async_trait; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use quinn::{RecvStream, SendStream}; use tracing::{debug, error}; @@ -49,11 +49,11 @@ impl QuicSender { self.send .write_all(&[status, &length, payload].as_slice().concat()) .await - .with_error(|_| format!("{COMPONENT} - failed to write buffer to the stream")) + .with_error_context(|_| format!("{COMPONENT} - failed to write buffer to the stream")) .map_err(|_| IggyError::QuicError)?; self.send .finish() - .with_error(|_| format!("{COMPONENT} - failed to finish send stream")) + .with_error_context(|_| format!("{COMPONENT} - failed to finish send stream")) .map_err(|_| IggyError::QuicError)?; debug!("Sent response with status: {:?}", status); Ok(()) diff --git a/server/src/quic/quic_server.rs b/server/src/quic/quic_server.rs index 0215c6080..0a529b802 100644 --- a/server/src/quic/quic_server.rs +++ b/server/src/quic/quic_server.rs @@ -5,7 +5,7 @@ use std::net::SocketAddr; use std::sync::Arc; use anyhow::Result; -use error_set::ResultContext; +use error_set::ErrContext; use quinn::{Endpoint, IdleTimeout, VarInt}; use rustls::pki_types::{CertificateDer, PrivateKeyDer}; use tracing::info; @@ -39,7 +39,7 @@ fn configure_quic(config: QuicConfig) -> Result Result<(Vec>, PrivateKeyDer<'static>), Box> { - let mut cert_chain_reader = BufReader::new( - File::open(cert_file) - .with_error(|_| format!("{COMPONENT} - failed to open cert file: {cert_file}"))?, - ); + let mut cert_chain_reader = + BufReader::new(File::open(cert_file).with_error_context(|_| { + format!("{COMPONENT} - failed to open cert file: {cert_file}") + })?); let certs = rustls_pemfile::certs(&mut cert_chain_reader) .map(|x| CertificateDer::from(x.unwrap().to_vec())) .collect(); - let mut key_reader = BufReader::new( - File::open(key_file) - .with_error(|_| format!("{COMPONENT} - failed to open key file: {key_file}"))?, - ); + let mut key_reader = + BufReader::new(File::open(key_file).with_error_context(|_| { + format!("{COMPONENT} - failed to open key file: {key_file}") + })?); let mut keys = rustls_pemfile::rsa_private_keys(&mut key_reader) .filter(|key| key.is_ok()) .map(|key| PrivateKeyDer::try_from(key.unwrap().secret_pkcs1_der().to_vec())) diff --git a/server/src/state/file.rs b/server/src/state/file.rs index 5d118d9a7..18c1a7b12 100644 --- a/server/src/state/file.rs +++ b/server/src/state/file.rs @@ -5,7 +5,7 @@ use crate::streaming::utils::file; use crate::versioning::SemanticVersion; use async_trait::async_trait; use bytes::{Buf, BufMut, Bytes, BytesMut}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::bytes_serializable::BytesSerializable; use iggy::error::IggyError; use iggy::utils::byte_size::IggyByteSize; @@ -73,7 +73,7 @@ impl State for FileState { self.persister .overwrite(&self.path, &[]) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to overwrite state file, path: {}", self.path @@ -84,7 +84,7 @@ impl State for FileState { let entries = self .load_entries() .await - .with_error(|_| format!("{COMPONENT} - failed to load entries"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to load entries"))?; let entries_count = entries.len() as u64; self.entries_count.store(entries_count, Ordering::SeqCst); if entries_count == 0 { @@ -104,7 +104,7 @@ impl State for FileState { let file = file::open(&self.path) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to open state file, path: {}", self.path @@ -114,7 +114,7 @@ impl State for FileState { let file_size = file .metadata() .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to load state file metadata, path: {}", self.path @@ -140,7 +140,7 @@ impl State for FileState { let index = reader .read_u64_le() .await - .with_error(|_| format!("{FILE_STATE_PARSE_ERROR} index")) + .with_error_context(|_| format!("{FILE_STATE_PARSE_ERROR} index")) .map_err(|_| IggyError::InvalidNumberEncoding)?; total_size += 8; if entries_count > 0 && index != current_index + 1 { @@ -157,51 +157,51 @@ impl State for FileState { let term = reader .read_u64_le() .await - .with_error(|_| format!("{FILE_STATE_PARSE_ERROR} term")) + .with_error_context(|_| format!("{FILE_STATE_PARSE_ERROR} term")) .map_err(|_| IggyError::InvalidNumberEncoding)?; total_size += 8; let leader_id = reader .read_u32_le() .await - .with_error(|_| format!("{FILE_STATE_PARSE_ERROR} leader_id")) + .with_error_context(|_| format!("{FILE_STATE_PARSE_ERROR} leader_id")) .map_err(|_| IggyError::InvalidNumberEncoding)?; total_size += 4; let version = reader .read_u32_le() .await - .with_error(|_| format!("{FILE_STATE_PARSE_ERROR} version")) + .with_error_context(|_| format!("{FILE_STATE_PARSE_ERROR} version")) .map_err(|_| IggyError::InvalidNumberEncoding)?; total_size += 4; let flags = reader .read_u64_le() .await - .with_error(|_| format!("{FILE_STATE_PARSE_ERROR} flags")) + .with_error_context(|_| format!("{FILE_STATE_PARSE_ERROR} flags")) .map_err(|_| IggyError::InvalidNumberEncoding)?; total_size += 8; let timestamp = IggyTimestamp::from( reader .read_u64_le() .await - .with_error(|_| format!("{FILE_STATE_PARSE_ERROR} timestamp")) + .with_error_context(|_| format!("{FILE_STATE_PARSE_ERROR} timestamp")) .map_err(|_| IggyError::InvalidNumberEncoding)?, ); total_size += 8; let user_id = reader .read_u32_le() .await - .with_error(|_| format!("{FILE_STATE_PARSE_ERROR} user_id")) + .with_error_context(|_| format!("{FILE_STATE_PARSE_ERROR} user_id")) .map_err(|_| IggyError::InvalidNumberEncoding)?; total_size += 4; let checksum = reader .read_u32_le() .await - .with_error(|_| format!("{FILE_STATE_PARSE_ERROR} checksum")) + .with_error_context(|_| format!("{FILE_STATE_PARSE_ERROR} checksum")) .map_err(|_| IggyError::InvalidNumberEncoding)?; total_size += 4; let context_length = reader .read_u32_le() .await - .with_error(|_| format!("{FILE_STATE_PARSE_ERROR} context context_length")) + .with_error_context(|_| format!("{FILE_STATE_PARSE_ERROR} context context_length")) .map_err(|_| IggyError::InvalidNumberEncoding)? as usize; total_size += 4; @@ -216,13 +216,13 @@ impl State for FileState { let code = reader .read_u32_le() .await - .with_error(|_| format!("{FILE_STATE_PARSE_ERROR} code")) + .with_error_context(|_| format!("{FILE_STATE_PARSE_ERROR} code")) .map_err(|_| IggyError::InvalidNumberEncoding)?; total_size += 4; let mut command_length = reader .read_u32_le() .await - .with_error(|_| format!("{FILE_STATE_PARSE_ERROR} command_length")) + .with_error_context(|_| format!("{FILE_STATE_PARSE_ERROR} command_length")) .map_err(|_| IggyError::InvalidNumberEncoding)? as usize; total_size += 4; @@ -247,7 +247,7 @@ impl State for FileState { entry_command.put_u32_le(command_length as u32); entry_command.extend(command_payload); let command = entry_command.freeze(); - EntryCommand::from_bytes(command.clone()).with_error(|_| { + EntryCommand::from_bytes(command.clone()).with_error_context(|_| { format!("{COMPONENT} - failed to parse entry command from bytes") })?; let calculated_checksum = StateEntry::calculate_checksum( @@ -315,8 +315,9 @@ impl State for FileState { let command_code = command.slice(0..4).get_u32_le(); let mut command_length = command.slice(4..8).get_u32_le() as usize; let command_payload = command.slice(8..8 + command_length); - let encrypted_command_payload = - encryptor.encrypt(&command_payload).with_error(|_| { + let encrypted_command_payload = encryptor + .encrypt(&command_payload) + .with_error_context(|_| { format!( "{COMPONENT} - failed to encrypt state entry command, index: {}", index @@ -347,7 +348,7 @@ impl State for FileState { self.persister .append(&self.path, &bytes) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to append state entry data to file, path: {}, data size: {}", self.path, diff --git a/server/src/state/models.rs b/server/src/state/models.rs index 35155029f..5b7fe270f 100644 --- a/server/src/state/models.rs +++ b/server/src/state/models.rs @@ -1,6 +1,6 @@ use crate::state::COMPONENT; use bytes::{BufMut, Bytes, BytesMut}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::bytes_serializable::BytesSerializable; use iggy::command::Command; use iggy::error::IggyError; @@ -48,7 +48,7 @@ impl BytesSerializable for CreatePersonalAccessTokenWithHash { let command_length = u32::from_le_bytes( bytes[position..position + 4] .try_into() - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to parse personal access token command length") }) .map_err(|_| IggyError::InvalidNumberEncoding)?, @@ -56,13 +56,14 @@ impl BytesSerializable for CreatePersonalAccessTokenWithHash { position += 4; let command_bytes = bytes.slice(position..position + command_length as usize); position += command_length as usize; - let command = CreatePersonalAccessToken::from_bytes(command_bytes).with_error(|_| { - format!("{COMPONENT} - failed to parse personal access token command") - })?; + let command = + CreatePersonalAccessToken::from_bytes(command_bytes).with_error_context(|_| { + format!("{COMPONENT} - failed to parse personal access token command") + })?; let hash_length = u32::from_le_bytes( bytes[position..position + 4] .try_into() - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to parse personal access token hash length") }) .map_err(|_| IggyError::InvalidNumberEncoding)?, diff --git a/server/src/state/system.rs b/server/src/state/system.rs index 4279f58fb..5093b2de9 100644 --- a/server/src/state/system.rs +++ b/server/src/state/system.rs @@ -1,6 +1,6 @@ use crate::state::{EntryCommand, StateEntry, COMPONENT}; use crate::streaming::personal_access_tokens::personal_access_token::PersonalAccessToken; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::compression::compression_algorithm::CompressionAlgorithm; use iggy::error::IggyError; use iggy::identifier::{IdKind, Identifier}; @@ -79,7 +79,7 @@ impl SystemState { let mut current_user_id = 0; for entry in entries { debug!("Processing state entry: {entry}",); - match entry.command().with_error(|_| { + match entry.command().with_error_context(|_| { format!("{COMPONENT} - failed to retrieve state entry command: {entry}") })? { EntryCommand::CreateStream(command) => { @@ -323,7 +323,7 @@ impl SystemState { let token_hash = command.hash; let user_id = find_user_id( &users, - &entry.user_id.try_into().with_error(|_| { + &entry.user_id.try_into().with_error_context(|_| { format!( "{COMPONENT} - failed to find user, user ID: {}", entry.user_id @@ -356,7 +356,7 @@ impl SystemState { EntryCommand::DeletePersonalAccessToken(command) => { let user_id = find_user_id( &users, - &entry.user_id.try_into().with_error(|_| { + &entry.user_id.try_into().with_error_context(|_| { format!( "{COMPONENT} - failed to find user, user ID: {}", entry.user_id diff --git a/server/src/streaming/models/messages.rs b/server/src/streaming/models/messages.rs index 0f174c230..76410e353 100644 --- a/server/src/streaming/models/messages.rs +++ b/server/src/streaming/models/messages.rs @@ -1,7 +1,7 @@ use crate::streaming::local_sizeable::LocalSizeable; use crate::streaming::models::COMPONENT; use bytes::{BufMut, Bytes, BytesMut}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::bytes_serializable::BytesSerializable; use iggy::error::IggyError; use iggy::models::messages::PolledMessage; @@ -93,33 +93,35 @@ impl RetainedMessage { let offset = u64::from_le_bytes( bytes[..8] .try_into() - .with_error(|_| format!("{COMPONENT} - failed to parse message offset")) + .with_error_context(|_| format!("{COMPONENT} - failed to parse message offset")) .map_err(|_| IggyError::InvalidNumberEncoding)?, ); let message_state = MessageState::from_code(bytes[8]) - .with_error(|_| format!("{COMPONENT} - failed to parse message state"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to parse message state"))?; let timestamp = u64::from_le_bytes( bytes[9..17] .try_into() - .with_error(|_| format!("{COMPONENT} - failed to parse message timestamp")) + .with_error_context(|_| format!("{COMPONENT} - failed to parse message timestamp")) .map_err(|_| IggyError::InvalidNumberEncoding)?, ); let id = u128::from_le_bytes( bytes[17..33] .try_into() - .with_error(|_| format!("{COMPONENT} - failed to parse message id")) + .with_error_context(|_| format!("{COMPONENT} - failed to parse message id")) .map_err(|_| IggyError::InvalidNumberEncoding)?, ); let checksum = u32::from_le_bytes( bytes[33..37] .try_into() - .with_error(|_| format!("{COMPONENT} - failed to parse message checksum")) + .with_error_context(|_| format!("{COMPONENT} - failed to parse message checksum")) .map_err(|_| IggyError::InvalidNumberEncoding)?, ); let headers_length = u32::from_le_bytes( bytes[37..41] .try_into() - .with_error(|_| format!("{COMPONENT} - failed to parse message headers_length")) + .with_error_context(|_| { + format!("{COMPONENT} - failed to parse message headers_length") + }) .map_err(|_| IggyError::InvalidNumberEncoding)?, ); let headers = if headers_length > 0 { diff --git a/server/src/streaming/partitions/consumer_offsets.rs b/server/src/streaming/partitions/consumer_offsets.rs index f0b848005..eccc0b254 100644 --- a/server/src/streaming/partitions/consumer_offsets.rs +++ b/server/src/streaming/partitions/consumer_offsets.rs @@ -2,7 +2,7 @@ use crate::streaming::partitions::partition::{ConsumerOffset, Partition}; use crate::streaming::partitions::COMPONENT; use crate::streaming::polling_consumer::PollingConsumer; use dashmap::DashMap; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer::ConsumerKind; use iggy::error::IggyError; use tracing::trace; @@ -54,12 +54,12 @@ impl Partition { PollingConsumer::Consumer(consumer_id, _) => { self.store_offset(ConsumerKind::Consumer, consumer_id, offset) .await - .with_error(|_| format!("{COMPONENT} - failed to store consumer offset, consumer ID: {}, offset: {}", consumer_id, offset))?; + .with_error_context(|_| format!("{COMPONENT} - failed to store consumer offset, consumer ID: {}, offset: {}", consumer_id, offset))?; } PollingConsumer::ConsumerGroup(consumer_id, _) => { self.store_offset(ConsumerKind::ConsumerGroup, consumer_id, offset) .await - .with_error(|_| format!("{COMPONENT} - failed to store consumer group offset, consumer ID: {}, offset: {}", consumer_id, offset))?; + .with_error_context(|_| format!("{COMPONENT} - failed to store consumer group offset, consumer ID: {}, offset: {}", consumer_id, offset))?; } }; @@ -79,7 +79,7 @@ impl Partition { .partition .save_consumer_offset(&consumer_offset) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to save consumer offset, consumer ID: {}, offset: {}", consumer_id, offset @@ -97,7 +97,7 @@ impl Partition { .partition .save_consumer_offset(&consumer_offset) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to save new consumer offset, consumer ID: {}, offset: {}", consumer_id, offset @@ -116,7 +116,7 @@ impl Partition { ); self.load_consumer_offsets_from_storage(ConsumerKind::Consumer) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to load consumer offsets from storage") })?; self.load_consumer_offsets_from_storage(ConsumerKind::ConsumerGroup) @@ -136,7 +136,7 @@ impl Partition { .partition .load_consumer_offsets(kind, path) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to load consumer offsets, kind: {kind}, path: {path}") })?; let consumer_offsets = self.get_consumer_offsets(kind); diff --git a/server/src/streaming/partitions/messages.rs b/server/src/streaming/partitions/messages.rs index ab8e6f0de..d378d5854 100644 --- a/server/src/streaming/partitions/messages.rs +++ b/server/src/streaming/partitions/messages.rs @@ -5,7 +5,7 @@ use crate::streaming::partitions::partition::Partition; use crate::streaming::partitions::COMPONENT; use crate::streaming::polling_consumer::PollingConsumer; use crate::streaming::segments::segment::Segment; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::messages::send_messages::Message; use iggy::models::messages::POLLED_MESSAGE_METADATA; use iggy::utils::timestamp::IggyTimestamp; @@ -47,7 +47,7 @@ impl Partition { .segment .try_load_index_for_timestamp(segment, timestamp) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "{COMPONENT} - failed to load index for timestamp, partition: {}, segment start offset: {}, timestamp: {}", self, segment.start_offset, timestamp, ))?; @@ -87,7 +87,7 @@ impl Partition { return Ok(self .get_messages_by_offset(start_offset, count) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "{COMPONENT} - failed to get messages by offset, partition: {}, timestamp: {}, start offset: {}, count: {}", self, timestamp, start_offset, count, ))? @@ -105,7 +105,7 @@ impl Partition { Ok(self .get_messages_by_offset(start_offset, adjusted_count) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "{COMPONENT} - failed to get messages by offset, patititon: {}, timestamp: {}, start offset: {}", self, timestamp, start_offset, ))? @@ -259,7 +259,7 @@ impl Partition { ) -> Result>, IggyError> { let mut messages = Vec::with_capacity(segments.len()); for segment in segments { - let segment_messages = segment.get_messages(offset, count).await.with_error(|_| format!( + let segment_messages = segment.get_messages(offset, count).await.with_error_context(|_| format!( "{COMPONENT} - failed to get messages from segment, segment: {}, offset: {}, count: {}", segment, offset, count, ))?; @@ -320,7 +320,7 @@ impl Partition { let partial_batches = segment .get_newest_batches_by_size(remaining_size) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "{COMPONENT} - failed to get newest batches by size, segment: {}, remaining size: {}", segment, remaining_size, ))? @@ -334,7 +334,7 @@ impl Partition { let segment_batches = segment .get_all_batches() .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to retrieve all batches from segment: {segment}",) })? .into_iter() @@ -415,7 +415,7 @@ impl Partition { "Current segment is closed, creating new segment with start offset: {} for partition with ID: {}...", start_offset, self.partition_id ); - self.add_persisted_segment(start_offset).await.with_error(|_| format!( + self.add_persisted_segment(start_offset).await.with_error_context(|_| format!( "{COMPONENT} - failed to add persisted segment, partition: {}, start offset: {}", self, start_offset, ))?; @@ -495,7 +495,7 @@ impl Partition { last_segment .append_batch(batch_size, messages_count, &retained_messages) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to append batch into last segment: {last_segment}", ) diff --git a/server/src/streaming/partitions/persistence.rs b/server/src/streaming/partitions/persistence.rs index 8c584066a..e692dbf50 100644 --- a/server/src/streaming/partitions/persistence.rs +++ b/server/src/streaming/partitions/persistence.rs @@ -1,7 +1,7 @@ use crate::state::system::PartitionState; use crate::streaming::partitions::partition::Partition; use crate::streaming::partitions::COMPONENT; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use std::path::Path; use std::sync::atomic::Ordering; @@ -24,7 +24,9 @@ impl Partition { .segment .delete(segment) .await - .with_error(|_| format!("{COMPONENT} - failed to delete segment: {segment}",))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to delete segment: {segment}",) + })?; self.segments_count_of_parent_stream .fetch_sub(1, Ordering::SeqCst); } @@ -45,7 +47,9 @@ impl Partition { .segment .delete(segment) .await - .with_error(|_| format!("{COMPONENT} - failed to delete segment: {segment}",))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to delete segment: {segment}",) + })?; self.segments_count_of_parent_stream .fetch_sub(1, Ordering::SeqCst); } @@ -54,19 +58,21 @@ impl Partition { .partition .delete_consumer_offsets(&self.consumer_offsets_path) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to delete consumer offsets, partition: {self}") })?; self.storage .partition .delete_consumer_offsets(&self.consumer_group_offsets_path) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to delete consumer offsets, partition: {self}") })?; - self.add_persisted_segment(0).await.with_error(|_| { - format!("{COMPONENT} - failed to add persisted segment, partition: {self}",) - })?; + self.add_persisted_segment(0) + .await + .with_error_context(|_| { + format!("{COMPONENT} - failed to add persisted segment, partition: {self}",) + })?; if !Path::new(&self.consumer_offsets_path).exists() && create_dir(&self.consumer_offsets_path).await.is_err() diff --git a/server/src/streaming/partitions/segments.rs b/server/src/streaming/partitions/segments.rs index d2d6275be..1a2342785 100644 --- a/server/src/streaming/partitions/segments.rs +++ b/server/src/streaming/partitions/segments.rs @@ -3,7 +3,7 @@ use std::sync::atomic::Ordering; use crate::streaming::partitions::partition::Partition; use crate::streaming::partitions::COMPONENT; use crate::streaming::segments::segment::Segment; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::utils::timestamp::IggyTimestamp; use tracing::info; @@ -64,7 +64,7 @@ impl Partition { self.messages_count_of_parent_topic.clone(), self.messages_count.clone(), ); - new_segment.persist().await.with_error(|_| { + new_segment.persist().await.with_error_context(|_| { format!("{COMPONENT} - failed to persist new segment: {new_segment}",) })?; self.segments.push(new_segment); @@ -88,7 +88,9 @@ impl Partition { .segment .delete(segment) .await - .with_error(|_| format!("{COMPONENT} - failed to delete segment: {segment}",))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to delete segment: {segment}",) + })?; self.segments_count_of_parent_stream .fetch_sub(1, Ordering::SeqCst); diff --git a/server/src/streaming/partitions/storage.rs b/server/src/streaming/partitions/storage.rs index 82b4ddb53..38d233361 100644 --- a/server/src/streaming/partitions/storage.rs +++ b/server/src/streaming/partitions/storage.rs @@ -9,7 +9,7 @@ use crate::streaming::storage::PartitionStorage; use crate::streaming::utils::file; use anyhow::Context; use async_trait::async_trait; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer::ConsumerKind; use iggy::error::IggyError; use std::path::Path; @@ -136,10 +136,9 @@ impl PartitionStorage for FilePartitionStorage { tokio::fs::remove_file(&time_index_path).await.unwrap(); } - segment - .load() - .await - .with_error(|_| format!("{COMPONENT} - failed to load segment: {segment}",))?; + segment.load().await.with_error_context(|_| { + format!("{COMPONENT} - failed to load segment: {segment}",) + })?; let capacity = partition.config.partition.messages_required_to_save; if !segment.is_closed { segment.unsaved_messages = Some(BatchAccumulator::new( @@ -168,7 +167,7 @@ impl PartitionStorage for FilePartitionStorage { .segment .load_message_ids(&segment) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to load message ids, segment: {segment}",) })?; for message_id in message_ids { @@ -216,9 +215,12 @@ impl PartitionStorage for FilePartitionStorage { partition.current_offset = last_segment.current_offset; } - partition.load_consumer_offsets().await.with_error(|_| { - format!("{COMPONENT} - failed to load consumer offsets, partition: {partition}",) - })?; + partition + .load_consumer_offsets() + .await + .with_error_context(|_| { + format!("{COMPONENT} - failed to load consumer offsets, partition: {partition}",) + })?; info!( "Loaded partition with ID: {} for stream with ID: {} and topic with ID: {}, current offset: {}.", partition.partition_id, partition.stream_id, partition.topic_id, partition.current_offset @@ -287,10 +289,9 @@ impl PartitionStorage for FilePartitionStorage { } for segment in partition.get_segments() { - segment - .persist() - .await - .with_error(|_| format!("{COMPONENT} - failed to persist segment: {segment}",))?; + segment.persist().await.with_error_context(|_| { + format!("{COMPONENT} - failed to persist segment: {segment}",) + })?; } info!("Saved partition with start ID: {} for stream with ID: {} and topic with ID: {}, path: {}.", partition.partition_id, partition.stream_id, partition.topic_id, partition.partition_path); @@ -347,7 +348,7 @@ impl PartitionStorage for FilePartitionStorage { self.persister .overwrite(&offset.path, &offset.offset.to_le_bytes()) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "{COMPONENT} - failed to overwrite consumer offset with value: {}, kind: {}, consumer ID: {}, path: {}", offset.offset, offset.kind, offset.consumer_id, offset.path, ))?; @@ -402,12 +403,14 @@ impl PartitionStorage for FilePartitionStorage { let consumer_id = consumer_id.unwrap(); let mut file = file::open(&path) .await - .with_error(|_| format!("{COMPONENT} - failed to open offset file, path: {path}")) + .with_error_context(|_| { + format!("{COMPONENT} - failed to open offset file, path: {path}") + }) .map_err(|_| IggyError::CannotReadFile)?; let offset = file .read_u64_le() .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to read consumer offset from file, path: {path}") }) .map_err(|_| IggyError::CannotReadFile)?; diff --git a/server/src/streaming/persistence/persister.rs b/server/src/streaming/persistence/persister.rs index 143b91f61..28ea01638 100644 --- a/server/src/streaming/persistence/persister.rs +++ b/server/src/streaming/persistence/persister.rs @@ -1,7 +1,7 @@ use crate::streaming::persistence::COMPONENT; use crate::streaming::utils::file; use async_trait::async_trait; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use std::fmt::Debug; use tokio::fs; @@ -39,11 +39,11 @@ impl Persister for FilePersister { async fn append(&self, path: &str, bytes: &[u8]) -> Result<(), IggyError> { let mut file = file::append(path) .await - .with_error(|_| format!("{COMPONENT} - failed to append to file: {path}")) + .with_error_context(|_| format!("{COMPONENT} - failed to append to file: {path}")) .map_err(|_| IggyError::CannotAppendToFile)?; file.write_all(bytes) .await - .with_error(|_| format!("{COMPONENT} - failed to write data to file: {path}")) + .with_error_context(|_| format!("{COMPONENT} - failed to write data to file: {path}")) .map_err(|_| IggyError::CannotWriteToFile)?; Ok(()) } @@ -51,11 +51,11 @@ impl Persister for FilePersister { async fn overwrite(&self, path: &str, bytes: &[u8]) -> Result<(), IggyError> { let mut file = file::overwrite(path) .await - .with_error(|_| format!("{COMPONENT} - failed to overwrite file: {path}")) + .with_error_context(|_| format!("{COMPONENT} - failed to overwrite file: {path}")) .map_err(|_| IggyError::CannotOverwriteFile)?; file.write_all(bytes) .await - .with_error(|_| format!("{COMPONENT} - failed to write data to file: {path}")) + .with_error_context(|_| format!("{COMPONENT} - failed to write data to file: {path}")) .map_err(|_| IggyError::CannotWriteToFile)?; Ok(()) } @@ -63,7 +63,7 @@ impl Persister for FilePersister { async fn delete(&self, path: &str) -> Result<(), IggyError> { fs::remove_file(path) .await - .with_error(|_| format!("{COMPONENT} - failed to delete file: {path}")) + .with_error_context(|_| format!("{COMPONENT} - failed to delete file: {path}")) .map_err(|_| IggyError::CannotDeleteFile)?; Ok(()) } @@ -74,15 +74,17 @@ impl Persister for FileWithSyncPersister { async fn append(&self, path: &str, bytes: &[u8]) -> Result<(), IggyError> { let mut file = file::append(path) .await - .with_error(|_| format!("{COMPONENT} - failed to append to file: {path}")) + .with_error_context(|_| format!("{COMPONENT} - failed to append to file: {path}")) .map_err(|_| IggyError::CannotAppendToFile)?; file.write_all(bytes) .await - .with_error(|_| format!("{COMPONENT} - failed to write data to file: {path}")) + .with_error_context(|_| format!("{COMPONENT} - failed to write data to file: {path}")) .map_err(|_| IggyError::CannotWriteToFile)?; file.sync_all() .await - .with_error(|_| format!("{COMPONENT} - failed to sync file after appending: {path}")) + .with_error_context(|_| { + format!("{COMPONENT} - failed to sync file after appending: {path}") + }) .map_err(|_| IggyError::CannotSyncFile)?; Ok(()) } @@ -90,15 +92,17 @@ impl Persister for FileWithSyncPersister { async fn overwrite(&self, path: &str, bytes: &[u8]) -> Result<(), IggyError> { let mut file = file::overwrite(path) .await - .with_error(|_| format!("{COMPONENT} - failed to overwrite file: {path}")) + .with_error_context(|_| format!("{COMPONENT} - failed to overwrite file: {path}")) .map_err(|_| IggyError::CannotOverwriteFile)?; file.write_all(bytes) .await - .with_error(|_| format!("{COMPONENT} - failed to write data to file: {path}")) + .with_error_context(|_| format!("{COMPONENT} - failed to write data to file: {path}")) .map_err(|_| IggyError::CannotWriteToFile)?; file.sync_all() .await - .with_error(|_| format!("{COMPONENT} - failed to sync file after overwriting: {path}")) + .with_error_context(|_| { + format!("{COMPONENT} - failed to sync file after overwriting: {path}") + }) .map_err(|_| IggyError::CannotSyncFile)?; Ok(()) } @@ -106,7 +110,7 @@ impl Persister for FileWithSyncPersister { async fn delete(&self, path: &str) -> Result<(), IggyError> { fs::remove_file(path) .await - .with_error(|_| format!("{COMPONENT} - failed to delete file: {path}")) + .with_error_context(|_| format!("{COMPONENT} - failed to delete file: {path}")) .map_err(|_| IggyError::CannotDeleteFile)?; Ok(()) } diff --git a/server/src/streaming/segments/messages.rs b/server/src/streaming/segments/messages.rs index fde8a7288..0a5bf98bd 100644 --- a/server/src/streaming/segments/messages.rs +++ b/server/src/streaming/segments/messages.rs @@ -4,7 +4,7 @@ use crate::streaming::batching::message_batch::{RetainedMessageBatch, RETAINED_B use crate::streaming::models::messages::RetainedMessage; use crate::streaming::segments::index::{Index, IndexRange}; use crate::streaming::segments::segment::Segment; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::utils::byte_size::IggyByteSize; use iggy::utils::sizeable::Sizeable; @@ -58,7 +58,7 @@ impl Segment { } // Can this be somehow improved? maybe with chain iterators - let mut messages = self.load_messages_from_disk(offset, end_offset).await.with_error(|_| format!( + let mut messages = self.load_messages_from_disk(offset, end_offset).await.with_error_context(|_| format!( "STREAMING_SEGMENT - failed to load messages from disk, stream ID: {}, topic ID: {}, partition ID: {}, start offset: {}, end offset :{}", self.stream_id, self.topic_id, self.partition_id, offset, end_offset, ))?; @@ -89,7 +89,7 @@ impl Segment { .segment .load_newest_batches_by_size(self, size_bytes) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "STREAMING_SEGMENT - failed to load newest batches by size, stream ID: {}, topic ID: {}, partition ID: {}, size: {}", self.stream_id, self.topic_id, self.partition_id, size_bytes, ))?; @@ -155,7 +155,7 @@ impl Segment { .segment .load_index_range(self, start_offset, end_offset) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "STREAMING_SEGMENT - failed to load index range, stream ID: {}, topic ID: {}, partition ID: {}, start offset: {}, end offset :{}", self.stream_id, self.topic_id, self.partition_id, start_offset, end_offset, ))? @@ -180,7 +180,7 @@ impl Segment { .segment .load_message_batches(self, index_range) .await - .with_error(|_| format!( + .with_error_context(|_| format!( "STREAMING_SEGMENT - failed to load message batches, stream ID: {}, topic ID: {}, partition ID: {}, start offset: {}, end offset: {}", self.stream_id, self.topic_id, self.partition_id, start_offset, end_offset, ))? @@ -283,7 +283,7 @@ impl Segment { self.unsaved_messages = Some(batch_accumulator); } let saved_bytes = storage.save_batches(self, batch).await?; - storage.save_index(&self.index_path, index).await.with_error(|_| format!( + storage.save_index(&self.index_path, index).await.with_error_context(|_| format!( "STREAMING_SEGMENT - failed to save index, stream ID: {}, topic ID: {}, partition ID: {}, path: {}", self.stream_id, self.topic_id, self.partition_id, self.index_path, ))?; diff --git a/server/src/streaming/segments/storage.rs b/server/src/streaming/segments/storage.rs index 8660d62d3..ae13362e1 100644 --- a/server/src/streaming/segments/storage.rs +++ b/server/src/streaming/segments/storage.rs @@ -11,7 +11,7 @@ use crate::streaming::utils::head_tail_buf::HeadTailBuffer; use anyhow::Context; use async_trait::async_trait; use bytes::{BufMut, BytesMut}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::utils::byte_size::IggyByteSize; use iggy::utils::checksum; @@ -50,7 +50,7 @@ impl SegmentStorage for FileSegmentStorage { ); let log_file = file::open(&segment.log_path) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to open log_file, path: {}", segment.log_path @@ -68,7 +68,7 @@ impl SegmentStorage for FileSegmentStorage { .segment .load_all_indexes(segment) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to load indexes, segment: {}", segment) })?, ); @@ -165,7 +165,7 @@ impl SegmentStorage for FileSegmentStorage { self.persister .delete(&segment.log_path) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to delete log file, path: {}", segment.log_path @@ -174,7 +174,7 @@ impl SegmentStorage for FileSegmentStorage { self.persister .delete(&segment.index_path) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to delete index file, path: {}", segment.index_path @@ -217,7 +217,7 @@ impl SegmentStorage for FileSegmentStorage { Ok(()) }) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to load batches by range, segment: {}, index range: {:?}", segment, index_range @@ -240,7 +240,7 @@ impl SegmentStorage for FileSegmentStorage { Ok(()) }) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to load messages by size, segment: {}, size bytes: {}", segment, size_bytes @@ -288,7 +288,7 @@ impl SegmentStorage for FileSegmentStorage { Ok(()) }) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to load batches by max range, segment: {segment}") })?; trace!("Loaded {} message IDs from disk.", message_ids.len()); @@ -316,7 +316,7 @@ impl SegmentStorage for FileSegmentStorage { Ok(()) }) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to load batches by max range, segment: {segment}") })?; Ok(()) @@ -326,7 +326,7 @@ impl SegmentStorage for FileSegmentStorage { trace!("Loading indexes from file..."); let file = file::open(&segment.index_path) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to open index file, path: {}", segment.index_path @@ -336,7 +336,7 @@ impl SegmentStorage for FileSegmentStorage { let file_size = file .metadata() .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to load index file metadata, path: {}", segment.index_path @@ -426,7 +426,7 @@ impl SegmentStorage for FileSegmentStorage { let file = file::open(&segment.index_path) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to open segment's index path, path: {}", segment.index_path @@ -436,7 +436,7 @@ impl SegmentStorage for FileSegmentStorage { let file_length = file .metadata() .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to load index's metadata, path: {}", segment.index_path @@ -466,17 +466,17 @@ impl SegmentStorage for FileSegmentStorage { let offset = reader .read_u32_le() .await - .with_error(|_| format!("{COMPONENT} - failed to load index's offset")) + .with_error_context(|_| format!("{COMPONENT} - failed to load index's offset")) .map_err(|_| IggyError::CannotReadIndexOffset)?; let position = reader .read_u32_le() .await - .with_error(|_| format!("{COMPONENT} - failed to load index's position")) + .with_error_context(|_| format!("{COMPONENT} - failed to load index's position")) .map_err(|_| IggyError::CannotReadIndexPosition)?; let timestamp = reader .read_u64_le() .await - .with_error(|_| format!("{COMPONENT} - failed to load index's timestamp")) + .with_error_context(|_| format!("{COMPONENT} - failed to load index's timestamp")) .map_err(|_| IggyError::CannotReadIndexTimestamp)?; read_bytes += INDEX_SIZE; let idx = Index { @@ -534,7 +534,7 @@ impl SegmentStorage for FileSegmentStorage { trace!("Loading time indexes from file..."); let file = file::open(&segment.index_path) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to open segment's index file, path: {}", segment.index_path @@ -544,7 +544,7 @@ impl SegmentStorage for FileSegmentStorage { let file_size = file .metadata() .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to load index's metadata, path: {}", segment.index_path @@ -629,7 +629,7 @@ async fn load_batches_by_range( reader .seek(SeekFrom::Start(index_range.start.position as u64)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to seek to position {}", index_range.start.position @@ -679,7 +679,7 @@ async fn load_batches_by_range( IggyByteSize::from(batch_length as u64), payload.freeze(), ); - on_batch(batch).with_error(|_| format!( + on_batch(batch).with_error_context(|_| format!( "{COMPONENT} - failed to process batch with base offset: {}, last offset delta: {}, max timestamp: {}, batch length: {}", batch_base_offset, last_offset_delta, max_timestamp, batch_length, ))?; diff --git a/server/src/streaming/streams/persistence.rs b/server/src/streaming/streams/persistence.rs index bf6b7b60b..e5d7a4853 100644 --- a/server/src/streaming/streams/persistence.rs +++ b/server/src/streaming/streams/persistence.rs @@ -1,7 +1,7 @@ use crate::state::system::StreamState; use crate::streaming::streams::stream::Stream; use crate::streaming::streams::COMPONENT; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; impl Stream { @@ -11,7 +11,7 @@ impl Stream { storage.stream .load(self, state) .await - .with_error(|_| format!("{COMPONENT} - failed to load stream with state, state ID: {state_id}, stream: {self}")) + .with_error_context(|_| format!("{COMPONENT} - failed to load stream with state, state ID: {state_id}, stream: {self}")) } pub async fn persist(&self) -> Result<(), IggyError> { @@ -19,12 +19,12 @@ impl Stream { .stream .save(self) .await - .with_error(|_| format!("{COMPONENT} - failed to persist stream: {self}")) + .with_error_context(|_| format!("{COMPONENT} - failed to persist stream: {self}")) } pub async fn delete(&self) -> Result<(), IggyError> { for topic in self.get_topics() { - topic.delete().await.with_error(|_| { + topic.delete().await.with_error_context(|_| { format!("{COMPONENT} - failed to delete topic in stream: {self}") })?; } @@ -33,13 +33,13 @@ impl Stream { .stream .delete(self) .await - .with_error(|_| format!("{COMPONENT} - failed to delete stream: {self}")) + .with_error_context(|_| format!("{COMPONENT} - failed to delete stream: {self}")) } pub async fn persist_messages(&self) -> Result { let mut saved_messages_number = 0; for topic in self.get_topics() { - saved_messages_number += topic.persist_messages().await.with_error(|_| { + saved_messages_number += topic.persist_messages().await.with_error_context(|_| { format!( "{COMPONENT} - failed to persist messages for topic: {topic} in stream: {self}" ) @@ -51,7 +51,7 @@ impl Stream { pub async fn purge(&self) -> Result<(), IggyError> { for topic in self.get_topics() { - topic.purge().await.with_error(|_| { + topic.purge().await.with_error_context(|_| { format!("{COMPONENT} - failed to purge topic: {topic} in stream: {self}") })?; } diff --git a/server/src/streaming/streams/storage.rs b/server/src/streaming/streams/storage.rs index 7baff8f7c..477309393 100644 --- a/server/src/streaming/streams/storage.rs +++ b/server/src/streaming/streams/storage.rs @@ -4,7 +4,7 @@ use crate::streaming::streams::stream::Stream; use crate::streaming::streams::COMPONENT; use crate::streaming::topics::topic::Topic; use async_trait::async_trait; -use error_set::ResultContext; +use error_set::ErrContext; use futures::future::join_all; use iggy::error::IggyError; use iggy::utils::timestamp::IggyTimestamp; @@ -116,10 +116,9 @@ impl StreamStorage for FileStreamStorage { stream.config.clone(), stream.storage.clone(), ); - topic - .persist() - .await - .with_error(|_| format!("{COMPONENT} - failed to persist topic: {topic}"))?; + topic.persist().await.with_error_context(|_| { + format!("{COMPONENT} - failed to persist topic: {topic}") + })?; unloaded_topics.push(topic); info!( "Created missing topic with ID: '{}', name: {}, for stream with ID: '{}'.", diff --git a/server/src/streaming/streams/topics.rs b/server/src/streaming/streams/topics.rs index d447a8497..671d4053b 100644 --- a/server/src/streaming/streams/topics.rs +++ b/server/src/streaming/streams/topics.rs @@ -1,7 +1,7 @@ use crate::streaming::streams::stream::Stream; use crate::streaming::streams::COMPONENT; use crate::streaming::topics::topic::Topic; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::compression::compression_algorithm::CompressionAlgorithm; use iggy::error::IggyError; use iggy::identifier::{IdKind, Identifier}; @@ -73,7 +73,7 @@ impl Stream { topic .persist() .await - .with_error(|_| format!("{COMPONENT} - failed to persist topic: {topic}"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to persist topic: {topic}"))?; info!("Created topic {}", topic); self.topics_ids.insert(name, id); self.topics.insert(id, topic); @@ -93,9 +93,9 @@ impl Stream { let max_topic_size = Topic::get_max_topic_size(max_topic_size, &self.config)?; let topic_id; { - let topic = self - .get_topic(id) - .with_error(|_| format!("{COMPONENT} - failed to get topic with id: {id}"))?; + let topic = self.get_topic(id).with_error_context(|_| { + format!("{COMPONENT} - failed to get topic with id: {id}") + })?; topic_id = topic.topic_id; } @@ -113,16 +113,16 @@ impl Stream { } let old_topic_name = { - let topic = self - .get_topic(id) - .with_error(|_| format!("{COMPONENT} - failed to get topic with id: {id}"))?; + let topic = self.get_topic(id).with_error_context(|_| { + format!("{COMPONENT} - failed to get topic with id: {id}") + })?; topic.name.clone() }; { self.topics_ids.remove(&old_topic_name.clone()); self.topics_ids.insert(updated_name.clone(), topic_id); - let topic = self.get_topic_mut(id).with_error(|_| { + let topic = self.get_topic_mut(id).with_error_context(|_| { format!("{COMPONENT} - failed to get mutable reference to topic with id {id}") })?; @@ -138,10 +138,9 @@ impl Stream { } topic.max_topic_size = max_topic_size; topic.replication_factor = replication_factor; - topic - .persist() - .await - .with_error(|_| format!("{COMPONENT} - failed to persist topic: {topic}"))?; + topic.persist().await.with_error_context(|_| { + format!("{COMPONENT} - failed to persist topic: {topic}") + })?; info!("Updated topic: {topic}"); } @@ -223,9 +222,9 @@ impl Stream { } pub async fn delete_topic(&mut self, id: &Identifier) -> Result { - let topic = self - .remove_topic(id) - .with_error(|_| format!("{COMPONENT} - failed to remove topic with id: {id}"))?; + let topic = self.remove_topic(id).with_error_context(|_| { + format!("{COMPONENT} - failed to remove topic with id: {id}") + })?; let topic_id = topic.topic_id; let current_topic_id = self.current_topic_id.load(Ordering::SeqCst); if current_topic_id > topic_id { @@ -235,7 +234,7 @@ impl Stream { topic .delete() .await - .with_error(|_| format!("{COMPONENT} - failed to delete topic: {topic}")) + .with_error_context(|_| format!("{COMPONENT} - failed to delete topic: {topic}")) .map_err(|_| IggyError::CannotDeleteTopic(topic.topic_id, self.stream_id))?; Ok(topic) } diff --git a/server/src/streaming/systems/clients.rs b/server/src/streaming/systems/clients.rs index f007471ac..6809bd407 100644 --- a/server/src/streaming/systems/clients.rs +++ b/server/src/streaming/systems/clients.rs @@ -2,7 +2,7 @@ use crate::streaming::clients::client_manager::{Client, Transport}; use crate::streaming::session::Session; use crate::streaming::systems::system::System; use crate::streaming::systems::COMPONENT; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::identifier::Identifier; use iggy::locking::IggySharedMut; @@ -67,7 +67,7 @@ impl System { self.ensure_authenticated(session)?; self.permissioner .get_client(session.get_user_id()) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get client by user ID: {}", session.get_user_id() @@ -77,7 +77,9 @@ impl System { let client_manager = self.client_manager.read().await; client_manager .get_client(client_id) - .with_error(|_| format!("{COMPONENT} - failed to get client with ID {}", client_id)) + .with_error_context(|_| { + format!("{COMPONENT} - failed to get client with ID {}", client_id) + }) } pub async fn get_clients( @@ -87,7 +89,7 @@ impl System { self.ensure_authenticated(session)?; self.permissioner .get_clients(session.get_user_id()) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get clients by user ID {}", session.get_user_id() diff --git a/server/src/streaming/systems/consumer_groups.rs b/server/src/streaming/systems/consumer_groups.rs index 954ea0c4d..4e72d9172 100644 --- a/server/src/streaming/systems/consumer_groups.rs +++ b/server/src/streaming/systems/consumer_groups.rs @@ -2,7 +2,7 @@ use crate::streaming::session::Session; use crate::streaming::systems::system::System; use crate::streaming::systems::COMPONENT; use crate::streaming::topics::consumer_group::ConsumerGroup; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::identifier::Identifier; use iggy::locking::IggySharedMutFn; @@ -18,11 +18,11 @@ impl System { ) -> Result<&RwLock, IggyError> { self.ensure_authenticated(session)?; let topic = self.find_topic(session, stream_id, topic_id) - .with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + .with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; self.permissioner .get_consumer_group(session.get_user_id(), topic.stream_id, topic.topic_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to get consumer group for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), @@ -31,7 +31,7 @@ impl System { ) })?; - topic.get_consumer_group(group_id).with_error(|_| { + topic.get_consumer_group(group_id).with_error_context(|_| { format!("{COMPONENT} - consumer group not found for group_id: {group_id}") }) } @@ -44,11 +44,11 @@ impl System { ) -> Result>, IggyError> { self.ensure_authenticated(session)?; let topic = self.find_topic(session, stream_id, topic_id) - .with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + .with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; self.permissioner .get_consumer_groups(session.get_user_id(), topic.stream_id, topic.topic_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to get consumer groups for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), @@ -71,23 +71,23 @@ impl System { self.ensure_authenticated(session)?; { let topic = self.find_topic(session, stream_id, topic_id) - .with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + .with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; self.permissioner.create_consumer_group( session.get_user_id(), topic.stream_id, topic.topic_id, - ).with_error(|_| format!("{COMPONENT} - permission denied to create consumer group for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, topic.topic_id))?; + ).with_error_context(|_| format!("{COMPONENT} - permission denied to create consumer group for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, topic.topic_id))?; } let topic = self.get_stream_mut(stream_id)? .get_topic_mut(topic_id) - .with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + .with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; topic .create_consumer_group(group_id, name) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to create consumer group with name: {name}") }) } @@ -104,13 +104,13 @@ impl System { let topic_id_value; { let topic = self.find_topic(session, stream_id, topic_id) - .with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + .with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; self.permissioner.delete_consumer_group( session.get_user_id(), topic.stream_id, topic.topic_id, - ).with_error(|_| format!("{COMPONENT} - permission denied to delete consumer group for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, topic.topic_id))?; + ).with_error_context(|_| format!("{COMPONENT} - permission denied to delete consumer group for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, topic.topic_id))?; stream_id_value = topic.stream_id; topic_id_value = topic.topic_id; @@ -118,16 +118,16 @@ impl System { let consumer_group; { - let stream = self.get_stream_mut(stream_id).with_error(|_| { + let stream = self.get_stream_mut(stream_id).with_error_context(|_| { format!( "{COMPONENT} - failed to get mutable reference to stream with id: {stream_id}" ) })?; - let topic = stream.get_topic_mut(topic_id).with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + let topic = stream.get_topic_mut(topic_id).with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; consumer_group = topic.delete_consumer_group(consumer_group_id) .await - .with_error(|_| format!("{COMPONENT} - failed to delete consumer group for consumer_group_id: {consumer_group_id}"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to delete consumer group for consumer_group_id: {consumer_group_id}"))?; } let client_manager = self.client_manager.read().await; @@ -142,7 +142,7 @@ impl System { consumer_group.group_id, ) .await - .with_error(|_| format!("{COMPONENT} - failed to make client leave consumer group for client_id: {}, group_id: {}", member.id, consumer_group.group_id))?; + .with_error_context(|_| format!("{COMPONENT} - failed to make client leave consumer group for client_id: {}, group_id: {}", member.id, consumer_group.group_id))?; } Ok(()) @@ -161,7 +161,7 @@ impl System { { let topic = self .find_topic(session, stream_id, topic_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}", ) @@ -171,7 +171,7 @@ impl System { session.get_user_id(), topic.stream_id, topic.topic_id, - ).with_error(|_| format!("{COMPONENT} - permission denied to join consumer group for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, topic.topic_id))?; + ).with_error_context(|_| format!("{COMPONENT} - permission denied to join consumer group for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, topic.topic_id))?; stream_id_value = topic.stream_id; topic_id_value = topic.topic_id; @@ -182,15 +182,14 @@ impl System { let topic = self.find_topic(session, stream_id, topic_id)?; { - let consumer_group = - topic - .get_consumer_group(consumer_group_id) - .with_error(|_| { - format!( - "{COMPONENT} - consumer group not found for group_id: {:?}", - consumer_group_id - ) - })?; + let consumer_group = topic + .get_consumer_group(consumer_group_id) + .with_error_context(|_| { + format!( + "{COMPONENT} - consumer group not found for group_id: {:?}", + consumer_group_id + ) + })?; let consumer_group = consumer_group.read().await; group_id = consumer_group.group_id; @@ -199,7 +198,7 @@ impl System { topic .join_consumer_group(consumer_group_id, session.client_id) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to join consumer group for group_id: {}", group_id @@ -211,7 +210,7 @@ impl System { client_manager .join_consumer_group(session.client_id, stream_id_value, topic_id_value, group_id) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to make client join consumer group for client_id: {}", session.client_id @@ -232,7 +231,7 @@ impl System { { let topic = self .find_topic(session, stream_id, topic_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - topic not found for stream_id: {:?}, topic_id: {:?}", stream_id, topic_id @@ -243,7 +242,7 @@ impl System { session.get_user_id(), topic.stream_id, topic.topic_id, - ).with_error(|_| format!("{COMPONENT} - permission denied to leave consumer group for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, topic.topic_id))?; + ).with_error_context(|_| format!("{COMPONENT} - permission denied to leave consumer group for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, topic.topic_id))?; } self.leave_consumer_group_by_client( @@ -253,7 +252,7 @@ impl System { session.client_id, ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to leave consumer group for client_id: {}", session.client_id @@ -273,24 +272,23 @@ impl System { let group_id; { - let stream = self.get_stream(stream_id).with_error(|_| { + let stream = self.get_stream(stream_id).with_error_context(|_| { format!("{COMPONENT} - failed to get stream with id: {stream_id}") })?; let topic = stream.get_topic(topic_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}", ) })?; { - let consumer_group = - topic - .get_consumer_group(consumer_group_id) - .with_error(|_| { - format!( + let consumer_group = topic + .get_consumer_group(consumer_group_id) + .with_error_context(|_| { + format!( "{COMPONENT} - consumer group not found for group_id: {consumer_group_id}", ) - })?; + })?; let consumer_group = consumer_group.read().await; group_id = consumer_group.group_id; } @@ -300,7 +298,7 @@ impl System { topic .leave_consumer_group(consumer_group_id, client_id) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed leave consumer group, client ID {client_id}",) })?; } diff --git a/server/src/streaming/systems/consumer_offsets.rs b/server/src/streaming/systems/consumer_offsets.rs index 1524dc807..76b38b5cf 100644 --- a/server/src/streaming/systems/consumer_offsets.rs +++ b/server/src/streaming/systems/consumer_offsets.rs @@ -1,7 +1,7 @@ use crate::streaming::session::Session; use crate::streaming::systems::system::System; use crate::streaming::systems::COMPONENT; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer::Consumer; use iggy::error::IggyError; use iggy::identifier::Identifier; @@ -18,7 +18,7 @@ impl System { offset: u64, ) -> Result<(), IggyError> { self.ensure_authenticated(session)?; - let topic = self.find_topic(session, stream_id, topic_id).with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + let topic = self.find_topic(session, stream_id, topic_id).with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; self.permissioner.store_consumer_offset( session.get_user_id(), topic.stream_id, @@ -39,12 +39,12 @@ impl System { partition_id: Option, ) -> Result { self.ensure_authenticated(session)?; - let topic = self.find_topic(session, stream_id, topic_id).with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + let topic = self.find_topic(session, stream_id, topic_id).with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; self.permissioner.get_consumer_offset( session.get_user_id(), topic.stream_id, topic.topic_id, - ).with_error(|_| { + ).with_error_context(|_| { format!( "{COMPONENT} - permission denied to get consumer group for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), diff --git a/server/src/streaming/systems/messages.rs b/server/src/streaming/systems/messages.rs index 58e7e409e..4638ef115 100644 --- a/server/src/streaming/systems/messages.rs +++ b/server/src/streaming/systems/messages.rs @@ -3,7 +3,7 @@ use crate::streaming::session::Session; use crate::streaming::systems::system::System; use crate::streaming::systems::COMPONENT; use bytes::Bytes; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer::Consumer; use iggy::messages::poll_messages::PollingStrategy; use iggy::messages::send_messages::Message; @@ -29,10 +29,10 @@ impl System { return Err(IggyError::InvalidMessagesCount); } - let topic = self.find_topic(session, stream_id, topic_id).with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + let topic = self.find_topic(session, stream_id, topic_id).with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; self.permissioner .poll_messages(session.get_user_id(), topic.stream_id, topic.topic_id) - .with_error(|_| format!( + .with_error_context(|_| format!( "{COMPONENT} - permission denied to poll messages for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, @@ -46,7 +46,7 @@ impl System { let (polling_consumer, partition_id) = topic .resolve_consumer_with_partition_id(consumer, session.client_id, partition_id, true) .await - .with_error(|_| format!("{COMPONENT} - failed to resolve consumer with partition id, consumer: {consumer}, client ID: {}, partition ID: {:?}", session.client_id, partition_id))?; + .with_error_context(|_| format!("{COMPONENT} - failed to resolve consumer with partition id, consumer: {consumer}, client ID: {}, partition ID: {:?}", session.client_id, partition_id))?; let mut polled_messages = topic .get_messages(polling_consumer, partition_id, args.strategy, args.count) @@ -62,7 +62,7 @@ impl System { topic .store_consumer_offset_internal(polling_consumer, offset, partition_id) .await - .with_error(|_| format!("{COMPONENT} - failed to store consumer offset internal, polling consumer: {}, offset: {}, partition ID: {}", polling_consumer, offset, partition_id)) ?; + .with_error_context(|_| format!("{COMPONENT} - failed to store consumer offset internal, polling consumer: {}, offset: {}, partition ID: {}", polling_consumer, offset, partition_id)) ?; } if self.encryptor.is_none() { @@ -105,12 +105,12 @@ impl System { messages: Vec, ) -> Result<(), IggyError> { self.ensure_authenticated(session)?; - let topic = self.find_topic(session, &stream_id, &topic_id).with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + let topic = self.find_topic(session, &stream_id, &topic_id).with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; self.permissioner.append_messages( session.get_user_id(), topic.stream_id, topic.topic_id, - ).with_error(|_| format!( + ).with_error_context(|_| format!( "{COMPONENT} - permission denied to append messages for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, @@ -163,13 +163,13 @@ impl System { fsync: bool, ) -> Result<(), IggyError> { self.ensure_authenticated(session)?; - let topic = self.find_topic(session, &stream_id, &topic_id).with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + let topic = self.find_topic(session, &stream_id, &topic_id).with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; // Reuse those permissions as if you can append messages you can flush them self.permissioner.append_messages( session.get_user_id(), topic.stream_id, topic.topic_id, - ).with_error(|_| format!( + ).with_error_context(|_| format!( "{COMPONENT} - permission denied to append messages for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, diff --git a/server/src/streaming/systems/partitions.rs b/server/src/streaming/systems/partitions.rs index 6cef81049..7d2e3eb04 100644 --- a/server/src/streaming/systems/partitions.rs +++ b/server/src/streaming/systems/partitions.rs @@ -1,7 +1,7 @@ use crate::streaming::session::Session; use crate::streaming::systems::system::System; use crate::streaming::systems::COMPONENT; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::identifier::Identifier; @@ -15,12 +15,12 @@ impl System { ) -> Result<(), IggyError> { self.ensure_authenticated(session)?; { - let topic = self.find_topic(session, stream_id, topic_id).with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + let topic = self.find_topic(session, stream_id, topic_id).with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; self.permissioner.create_partitions( session.get_user_id(), topic.stream_id, topic.topic_id, - ).with_error(|_| format!( + ).with_error_context(|_| format!( "{COMPONENT} - permission denied to create partitions for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, @@ -31,7 +31,7 @@ impl System { let topic = self .get_stream_mut(stream_id)? .get_topic_mut(topic_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get mutable reference to stream with id: {stream_id}" ) @@ -39,7 +39,7 @@ impl System { topic .add_persisted_partitions(partitions_count) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to add persisted partitions, topic: {topic}") })?; topic.reassign_consumer_groups().await; @@ -57,12 +57,12 @@ impl System { ) -> Result<(), IggyError> { self.ensure_authenticated(session)?; { - let topic = self.find_topic(session, stream_id, topic_id).with_error(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; + let topic = self.find_topic(session, stream_id, topic_id).with_error_context(|_| format!("{COMPONENT} - topic not found for stream_id: {stream_id}, topic_id: {topic_id}"))?; self.permissioner.delete_partitions( session.get_user_id(), topic.stream_id, topic.topic_id, - ).with_error(|_| format!( + ).with_error_context(|_| format!( "{COMPONENT} - permission denied to delete partitions for user {} on stream_id: {}, topic_id: {}", session.get_user_id(), topic.stream_id, @@ -73,7 +73,7 @@ impl System { let topic = self .get_stream_mut(stream_id)? .get_topic_mut(topic_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get mutable reference to stream with id: {stream_id}" ) @@ -81,7 +81,7 @@ impl System { let partitions = topic .delete_persisted_partitions(partitions_count) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to delete persisted partitions, topic: {topic}") })?; topic.reassign_consumer_groups().await; diff --git a/server/src/streaming/systems/personal_access_tokens.rs b/server/src/streaming/systems/personal_access_tokens.rs index 3800f0f47..f34ff0382 100644 --- a/server/src/streaming/systems/personal_access_tokens.rs +++ b/server/src/streaming/systems/personal_access_tokens.rs @@ -3,7 +3,7 @@ use crate::streaming::session::Session; use crate::streaming::systems::system::System; use crate::streaming::systems::COMPONENT; use crate::streaming::users::user::User; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::utils::expiry::IggyExpiry; use iggy::utils::text; @@ -19,7 +19,9 @@ impl System { let user_id = session.get_user_id(); let user = self .get_user(&user_id.try_into()?) - .with_error(|_| format!("{COMPONENT} - failed to get user with id: {user_id}"))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to get user with id: {user_id}") + })?; info!("Loading personal access tokens for user with ID: {user_id}...",); let personal_access_tokens: Vec<_> = user.personal_access_tokens.values().collect(); info!( @@ -39,9 +41,9 @@ impl System { let user_id = session.get_user_id(); let identifier = user_id.try_into()?; { - let user = self - .get_user(&identifier) - .with_error(|_| format!("{COMPONENT} - failed to get user with id: {user_id}"))?; + let user = self.get_user(&identifier).with_error_context(|_| { + format!("{COMPONENT} - failed to get user with id: {user_id}") + })?; let max_token_per_user = self.personal_access_token.max_tokens_per_user; if user.personal_access_tokens.len() as u32 >= max_token_per_user { error!( @@ -54,7 +56,7 @@ impl System { } } - let user = self.get_user_mut(&identifier).with_error(|_| { + let user = self.get_user_mut(&identifier).with_error_context(|_| { format!("{COMPONENT} - failed to get mutable reference to the user with id: {user_id}") })?; let name = text::to_lowercase_non_whitespace(name); @@ -83,9 +85,13 @@ impl System { ) -> Result<(), IggyError> { self.ensure_authenticated(session)?; let user_id = session.get_user_id(); - let user = self.get_user_mut(&user_id.try_into()?).with_error(|_| { - format!("{COMPONENT} - failed to get mutable reference to the user with id: {user_id}") - })?; + let user = self + .get_user_mut(&user_id.try_into()?) + .with_error_context(|_| { + format!( + "{COMPONENT} - failed to get mutable reference to the user with id: {user_id}" + ) + })?; let name = text::to_lowercase_non_whitespace(name); let token; @@ -141,7 +147,7 @@ impl System { let user = self .get_user(&personal_access_token.user_id.try_into()?) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get user with id: {}", personal_access_token.user_id diff --git a/server/src/streaming/systems/storage.rs b/server/src/streaming/systems/storage.rs index 32982ebf7..0efc1863e 100644 --- a/server/src/streaming/systems/storage.rs +++ b/server/src/streaming/systems/storage.rs @@ -6,7 +6,7 @@ use crate::streaming::utils::file; use anyhow::Context; use async_trait::async_trait; use bytes::{BufMut, BytesMut}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use std::sync::Arc; use tokio::io::AsyncReadExt; @@ -38,7 +38,7 @@ impl SystemInfoStorage for FileSystemInfoStorage { let file_size = file .metadata() .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to retrieve metadata for file at path: {}", self.path @@ -50,7 +50,7 @@ impl SystemInfoStorage for FileSystemInfoStorage { buffer.put_bytes(0, file_size); file.read_exact(&mut buffer) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to read file content from path: {}", self.path @@ -69,7 +69,7 @@ impl SystemInfoStorage for FileSystemInfoStorage { self.persister .overwrite(&self.path, &data) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to overwrite file at path: {}", self.path diff --git a/server/src/streaming/systems/streams.rs b/server/src/streaming/systems/streams.rs index 8a39de8c1..6cc238676 100644 --- a/server/src/streaming/systems/streams.rs +++ b/server/src/streaming/systems/streams.rs @@ -3,7 +3,7 @@ use crate::streaming::session::Session; use crate::streaming::streams::stream::Stream; use crate::streaming::systems::system::System; use crate::streaming::systems::COMPONENT; -use error_set::ResultContext; +use error_set::ErrContext; use futures::future::try_join_all; use iggy::error::IggyError; use iggy::identifier::{IdKind, Identifier}; @@ -150,7 +150,7 @@ impl System { self.ensure_authenticated(session)?; self.permissioner .get_streams(session.get_user_id()) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to get streams for user {}", session.get_user_id(), @@ -169,7 +169,7 @@ impl System { if let Ok(stream) = stream { self.permissioner .get_stream(session.get_user_id(), stream.stream_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to get stream for user {}", session.get_user_id(), @@ -288,15 +288,15 @@ impl System { self.ensure_authenticated(session)?; let stream_id; { - let stream = self - .get_stream(id) - .with_error(|_| format!("{COMPONENT} - failed to get stream with id: {id}"))?; + let stream = self.get_stream(id).with_error_context(|_| { + format!("{COMPONENT} - failed to get stream with id: {id}") + })?; stream_id = stream.stream_id; } self.permissioner .update_stream(session.get_user_id(), stream_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to update stream, user ID: {}, stream ID: {}", session.get_user_id(), @@ -315,7 +315,7 @@ impl System { let old_name; { - let stream = self.get_stream_mut(id).with_error(|_| { + let stream = self.get_stream_mut(id).with_error_context(|_| { format!("{COMPONENT} - failed to get mutable reference to stream with id: {id}") })?; old_name = stream.name.clone(); @@ -343,11 +343,11 @@ impl System { self.ensure_authenticated(session)?; let stream = self .get_stream(id) - .with_error(|_| format!("{COMPONENT} - failed to get stream with id: {id}"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to get stream with id: {id}"))?; let stream_id = stream.stream_id; self.permissioner .delete_stream(session.get_user_id(), stream_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to delete stream for user {}, stream ID: {}", session.get_user_id(), @@ -384,12 +384,12 @@ impl System { session: &Session, stream_id: &Identifier, ) -> Result<(), IggyError> { - let stream = self - .get_stream(stream_id) - .with_error(|_| format!("{COMPONENT} - failed to get stream with id: {stream_id}"))?; + let stream = self.get_stream(stream_id).with_error_context(|_| { + format!("{COMPONENT} - failed to get stream with id: {stream_id}") + })?; self.permissioner .purge_stream(session.get_user_id(), stream.stream_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to purge stream for user {}, stream ID: {}", session.get_user_id(), diff --git a/server/src/streaming/systems/system.rs b/server/src/streaming/systems/system.rs index b0e9d3e46..4f4086fb7 100644 --- a/server/src/streaming/systems/system.rs +++ b/server/src/streaming/systems/system.rs @@ -9,7 +9,7 @@ use crate::streaming::storage::SystemStorage; use crate::streaming::streams::stream::Stream; use crate::streaming::systems::COMPONENT; use crate::streaming::users::permissioner::Permissioner; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::utils::byte_size::IggyByteSize; use iggy::utils::crypto::{Aes256GcmEncryptor, Encryptor}; @@ -208,24 +208,23 @@ impl System { self.config.get_system_path() ); - let state_entries = self - .state - .init() - .await - .with_error(|_| format!("{COMPONENT} - failed to initialize state entries"))?; + let state_entries = + self.state.init().await.with_error_context(|_| { + format!("{COMPONENT} - failed to initialize state entries") + })?; let system_state = SystemState::init(state_entries) .await - .with_error(|_| format!("{COMPONENT} - failed to initialize system state"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to initialize system state"))?; let now = Instant::now(); self.load_version() .await - .with_error(|_| format!("{COMPONENT} - failed to load version"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to load version"))?; self.load_users(system_state.users.into_values().collect()) .await - .with_error(|_| format!("{COMPONENT} - failed to load users"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to load users"))?; self.load_streams(system_state.streams.into_values().collect()) .await - .with_error(|_| format!("{COMPONENT} - failed to load streams"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to load streams"))?; if let Some(archiver) = self.archiver.as_ref() { archiver .init() diff --git a/server/src/streaming/systems/topics.rs b/server/src/streaming/systems/topics.rs index 4710bcbd4..04082fee0 100644 --- a/server/src/streaming/systems/topics.rs +++ b/server/src/streaming/systems/topics.rs @@ -2,7 +2,7 @@ use crate::streaming::session::Session; use crate::streaming::systems::system::System; use crate::streaming::systems::COMPONENT; use crate::streaming::topics::topic::Topic; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::compression::compression_algorithm::CompressionAlgorithm; use iggy::error::IggyError; use iggy::identifier::Identifier; @@ -20,12 +20,14 @@ impl System { self.ensure_authenticated(session)?; let stream = self .find_stream(session, stream_id) - .with_error(|_| format!("{COMPONENT} - failed to find stream with id: {stream_id}"))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to find stream with id: {stream_id}") + })?; let topic = stream.get_topic(topic_id); if let Ok(topic) = topic { self.permissioner .get_topic(session.get_user_id(), stream.stream_id, topic.topic_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to get topic for user with id: {}, stream ID: {}, topic ID: {}", session.get_user_id(), @@ -45,12 +47,12 @@ impl System { stream_id: &Identifier, ) -> Result, IggyError> { self.ensure_authenticated(session)?; - let stream = self - .get_stream(stream_id) - .with_error(|_| format!("{COMPONENT} - failed to get stream with id: {stream_id}"))?; + let stream = self.get_stream(stream_id).with_error_context(|_| { + format!("{COMPONENT} - failed to get stream with id: {stream_id}") + })?; self.permissioner .get_topics(session.get_user_id(), stream.stream_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to get topics for user with id: {}, stream ID: {}", session.get_user_id(), @@ -75,12 +77,12 @@ impl System { ) -> Result<&Topic, IggyError> { self.ensure_authenticated(session)?; { - let stream = self.get_stream(stream_id).with_error(|_| { + let stream = self.get_stream(stream_id).with_error_context(|_| { format!("{COMPONENT} - failed to get stream with id: {stream_id}") })?; self.permissioner .create_topic(session.get_user_id(), stream.stream_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to create topic for user with id: {}, stream ID: {}", session.get_user_id(), @@ -101,7 +103,7 @@ impl System { replication_factor.unwrap_or(1), ) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to create topic, stream ID: {stream_id}") })?; @@ -110,9 +112,11 @@ impl System { self.metrics.increment_segments(partitions_count); self.get_stream(stream_id) - .with_error(|_| format!("{COMPONENT} - failed to get stream with id: {stream_id}"))? + .with_error_context(|_| { + format!("{COMPONENT} - failed to get stream with id: {stream_id}") + })? .get_topic(&created_topic_id.try_into()?) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get topic with id: {}", created_topic_id @@ -136,14 +140,14 @@ impl System { { let topic = self .find_topic(session, stream_id, topic_id) - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to find topic with id: {topic_id}") })?; self.permissioner.update_topic( session.get_user_id(), topic.stream_id, topic.topic_id, - ).with_error(|_| { + ).with_error_context(|_| { format!( "{COMPONENT} - permission denied to update topic for user with id: {}, stream ID: {}, topic ID: {}", session.get_user_id(), @@ -163,7 +167,7 @@ impl System { replication_factor.unwrap_or(1), ) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to update topic, stream ID: {}, topic ID: {}", stream_id, topic_id @@ -174,9 +178,13 @@ impl System { // TODO: if max_size_bytes is changed, we need to check if we need to purge messages based on the new size // TODO: if replication_factor is changed, we need to do `something` self.get_stream(stream_id) - .with_error(|_| format!("{COMPONENT} - failed to get stream with id: {stream_id}"))? + .with_error_context(|_| { + format!("{COMPONENT} - failed to get stream with id: {stream_id}") + })? .get_topic(topic_id) - .with_error(|_| format!("{COMPONENT} - failed to get topic with id: {topic_id}")) + .with_error_context(|_| { + format!("{COMPONENT} - failed to get topic with id: {topic_id}") + }) } pub async fn delete_topic( @@ -190,14 +198,14 @@ impl System { { let topic = self .find_topic(session, stream_id, topic_id) - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to find topic with id: {topic_id}") })?; self.permissioner.delete_topic( session.get_user_id(), topic.stream_id, topic.topic_id, - ).with_error(|_| { + ).with_error_context(|_| { format!( "{COMPONENT} - permission denied to delete topic for user with id: {}, stream ID: {}, topic ID: {}", session.get_user_id(), @@ -212,7 +220,7 @@ impl System { .get_stream_mut(stream_id)? .delete_topic(topic_id) .await - .with_error(|_| format!("{COMPONENT} - failed to delete topic, stream ID: {stream_id}, topic ID: {topic_id}"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to delete topic, stream ID: {stream_id}, topic ID: {topic_id}"))?; self.metrics.decrement_topics(1); self.metrics @@ -235,10 +243,12 @@ impl System { ) -> Result<(), IggyError> { let topic = self .find_topic(session, stream_id, topic_id) - .with_error(|_| format!("{COMPONENT} - failed to find topic with id: {topic_id}"))?; + .with_error_context(|_| { + format!("{COMPONENT} - failed to find topic with id: {topic_id}") + })?; self.permissioner .purge_topic(session.get_user_id(), topic.stream_id, topic.topic_id) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to purge topic for user with id: {}, stream ID: {}, topic ID: {}", session.get_user_id(), @@ -246,9 +256,8 @@ impl System { topic.topic_id, ) })?; - topic - .purge() - .await - .with_error(|_| format!("{COMPONENT} - failed to purge topic with id: {topic_id}")) + topic.purge().await.with_error_context(|_| { + format!("{COMPONENT} - failed to purge topic with id: {topic_id}") + }) } } diff --git a/server/src/streaming/systems/users.rs b/server/src/streaming/systems/users.rs index c4942f473..d582e67de 100644 --- a/server/src/streaming/systems/users.rs +++ b/server/src/streaming/systems/users.rs @@ -7,7 +7,7 @@ use crate::streaming::systems::COMPONENT; use crate::streaming::users::user::User; use crate::streaming::utils::crypto; use crate::{IGGY_ROOT_PASSWORD_ENV, IGGY_ROOT_USERNAME_ENV}; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::identifier::{IdKind, Identifier}; use iggy::locking::IggySharedMutFn; @@ -38,7 +38,7 @@ impl System { self.state .apply(0, EntryCommand::CreateUser(command)) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to apply create user command, username: {}", root.username @@ -125,7 +125,7 @@ impl System { if let Ok(user) = user { let session_user_id = session.get_user_id(); if user.id != session_user_id { - self.permissioner.get_user(session_user_id).with_error(|_| { + self.permissioner.get_user(session_user_id).with_error_context(|_| { format!( "{COMPONENT} - permission denied to get user for user with id: {session_user_id}" ) @@ -176,7 +176,7 @@ impl System { self.ensure_authenticated(session)?; self.permissioner .get_users(session.get_user_id()) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to get users for user with id: {}", session.get_user_id() @@ -196,7 +196,7 @@ impl System { self.ensure_authenticated(session)?; self.permissioner .create_user(session.get_user_id()) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to create user for user with id: {}", session.get_user_id() @@ -222,7 +222,7 @@ impl System { info!("Created user: {username} with ID: {user_id}."); self.metrics.increment_users(1); self.get_user(&user_id.try_into()?) - .with_error(|_| format!("{COMPONENT} - failed to get user with id: {user_id}")) + .with_error_context(|_| format!("{COMPONENT} - failed to get user with id: {user_id}")) } pub async fn delete_user( @@ -236,15 +236,15 @@ impl System { { self.permissioner .delete_user(session.get_user_id()) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to delete user for user with id: {}", session.get_user_id() ) })?; - let user = self - .get_user(user_id) - .with_error(|_| format!("{COMPONENT} - failed to get user with id: {user_id}"))?; + let user = self.get_user(user_id).with_error_context(|_| { + format!("{COMPONENT} - failed to get user with id: {user_id}") + })?; if user.is_root() { error!("Cannot delete the root user."); return Err(IggyError::CannotDeleteUser(user.id)); @@ -265,7 +265,7 @@ impl System { client_manager .delete_clients_for_user(existing_user_id) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to delete clients for user with id: {existing_user_id}" ) @@ -285,7 +285,7 @@ impl System { self.ensure_authenticated(session)?; self.permissioner .update_user(session.get_user_id()) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to update user for user with id: {}", session.get_user_id() @@ -302,7 +302,7 @@ impl System { } } - let user = self.get_user_mut(user_id).with_error(|_| { + let user = self.get_user_mut(user_id).with_error_context(|_| { format!("{COMPONENT} - failed to get mutable reference to the user with id: {user_id}") })?; if let Some(username) = username { @@ -328,14 +328,14 @@ impl System { { self.permissioner .update_permissions(session.get_user_id()) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - permission denied to update permissions for user with id: {}", session.get_user_id() ) })?; - let user = self - .get_user(user_id) - .with_error(|_| format!("{COMPONENT} - failed to get user with id: {user_id}"))?; + let user = self.get_user(user_id).with_error_context(|_| { + format!("{COMPONENT} - failed to get user with id: {user_id}") + })?; if user.is_root() { error!("Cannot change the root user permissions."); return Err(IggyError::CannotChangePermissions(user.id)); @@ -346,7 +346,7 @@ impl System { } { - let user = self.get_user_mut(user_id).with_error(|_| { + let user = self.get_user_mut(user_id).with_error_context(|_| { format!( "{COMPONENT} - failed to get mutable reference to the user with id: {user_id}" ) @@ -371,16 +371,16 @@ impl System { self.ensure_authenticated(session)?; { - let user = self - .get_user(user_id) - .with_error(|_| format!("{COMPONENT} - failed to get user with id: {user_id}"))?; + let user = self.get_user(user_id).with_error_context(|_| { + format!("{COMPONENT} - failed to get user with id: {user_id}") + })?; let session_user_id = session.get_user_id(); if user.id != session_user_id { self.permissioner.change_password(session_user_id)?; } } - let user = self.get_user_mut(user_id).with_error(|_| { + let user = self.get_user_mut(user_id).with_error_context(|_| { format!("{COMPONENT} - failed to get mutable reference to the user with id: {user_id}") })?; if !crypto::verify_password(current_password, &user.password) { @@ -459,7 +459,7 @@ impl System { client_manager .set_user_id(session.client_id, user.id) .await - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to set user_id to client, client ID: {}, user ID: {}", session.client_id, user.id @@ -472,7 +472,7 @@ impl System { self.ensure_authenticated(session)?; let user = self .get_user(&Identifier::numeric(session.get_user_id())?) - .with_error(|_| { + .with_error_context(|_| { format!( "{COMPONENT} - failed to get user with id: {}", session.get_user_id() diff --git a/server/src/streaming/topics/consumer_groups.rs b/server/src/streaming/topics/consumer_groups.rs index 25716637a..a3f79c236 100644 --- a/server/src/streaming/topics/consumer_groups.rs +++ b/server/src/streaming/topics/consumer_groups.rs @@ -1,7 +1,7 @@ use crate::streaming::topics::consumer_group::ConsumerGroup; use crate::streaming::topics::topic::Topic; use crate::streaming::topics::COMPONENT; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::identifier::{IdKind, Identifier}; use iggy::locking::IggySharedMutFn; @@ -120,7 +120,7 @@ impl Topic { ) -> Result, IggyError> { let group_id; { - let consumer_group = self.get_consumer_group(id).with_error(|_| { + let consumer_group = self.get_consumer_group(id).with_error_context(|_| { format!("{COMPONENT} - failed to get consumer group with id: {id}") })?; let consumer_group = consumer_group.read().await; @@ -166,7 +166,7 @@ impl Topic { group_id: &Identifier, member_id: u32, ) -> Result<(), IggyError> { - let consumer_group = self.get_consumer_group(group_id).with_error(|_| { + let consumer_group = self.get_consumer_group(group_id).with_error_context(|_| { format!("{COMPONENT} - failed to get consumer group with id: {group_id}") })?; let mut consumer_group = consumer_group.write().await; @@ -183,7 +183,7 @@ impl Topic { group_id: &Identifier, member_id: u32, ) -> Result<(), IggyError> { - let consumer_group = self.get_consumer_group(group_id).with_error(|_| { + let consumer_group = self.get_consumer_group(group_id).with_error_context(|_| { format!("{COMPONENT} - failed to get consumer group with id: {group_id}") })?; let mut consumer_group = consumer_group.write().await; diff --git a/server/src/streaming/topics/consumer_offsets.rs b/server/src/streaming/topics/consumer_offsets.rs index ccc771c3b..825bb64db 100644 --- a/server/src/streaming/topics/consumer_offsets.rs +++ b/server/src/streaming/topics/consumer_offsets.rs @@ -1,7 +1,7 @@ use crate::streaming::polling_consumer::PollingConsumer; use crate::streaming::topics::topic::Topic; use crate::streaming::topics::COMPONENT; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::consumer::Consumer; use iggy::error::IggyError; use iggy::locking::IggySharedMutFn; @@ -18,15 +18,15 @@ impl Topic { let (polling_consumer, partition_id) = self .resolve_consumer_with_partition_id(&consumer, client_id, partition_id, false) .await - .with_error(|_| format!("{COMPONENT} - failed to resolve consumer with partition id, consumer ID: {}, client ID: {}, partition ID: {:?}", consumer.id, client_id, partition_id))?; - let partition = self.get_partition(partition_id).with_error(|_| { + .with_error_context(|_| format!("{COMPONENT} - failed to resolve consumer with partition id, consumer ID: {}, client ID: {}, partition ID: {:?}", consumer.id, client_id, partition_id))?; + let partition = self.get_partition(partition_id).with_error_context(|_| { format!("{COMPONENT} - failed to get partiton with id: {partition_id}") })?; let partition = partition.read().await; partition .store_consumer_offset(polling_consumer, offset) .await - .with_error(|_| format!("{COMPONENT} - failed to store consumer offset, consumer: {polling_consumer}, offset: {offset}")) + .with_error_context(|_| format!("{COMPONENT} - failed to store consumer offset, consumer: {polling_consumer}, offset: {offset}")) } pub async fn store_consumer_offset_internal( @@ -35,11 +35,11 @@ impl Topic { offset: u64, partition_id: u32, ) -> Result<(), IggyError> { - let partition = self.get_partition(partition_id).with_error(|_| { + let partition = self.get_partition(partition_id).with_error_context(|_| { format!("{COMPONENT} - failed to get partition with id: {partition_id}") })?; let partition = partition.read().await; - partition.store_consumer_offset(consumer, offset).await.with_error(|_| format!("{COMPONENT} - failed to store consumer offset, consumer: {consumer}, offset: {offset}")) + partition.store_consumer_offset(consumer, offset).await.with_error_context(|_| format!("{COMPONENT} - failed to store consumer offset, consumer: {consumer}, offset: {offset}")) } pub async fn get_consumer_offset( @@ -51,15 +51,15 @@ impl Topic { let (polling_consumer, partition_id) = self .resolve_consumer_with_partition_id(consumer, client_id, partition_id, false) .await - .with_error(|_| format!("{COMPONENT} - failed to resolve consumer with partition id, consumer: {consumer}, client ID: {client_id}, partition ID: {:?}", partition_id))?; - let partition = self.get_partition(partition_id).with_error(|_| { + .with_error_context(|_| format!("{COMPONENT} - failed to resolve consumer with partition id, consumer: {consumer}, client ID: {client_id}, partition ID: {:?}", partition_id))?; + let partition = self.get_partition(partition_id).with_error_context(|_| { format!("{COMPONENT} - failed to get partition with id: {partition_id}") })?; let partition = partition.read().await; let offset = partition .get_consumer_offset(polling_consumer) .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to get consumer offset, consumer: {polling_consumer}") })?; Ok(ConsumerOffsetInfo { diff --git a/server/src/streaming/topics/messages.rs b/server/src/streaming/topics/messages.rs index 39a9ae9d4..a580cb62b 100644 --- a/server/src/streaming/topics/messages.rs +++ b/server/src/streaming/topics/messages.rs @@ -5,7 +5,7 @@ use crate::streaming::topics::topic::Topic; use crate::streaming::topics::COMPONENT; use crate::streaming::utils::file::folder_size; use crate::streaming::utils::hash; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::locking::IggySharedMutFn; use iggy::messages::poll_messages::{PollingKind, PollingStrategy}; @@ -54,7 +54,7 @@ impl Topic { partition .get_messages_by_timestamp(value.into(), count) .await - .with_error(|_| format!("{COMPONENT} - failed to get messages by timestamp: {value}, count: {count}")) + .with_error_context(|_| format!("{COMPONENT} - failed to get messages by timestamp: {value}, count: {count}")) } PollingKind::First => partition.get_first_messages(count).await, PollingKind::Last => partition.get_last_messages(count).await, @@ -143,7 +143,7 @@ impl Topic { .await .append_messages(appendable_batch_info, messages) .await - .with_error(|_| format!("{COMPONENT} - failed to append messages"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to append messages"))?; Ok(()) } @@ -185,7 +185,9 @@ impl Topic { // TODO: load data from database instead of calculating the size on disk let total_size_on_disk_bytes = folder_size(&path) .await - .with_error(|_| format!("{COMPONENT} - failed to get folder size, path: {path}")) + .with_error_context(|_| { + format!("{COMPONENT} - failed to get folder size, path: {path}") + }) .map_err(|_| IggyError::InvalidSizeBytes)?; for partition_lock in self.partitions.values_mut() { @@ -223,7 +225,7 @@ impl Topic { let messages = partition .get_newest_messages_by_size(size_to_fetch_from_disk as u64) .await - .with_error(|_| format!("{COMPONENT} - failed to get newest messages by size: {size_to_fetch_from_disk}"))?; + .with_error_context(|_| format!("{COMPONENT} - failed to get newest messages by size: {size_to_fetch_from_disk}"))?; let sum = messages .iter() diff --git a/server/src/streaming/topics/partitions.rs b/server/src/streaming/topics/partitions.rs index db1799f4c..cbfb59e45 100644 --- a/server/src/streaming/topics/partitions.rs +++ b/server/src/streaming/topics/partitions.rs @@ -1,7 +1,7 @@ use crate::streaming::partitions::partition::Partition; use crate::streaming::topics::topic::Topic; use crate::streaming::topics::COMPONENT; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::locking::IggySharedMut; use iggy::locking::IggySharedMutFn; @@ -54,13 +54,13 @@ impl Topic { } pub async fn add_persisted_partitions(&mut self, count: u32) -> Result, IggyError> { - let partition_ids = self - .add_partitions(count) - .with_error(|_| format!("{COMPONENT} - failed to add partitions, count: {count}"))?; + let partition_ids = self.add_partitions(count).with_error_context(|_| { + format!("{COMPONENT} - failed to add partitions, count: {count}") + })?; for partition_id in &partition_ids { let partition = self.partitions.get(partition_id).unwrap(); let partition = partition.read().await; - partition.persist().await.with_error(|_| { + partition.persist().await.with_error_context(|_| { format!( "{COMPONENT} - failed to persist partiton with id: {}", partition.partition_id @@ -91,7 +91,7 @@ impl Topic { let partition_messages_count = partition.get_messages_count(); segments_count += partition.get_segments_count(); messages_count += partition_messages_count; - partition.delete().await.with_error(|_| { + partition.delete().await.with_error_context(|_| { format!( "{COMPONENT} - failed to delete partiton with id: {}", partition.partition_id diff --git a/server/src/streaming/topics/persistence.rs b/server/src/streaming/topics/persistence.rs index 37f36167f..e3c9bfa50 100644 --- a/server/src/streaming/topics/persistence.rs +++ b/server/src/streaming/topics/persistence.rs @@ -1,7 +1,7 @@ use crate::state::system::TopicState; use crate::streaming::topics::topic::Topic; use crate::streaming::topics::COMPONENT; -use error_set::ResultContext; +use error_set::ErrContext; use iggy::error::IggyError; use iggy::locking::IggySharedMutFn; @@ -19,7 +19,7 @@ impl Topic { pub async fn delete(&self) -> Result<(), IggyError> { for partition in self.get_partitions() { let partition = partition.read().await; - partition.delete().await.with_error(|_| { + partition.delete().await.with_error_context(|_| { format!( "{COMPONENT} - failed to delete partition with id: {}", partition.partition_id @@ -36,7 +36,7 @@ impl Topic { let mut partition = partition.write().await; let partition_id = partition.partition_id; for segment in partition.get_segments_mut() { - saved_messages_number += segment.persist_messages().await.with_error(|_| format!("{COMPONENT} - failed to persist messages in segment, partition ID: {partition_id}"))?; + saved_messages_number += segment.persist_messages().await.with_error_context(|_| format!("{COMPONENT} - failed to persist messages in segment, partition ID: {partition_id}"))?; } } diff --git a/server/src/streaming/topics/storage.rs b/server/src/streaming/topics/storage.rs index cafde573e..a4da433a6 100644 --- a/server/src/streaming/topics/storage.rs +++ b/server/src/streaming/topics/storage.rs @@ -6,7 +6,7 @@ use crate::streaming::topics::topic::Topic; use crate::streaming::topics::COMPONENT; use anyhow::Context; use async_trait::async_trait; -use error_set::ResultContext; +use error_set::ErrContext; use futures::future::join_all; use iggy::error::IggyError; use iggy::locking::IggySharedMut; @@ -150,7 +150,7 @@ impl TopicStorage for FileTopicStorage { topic.segments_count_of_parent_stream.clone(), partition_state.created_at, ); - partition.persist().await.with_error(|_| { + partition.persist().await.with_error_context(|_| { format!("{COMPONENT} - failed to persist partiton: {partition}") })?; partition.segments.clear(); @@ -209,7 +209,7 @@ impl TopicStorage for FileTopicStorage { topic .load_messages_from_disk_to_cache() .await - .with_error(|_| { + .with_error_context(|_| { format!("{COMPONENT} - failed to load messages from disk to cache, topic: {topic}") })?; info!("Loaded topic {topic}"); @@ -241,7 +241,7 @@ impl TopicStorage for FileTopicStorage { ); for (_, partition) in topic.partitions.iter() { let partition = partition.write().await; - partition.persist().await.with_error(|_| { + partition.persist().await.with_error_context(|_| { format!("{COMPONENT} - failed to persist partition, topic: {topic}") })?; }