diff --git a/Cargo.lock b/Cargo.lock index 9a05560..dd07cbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.6" @@ -86,14 +75,12 @@ dependencies = [ ] [[package]] -name = "async-channel" -version = "1.9.0" +name = "anyhow" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", + "backtrace", ] [[package]] @@ -112,6 +99,28 @@ dependencies = [ "zstd-safe", ] +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "async-trait" version = "0.1.74" @@ -136,13 +145,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core", + "axum-core 0.3.4", "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 0.1.2", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +dependencies = [ + "async-trait", + "axum-core 0.4.3", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.3.1", + "hyper-util", "itoa", "matchit", "memchr", @@ -154,7 +192,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 1.0.1", "tokio", "tower", "tower-layer", @@ -171,12 +209,32 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "mime", "rustversion", "tower-layer", "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 0.1.2", + "tower-layer", + "tower-service", "tracing", ] @@ -195,12 +253,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.5" @@ -227,6 +279,9 @@ name = "bitflags" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +dependencies = [ + "serde", +] [[package]] name = "block-buffer" @@ -288,11 +343,11 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cached" -version = "0.46.1" +version = "0.49.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7c8c50262271cdf5abc979a5f76515c234e764fa025d1ba4862c0f0bcda0e95" +checksum = "8e8e463fceca5674287f32d252fb1d94083758b8709c160efae66d263e5f4eba" dependencies = [ - "ahash 0.8.6", + "ahash", "cached_proc_macro", "cached_proc_macro_types", "hashbrown 0.14.2", @@ -303,9 +358,9 @@ dependencies = [ [[package]] name = "cached_proc_macro" -version = "0.18.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c878c71c2821aa2058722038a59a67583a4240524687c6028571c9b395ded61f" +checksum = "ad9f16c0d84de31a2ab7fdf5f7783c14631f7075cf464eb3bb43119f61c9cb2a" dependencies = [ "darling", "proc-macro2", @@ -315,15 +370,9 @@ dependencies = [ [[package]] name = "cached_proc_macro_types" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663" - -[[package]] -name = "castaway" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2698f953def977c68f935bb0dfa959375ad4638570e969e2f1e9f433cbf1af6" +checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" [[package]] name = "cc" @@ -378,49 +427,14 @@ dependencies = [ "phf_codegen", ] -[[package]] -name = "color-eyre" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" -dependencies = [ - "backtrace", - "color-spantrace", - "eyre", - "indenter", - "once_cell", - "owo-colors", - "tracing-error", -] - -[[package]] -name = "color-spantrace" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" -dependencies = [ - "once_cell", - "owo-colors", - "tracing-core", - "tracing-error", -] - -[[package]] -name = "concurrent-queue" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "config" -version = "0.13.3" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d379af7f68bfc21714c6c7dea883544201741d2ce8274bb12fa54f89507f52a7" +checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be" dependencies = [ "async-trait", + "convert_case", "json5", "lazy_static", "nom", @@ -429,10 +443,39 @@ dependencies = [ "rust-ini", "serde", "serde_json", - "toml 0.5.11", + "toml", "yaml-rust", ] +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom", + "once_cell", + "tiny-keccak", +] + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "core-foundation-sys" version = "0.8.4" @@ -476,6 +519,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -486,36 +535,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "curl" -version = "0.4.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "509bd11746c7ac09ebd19f0b17782eae80aadee26237658a6b4808afb5c11a22" -dependencies = [ - "curl-sys", - "libc", - "openssl-probe", - "openssl-sys", - "schannel", - "socket2 0.4.10", - "winapi", -] - -[[package]] -name = "curl-sys" -version = "0.4.65+curl-8.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "961ba061c9ef2fe34bbd12b807152d96f0badd2bebe7b90ce6c8c8b7572a0986" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", - "winapi", -] - [[package]] name = "darling" version = "0.14.4" @@ -578,9 +597,18 @@ dependencies = [ [[package]] name = "dlv-list" -version = "0.3.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", +] + +[[package]] +name = "either" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "equivalent" @@ -598,31 +626,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - -[[package]] -name = "eyre" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" -dependencies = [ - "indenter", - "once_cell", -] - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - [[package]] name = "flate2" version = "1.0.28" @@ -674,27 +677,6 @@ dependencies = [ "futures-util", ] -[[package]] -name = "futures-io" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" - -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - [[package]] name = "futures-macro" version = "0.3.29" @@ -801,17 +783,36 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", "futures-core", "futures-sink", "futures-util", - "http", - "indexmap 1.9.3", + "http 0.2.12", + "indexmap 2.1.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.1.0", + "indexmap 2.1.0", "slab", "tokio", "tokio-util", @@ -823,9 +824,12 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.7", -] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" [[package]] name = "hashbrown" @@ -833,7 +837,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ - "ahash 0.8.6", + "ahash", "allocator-api2", ] @@ -861,9 +865,20 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f95b9abcae896730d42b78e09c155ed4ddf82c07b4de772c64aee5b2d8b7c150" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -872,20 +887,43 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes", + "futures-core", + "http 1.1.0", + "http-body 1.0.0", "pin-project-lite", ] [[package]] name = "http-range-header" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "3ce4ef31cda248bbdb6e6820603b82dfcd9e833db65a43e997a0ccec777d11fe" [[package]] name = "httparse" @@ -910,28 +948,76 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2", "tokio", "tower-service", "tracing", "want", ] +[[package]] +name = "hyper" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.4", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper 0.14.28", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.3.1", + "pin-project-lite", + "socket2", + "tokio", +] + [[package]] name = "iana-time-zone" version = "0.1.58" @@ -961,16 +1047,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "idna" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "ignore" version = "0.4.20" @@ -988,12 +1064,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "indenter" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" - [[package]] name = "indexmap" version = "1.9.3" @@ -1023,12 +1093,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "integer-encoding" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" - [[package]] name = "io-lifetimes" version = "1.0.11" @@ -1051,28 +1115,12 @@ dependencies = [ ] [[package]] -name = "isahc" -version = "1.7.2" +name = "itertools" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "334e04b4d781f436dc315cb1e7515bd96826426345d498149e4bde36b67f8ee9" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ - "async-channel", - "castaway", - "crossbeam-utils", - "curl", - "curl-sys", - "event-listener", - "futures-lite", - "http", - "log", - "once_cell", - "polling", - "slab", - "sluice", - "tracing", - "tracing-futures", - "url", - "waker-fn", + "either", ] [[package]] @@ -1128,18 +1176,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "libz-sys" -version = "1.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "line-wrap" version = "0.1.1" @@ -1316,33 +1352,14 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "opentelemetry" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e32339a5dc40459130b3bd269e9892439f55b33e772d2a9d402a789baaf4e8a" +checksum = "900d57987be3f2aeb70d385fff9b27fb74c5723cc9a52d904d4f9c807a0667bf" dependencies = [ "futures-core", "futures-sink", - "indexmap 2.1.0", "js-sys", "once_cell", "pin-project-lite", @@ -1351,50 +1368,47 @@ dependencies = [ ] [[package]] -name = "opentelemetry-http" -version = "0.10.0" +name = "opentelemetry-otlp" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f51189ce8be654f9b5f7e70e49967ed894e84a06fc35c6c042e64ac1fc5399e" -dependencies = [ - "async-trait", - "bytes", - "http", - "isahc", - "opentelemetry", -] - -[[package]] -name = "opentelemetry-jaeger" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e617c66fd588e40e0dbbd66932fdc87393095b125d4459b1a3a10feb1712f8a1" +checksum = "1a016b8d9495c639af2145ac22387dcb88e44118e45320d9238fbf4e7889abcb" dependencies = [ "async-trait", "futures-core", - "futures-util", - "http", - "isahc", + "http 0.2.12", "opentelemetry", - "opentelemetry-http", + "opentelemetry-proto", "opentelemetry-semantic-conventions", "opentelemetry_sdk", - "thrift", + "prost", + "thiserror", + "tokio", + "tonic", +] + +[[package]] +name = "opentelemetry-proto" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8fddc9b68f5b80dae9d6f510b88e02396f006ad48cac349411fbecc80caae4" +dependencies = [ + "opentelemetry", + "opentelemetry_sdk", + "prost", + "tonic", ] [[package]] name = "opentelemetry-semantic-conventions" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5774f1ef1f982ef2a447f6ee04ec383981a3ab99c8e77a1a7b30182e65bbc84" -dependencies = [ - "opentelemetry", -] +checksum = "f9ab5bd6c42fb9349dcf28af2ba9a0667f697f9bdcca045d39f2cec5543e2910" [[package]] name = "opentelemetry_sdk" -version = "0.21.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b3ce3f5705e2ae493be467a0b23be4bc563c193cdb7713e55372c89a906b34" +checksum = "9e90c7113be649e31e9a0f8b5ee24ed7a16923b322c3c5ab6367469c049d6b7e" dependencies = [ "async-trait", "crossbeam-channel", @@ -1404,19 +1418,12 @@ dependencies = [ "glob", "once_cell", "opentelemetry", - "ordered-float 4.1.1", + "ordered-float", "percent-encoding", "rand", "thiserror", -] - -[[package]] -name = "ordered-float" -version = "2.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" -dependencies = [ - "num-traits", + "tokio", + "tokio-stream", ] [[package]] @@ -1430,12 +1437,12 @@ dependencies = [ [[package]] name = "ordered-multimap" -version = "0.4.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" +checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e" dependencies = [ "dlv-list", - "hashbrown 0.12.3", + "hashbrown 0.13.2", ] [[package]] @@ -1444,18 +1451,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "owo-colors" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" - -[[package]] -name = "parking" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" - [[package]] name = "parking_lot" version = "0.12.1" @@ -1627,7 +1622,7 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5699cc8a63d1aa2b1ee8e12b9ad70ac790d65788cd36101fa37f87ea46c4cef" dependencies = [ - "base64 0.21.5", + "base64", "indexmap 2.1.0", "line-wrap", "quick-xml", @@ -1635,22 +1630,6 @@ dependencies = [ "time", ] -[[package]] -name = "polling" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" -dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if", - "concurrent-queue", - "libc", - "log", - "pin-project-lite", - "windows-sys 0.48.0", -] - [[package]] name = "powerfmt" version = "0.2.0" @@ -1702,6 +1681,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "prost" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "protobuf" version = "2.28.0" @@ -1710,16 +1712,23 @@ checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" [[package]] name = "pulldown-cmark" -version = "0.9.3" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" +checksum = "5f0530d13d87d1f549b66a3e8d0c688952abe5994e204ed62615baaf25dc029c" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "getopts", "memchr", + "pulldown-cmark-escape", "unicase", ] +[[package]] +name = "pulldown-cmark-escape" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5d8f9aa0e3cbcfaf8bf00300004ee3b72f74770f9cbac93f6928771f613276b" + [[package]] name = "quick-xml" version = "0.31.0" @@ -1829,20 +1838,21 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "ron" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" +checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", + "base64", + "bitflags 2.4.1", "serde", + "serde_derive", ] [[package]] name = "rust-ini" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" +checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091" dependencies = [ "cfg-if", "ordered-multimap", @@ -1895,15 +1905,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" -dependencies = [ - "windows-sys 0.48.0", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -2026,32 +2027,11 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "sluice" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7400c0eff44aa2fcb5e31a5f24ba9716ed90138769e4977a2ba6014ae63eb5" -dependencies = [ - "async-channel", - "futures-core", - "futures-io", -] - [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" - -[[package]] -name = "socket2" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi", -] +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" @@ -2097,6 +2077,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "syntect" version = "5.1.0" @@ -2170,28 +2156,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", -] - -[[package]] -name = "thrift" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e54bc85fc7faa8bc175c4bab5b92ba8d9a3ce893d0e9f42cc455c8ab16a9e09" -dependencies = [ - "byteorder", - "integer-encoding", - "log", - "ordered-float 2.10.1", - "threadpool", -] - [[package]] name = "time" version = "0.3.30" @@ -2222,20 +2186,14 @@ dependencies = [ ] [[package]] -name = "tinyvec" -version = "1.6.0" +name = "tiny-keccak" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" dependencies = [ - "tinyvec_macros", + "crunchy", ] -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "tokio" version = "1.34.0" @@ -2250,12 +2208,22 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.5", + "socket2", "tokio-macros", "tracing", "windows-sys 0.48.0", ] +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-macros" version = "2.2.0" @@ -2267,6 +2235,17 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.10" @@ -2281,15 +2260,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - [[package]] name = "toml" version = "0.8.8" @@ -2324,6 +2294,33 @@ dependencies = [ "winnow", ] +[[package]] +name = "tonic" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +dependencies = [ + "async-stream", + "async-trait", + "axum 0.6.20", + "base64", + "bytes", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "tower" version = "0.4.13" @@ -2347,18 +2344,19 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "async-compression", - "base64 0.21.5", + "base64", "bitflags 2.4.1", "bytes", "futures-core", "futures-util", - "http", - "http-body", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "http-range-header", "httpdate", "iri-string", @@ -2420,26 +2418,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-error" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" -dependencies = [ - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - [[package]] name = "tracing-log" version = "0.1.4" @@ -2464,9 +2442,9 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c67ac25c5407e7b961fafc6f7e9aa5958fd297aada2d20fa2ae1737357e55596" +checksum = "a9be14ba1bbe4ab79e9229f7f89fab8d120b865859f10527f31c033e599d2284" dependencies = [ "js-sys", "once_cell", @@ -2513,9 +2491,9 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" @@ -2588,12 +2566,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - [[package]] name = "unicode-ident" version = "1.0.12" @@ -2601,13 +2573,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "unicode-normalization" -version = "0.1.22" +name = "unicode-segmentation" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" @@ -2615,17 +2584,6 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" -[[package]] -name = "url" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - [[package]] name = "urlencoding" version = "2.1.3" @@ -2647,24 +2605,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "walkdir" version = "2.4.0" @@ -2746,9 +2692,9 @@ checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "web-time" -version = "0.2.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57099a701fb3a8043f993e8228dc24229c7b942e2b009a1b962e54489ba1d3bf" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" dependencies = [ "js-sys", "wasm-bindgen", @@ -2758,14 +2704,15 @@ dependencies = [ name = "website" version = "0.1.0" dependencies = [ - "axum", + "anyhow", + "axum 0.7.5", "cached", "chrono", - "color-eyre", "config", "glob", "opentelemetry", - "opentelemetry-jaeger", + "opentelemetry-otlp", + "opentelemetry_sdk", "prometheus", "pulldown-cmark", "regex", @@ -2775,7 +2722,7 @@ dependencies = [ "syntect", "tera", "tokio", - "toml 0.8.8", + "toml", "tower", "tower-http", "tracing", diff --git a/Cargo.toml b/Cargo.toml index 04035d1..6af1eb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,16 +6,17 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -axum = { version = "0.6.20", features = ["http2", "original-uri", "tracing"] } -cached = "0.46.1" +anyhow = { version = "1.0.82", features = ["backtrace"] } +axum = { version = "0.7.5", features = ["http2", "original-uri", "tracing"] } +cached = "0.49.3" chrono = { version = "0.4.31", features = ["serde"] } -color-eyre = "0.6.1" -config = "0.13.3" +config = "0.14.0" glob = "0.3.0" -opentelemetry = { version = "0.21.0", features = ["metrics"] } -opentelemetry-jaeger = { version = "0.20.0", features = ["collector_client", "isahc_collector_client"]} +opentelemetry = { version = "0.22.0", features = ["trace", "metrics"] } +opentelemetry-otlp = { version = "0.15.0", features = ["trace", "metrics"] } +opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio", "trace", "metrics"] } prometheus = { version = "0.13.3", features = ["process"] } -pulldown-cmark = "0.9.2" +pulldown-cmark = "0.10.2" regex = "1.7.2" serde = "1.0.144" serde_derive = "1.0.144" @@ -25,7 +26,7 @@ tera = { version = "1.19.1", features = ["builtins"] } tokio = { version = "1.34.0", features = ["full", "tracing"] } toml = "0.8.8" tower = { version = "0.4.13", features = ["full"] } -tower-http = { version = "0.4.4", features = ["full"] } +tower-http = { version = "0.5.2", features = ["full"] } tracing = "0.1.35" -tracing-opentelemetry = "0.22.0" +tracing-opentelemetry = "0.23.0" tracing-subscriber = { version = "0.3.17", features = ["fmt", "env-filter", "json", "tracing-log"] } diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..9aadf2a --- /dev/null +++ b/fly.toml @@ -0,0 +1,18 @@ +# fly.toml app configuration file generated for cool-glade-6208 on 2023-06-24T10:46:20+02:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = "cool-glade-6208" +primary_region = "arn" + +[http_service] + internal_port = 8080 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + +[metrics] + port = 8180 + path = "/metrics" diff --git a/src/feed.rs b/src/feed.rs index ecc54d7..317f8cd 100644 --- a/src/feed.rs +++ b/src/feed.rs @@ -1,4 +1,4 @@ -use color_eyre::Result; +use anyhow::Result; use serde_derive::Serialize; use tracing::instrument; @@ -16,7 +16,11 @@ struct FeedContext<'a> { #[instrument(skip(state))] pub fn render_atom_feed(state: &AppState) -> Result { - let mut posts: Vec<_> = state.posts.values().filter(|p| !p.draft && p.is_published()).collect(); + let mut posts: Vec<_> = state + .posts + .values() + .filter(|p| !p.draft && p.is_published()) + .collect(); posts.sort_by_key(|p| &p.date); posts.reverse(); diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index a410d32..249a140 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -1,7 +1,7 @@ use axum::{ - body, - extract::State, - http::{header, HeaderMap, Request, StatusCode}, + body::Body, + extract::{Request, State}, + http::{header, HeaderMap, StatusCode}, middleware::Next, response::{Html, IntoResponse, Response}, routing::get, @@ -14,7 +14,7 @@ use std::sync::Arc; use tower_http::services::ServeDir; use tracing::{ instrument, - log::{error, info, debug}, + log::{debug, error, info}, }; use crate::{AppState, WebsiteError}; @@ -22,14 +22,16 @@ use crate::{AppState, WebsiteError}; pub mod posts; pub mod tags; -pub static HIT_COUNTER: Lazy = Lazy::new(|| prometheus::register_int_counter_vec!( - opts!( - "http_requests_total", - "Total amount of http requests received" - ), - &["route", "method", "status"] -) -.unwrap()); +pub static HIT_COUNTER: Lazy = Lazy::new(|| { + prometheus::register_int_counter_vec!( + opts!( + "http_requests_total", + "Total amount of http requests received" + ), + &["route", "method", "status"] + ) + .unwrap() +}); pub fn routes(state: &Arc) -> Router> { Router::new() @@ -38,14 +40,8 @@ pub fn routes(state: &Arc) -> Router> { .merge(tags::router()) .merge(posts::alias_router(state.posts.values())) .route("/healthcheck", get(healthcheck)) - .route_service( - "/posts/:slug/*path", - ServeDir::new("./"), - ) - .route_service( - "/static/*path", - ServeDir::new("./"), - ) + .route_service("/posts/:slug/*path", ServeDir::new("./")) + .route_service("/static/*path", ServeDir::new("./")) .layer(axum::middleware::from_fn(metrics_middleware)) .route("/metrics", get(metrics)) } @@ -86,7 +82,7 @@ async fn metrics() -> impl IntoResponse { Response::builder() .status(200) .header(header::CONTENT_TYPE, encoder.format_type()) - .body(body::boxed(body::Full::from(buffer))) + .body(Body::from(buffer)) .unwrap() } @@ -95,7 +91,7 @@ pub async fn not_found() -> impl IntoResponse { } #[instrument(skip(request, next))] -pub async fn metrics_middleware(request: Request, next: Next) -> Response { +pub async fn metrics_middleware(request: Request, next: Next) -> Response { let path = request.uri().path().to_string(); let method = request.method().clone(); diff --git a/src/handlers/posts.rs b/src/handlers/posts.rs index cbf1a23..f61fdb5 100644 --- a/src/handlers/posts.rs +++ b/src/handlers/posts.rs @@ -37,8 +37,8 @@ pub fn alias_router<'a>(posts: impl IntoIterator) -> Router>, headers: HeaderMap, ) -> Result { - let mut posts: Vec<&Post> = state.posts.values().filter(|p| !p.draft && p.is_published()).collect(); + let mut posts: Vec<&Post> = state + .posts + .values() + .filter(|p| !p.draft && p.is_published()) + .collect(); let last_changed = posts.iter().filter_map(|p| p.last_modified()).max(); @@ -76,15 +80,11 @@ pub async fn index( let res = state.tera.render("posts_index.html", &c)?; - Ok(( StatusCode::OK, [( header::LAST_MODIFIED, - last_changed.map_or_else( - || state.startup_time.to_rfc2822(), - |d| d.to_rfc2822(), - ), + last_changed.map_or_else(|| state.startup_time.to_rfc2822(), |d| d.to_rfc2822()), )], Html(res), ) @@ -116,10 +116,7 @@ pub async fn view( StatusCode::OK, [( header::LAST_MODIFIED, - last_changed.map_or_else( - || state.startup_time.to_rfc2822(), - |d| d.to_rfc2822(), - ), + last_changed.map_or_else(|| state.startup_time.to_rfc2822(), |d| d.to_rfc2822()), )], Html(res), ) @@ -131,7 +128,11 @@ pub async fn feed( State(state): State>, headers: HeaderMap, ) -> Result { - let mut posts: Vec<&Post> = state.posts.values().filter(|p| !p.draft && p.is_published()).collect(); + let mut posts: Vec<&Post> = state + .posts + .values() + .filter(|p| !p.draft && p.is_published()) + .collect(); let last_changed = posts.iter().filter_map(|p| p.last_modified()).max(); @@ -149,10 +150,7 @@ pub async fn feed( (header::CONTENT_TYPE, "application/atom+xml"), ( header::LAST_MODIFIED, - &last_changed.map_or_else( - || state.startup_time.to_rfc2822(), - |d| d.to_rfc2822(), - ), + &last_changed.map_or_else(|| state.startup_time.to_rfc2822(), |d| d.to_rfc2822()), ), ], crate::feed::render_atom_feed(&state)?, diff --git a/src/handlers/tags.rs b/src/handlers/tags.rs index b2908b9..0f1e25f 100644 --- a/src/handlers/tags.rs +++ b/src/handlers/tags.rs @@ -85,10 +85,7 @@ pub async fn view( StatusCode::OK, [( header::LAST_MODIFIED, - &last_changed.map_or_else( - || state.startup_time.to_rfc2822(), - |d| d.to_rfc2822(), - ), + &last_changed.map_or_else(|| state.startup_time.to_rfc2822(), |d| d.to_rfc2822()), )], Html(res), ) @@ -125,10 +122,7 @@ pub async fn feed( (header::CONTENT_TYPE, "application/atom+xml"), ( header::LAST_MODIFIED, - &last_changed.map_or_else( - || state.startup_time.to_rfc2822(), - |d| d.to_rfc2822(), - ), + &last_changed.map_or_else(|| state.startup_time.to_rfc2822(), |d| d.to_rfc2822()), ), ], crate::feed::render_atom_tag_feed(tag, &state)?, diff --git a/src/helpers.rs b/src/helpers.rs index e60c274..6910173 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -36,23 +36,32 @@ pub fn uri_with_path(uri: &Uri, path: &str) -> Uri { mod tests { use axum::http::Uri; - use crate::helpers::uri_with_path; + use super::*; #[test] fn uri_with_relative_path() { let uri: Uri = "http://localhost/baba/".parse().unwrap(); - assert_eq!(uri_with_path(&uri, "is/you").to_string(), "http://localhost/baba/is/you"); + assert_eq!( + uri_with_path(&uri, "is/you").to_string(), + "http://localhost/baba/is/you" + ); } #[test] fn uri_with_absolute_path() { let uri: Uri = "http://localhost/baba/is/you".parse().unwrap(); - assert_eq!(uri_with_path(&uri, "/keke/is/move").to_string(), "http://localhost/keke/is/move"); + assert_eq!( + uri_with_path(&uri, "/keke/is/move").to_string(), + "http://localhost/keke/is/move" + ); } #[test] fn uri_with_index_relative_path() { let uri: Uri = "http://localhost/baba/is/you".parse().unwrap(); - assert_eq!(uri_with_path(&uri, "happy").to_string(), "http://localhost/baba/is/happy"); + assert_eq!( + uri_with_path(&uri, "happy/and/you").to_string(), + "http://localhost/baba/is/happy/and/you" + ); } } diff --git a/src/hilighting.rs b/src/hilighting.rs index 970bf71..e4bcb9b 100644 --- a/src/hilighting.rs +++ b/src/hilighting.rs @@ -2,7 +2,7 @@ use syntect::{highlighting::ThemeSet, parsing::SyntaxSet}; use tracing::{error, instrument}; #[instrument(skip(content, lang, theme))] -pub fn hilight(content: &str, lang: &str, theme: Option<&str>) -> color_eyre::Result { +pub fn hilight(content: &str, lang: &str, theme: Option<&str>) -> anyhow::Result { let ss = SyntaxSet::load_defaults_newlines(); let s = ss .find_syntax_by_extension(lang) diff --git a/src/main.rs b/src/main.rs index 825b531..9258269 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,31 +1,26 @@ #![warn(clippy::pedantic)] -#![allow(clippy::unused_async)] // axum handlers needs async, even if no awaiting happens -use std::{collections::HashMap, fmt::Display, sync::Arc, time::Duration}; +use std::{collections::HashMap, fmt::Display, sync::Arc}; -use axum::{ - body::Body, - extract::{MatchedPath, OriginalUri}, - http::{uri::PathAndQuery, Request, Uri}, - response::Response, -}; +use axum::http::Uri; use chrono::DateTime; -use color_eyre::eyre::{Error, Result}; use config::Config; use post::Post; use tag::Tag; use tera::Tera; -use tower_http::{compression::CompressionLayer, cors::CorsLayer}; -use tracing::{field::Empty, info_span, log::info, Span, instrument}; -use tracing_subscriber::{prelude::*, EnvFilter}; +use tower_http::{compression::CompressionLayer, cors::CorsLayer}; +use tracing::{instrument, log::info}; + +use anyhow::{Error, Result}; mod feed; mod handlers; mod helpers; mod hilighting; mod markdown; +mod observability; mod post; mod tag; @@ -40,28 +35,24 @@ pub struct AppState { #[tokio::main] async fn main() -> Result<()> { - color_eyre::install()?; let cfg = Config::builder() .add_source(config::File::with_name("config.toml")) .add_source(config::Environment::with_prefix("WEBSITE")) .build()?; - init_tracing(&cfg); + observability::init_tracing(&cfg); info!("Starting server..."); - + let addr = cfg.get_string("bind_address")?; let app = init_app(&cfg).await?; - axum::Server::bind(&cfg.get_string("bind_address")?.parse().unwrap()) - .serve(app.into_make_service()) - .await?; + let listener = tokio::net::TcpListener::bind(addr).await.unwrap(); + axum::serve(listener, app.into_make_service()).await?; Ok(()) } #[instrument] async fn init_app(cfg: &Config) -> Result { - let base_url: Uri = cfg.get_string("base_url")? - .parse() - .unwrap(); + let base_url: Uri = cfg.get_string("base_url")?.parse().unwrap(); let tera = Tera::new("templates/**/*")?; let mut state = AppState { @@ -83,69 +74,12 @@ async fn init_app(cfg: &Config) -> Result { .layer(CompressionLayer::new()) .layer( tower_http::trace::TraceLayer::new_for_http() - .make_span_with(make_span) - .on_response(on_response), + .make_span_with(observability::make_span) + .on_response(observability::on_response), ) .with_state(state.clone())) } -fn init_tracing(cfg: &Config) { - let filter = if let Ok(filter) = cfg.get_string("logging") { - EnvFilter::builder() - .with_default_directive("info".parse().unwrap()) - .parse_lossy(filter) - } else { - EnvFilter::builder() - .with_default_directive("info".parse().unwrap()) - .from_env_lossy() - }; - - opentelemetry::global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new()); - - let tracer = opentelemetry_jaeger::new_agent_pipeline() - .with_service_name("website") - .install_simple().unwrap(); - - let otel = tracing_opentelemetry::layer().with_tracer(tracer); - - tracing_subscriber::registry() - .with(filter) - .with(otel) - .with(tracing_subscriber::fmt::layer()) - .init(); -} - - -fn make_span(request: &Request) -> Span { - let uri = if let Some(OriginalUri(uri)) = request.extensions().get::() { - uri - } else { - request.uri() - }; - let route = request - .extensions() - .get::() - .map_or(uri.path(), axum::extract::MatchedPath::as_str); - let method = request.method().as_str(); - let target = uri - .path_and_query() - .map_or(uri.path(), PathAndQuery::as_str); - let name = format!("{method} {route}"); - - info_span!( - "request", - otel.name = %name, - http.route = %route, - http.method = %method, - http.target = %target, - http.status_code = Empty - ) -} - -fn on_response(response: &Response, _latency: Duration, span: &Span) { - span.record("http.status_code", response.status().as_str()); -} - #[derive(Debug)] pub enum WebsiteError { NotFound, @@ -176,8 +110,8 @@ impl From for WebsiteError { } } -impl From for WebsiteError { - fn from(value: color_eyre::Report) -> Self { +impl From for WebsiteError { + fn from(value: Error) -> Self { WebsiteError::InternalError(value) } } diff --git a/src/markdown.rs b/src/markdown.rs index af7c51f..bd3cb6c 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -2,8 +2,10 @@ use crate::helpers; use crate::hilighting; use axum::http::Uri; use cached::once_cell::sync::Lazy; +use pulldown_cmark::CodeBlockKind; use pulldown_cmark::Event; use pulldown_cmark::Tag; +use pulldown_cmark::TagEnd; use pulldown_cmark::{Options, Parser}; use regex::Regex; use tracing::instrument; @@ -24,46 +26,65 @@ pub fn render_markdown_to_html(base_uri: Option<&Uri>, markdown: &str) -> String let mut content_html = String::new(); let parser = Parser::new_ext(markdown, opt); - let mut code_block = false; let mut code_lang = None; let mut code_accumulator = String::new(); let mut events = Vec::new(); for event in parser { match event { Event::Text(text) => { - if code_block { + if code_lang.is_some() { code_accumulator.push_str(&text); } else { events.push(Event::Text(text)); } } - Event::Start(Tag::Link(t, mut link, title)) => { + Event::Start(Tag::Link { + mut dest_url, + link_type, + title, + id, + }) => { if let Some(uri) = base_uri { - if !link.starts_with('#') && !STARTS_WITH_SCHEMA_RE.is_match(&link) && !EMAIL_RE.is_match(&link) { + if !dest_url.starts_with('#') + && !STARTS_WITH_SCHEMA_RE.is_match(&dest_url) + && !EMAIL_RE.is_match(&dest_url) + { // convert relative URIs to absolute URIs - link = helpers::uri_with_path(uri, &link).to_string().into(); + dest_url = helpers::uri_with_path(uri, &dest_url).to_string().into(); } } - events.push(Event::Start(Tag::Link(t, link, title))); + events.push(Event::Start(Tag::Link { + dest_url, + link_type, + title, + id, + })); } - Event::Start(Tag::Image(t, mut link, title)) => { + Event::Start(Tag::Image { + link_type, + mut dest_url, + title, + id, + }) => { if let Some(uri) = base_uri { - if !link.contains("://") && !link.contains('@') { + if !dest_url.contains("://") && !dest_url.contains('@') { // convert relative URIs to absolute URIs - link = helpers::uri_with_path(uri, &link).to_string().into(); + dest_url = helpers::uri_with_path(uri, &dest_url).to_string().into(); } } - events.push(Event::Start(Tag::Image(t, link, title))); + events.push(Event::Start(Tag::Image { + link_type, + dest_url, + title, + id, + })); } Event::Start(Tag::CodeBlock(kind)) => { - code_block = true; - if let pulldown_cmark::CodeBlockKind::Fenced(lang) = kind { + if let CodeBlockKind::Fenced(lang) = kind { code_lang = Some(lang); } } - Event::End(Tag::CodeBlock(_)) => { - code_block = false; - + Event::End(TagEnd::CodeBlock) => { let lang = code_lang.take().unwrap_or("".into()); let res = hilighting::hilight(&code_accumulator, &lang, Some("base16-ocean.dark")) .unwrap(); diff --git a/src/observability.rs b/src/observability.rs new file mode 100644 index 0000000..d0b2c17 --- /dev/null +++ b/src/observability.rs @@ -0,0 +1,70 @@ +use std::time::Duration; + +use axum::{ + extract::{MatchedPath, OriginalUri, Request}, + http::uri::PathAndQuery, + response::Response, +}; +use config::Config; +use opentelemetry::global; +use opentelemetry_sdk::propagation::TraceContextPropagator; +use tracing::{field::Empty, info_span, Span}; +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; + +pub fn init_tracing(cfg: &Config) { + let filter = if let Ok(filter) = cfg.get_string("logging") { + EnvFilter::builder() + .with_default_directive("info".parse().unwrap()) + .parse_lossy(filter) + } else { + EnvFilter::builder() + .with_default_directive("info".parse().unwrap()) + .from_env_lossy() + }; + + global::set_text_map_propagator(TraceContextPropagator::new()); + + let tracer = opentelemetry_otlp::new_pipeline() + .tracing() + .with_exporter(opentelemetry_otlp::new_exporter().tonic()) + .install_batch(opentelemetry_sdk::runtime::Tokio) + .unwrap(); + + let otel = tracing_opentelemetry::layer().with_tracer(tracer); + + tracing_subscriber::registry() + .with(filter) + .with(otel) + .with(tracing_subscriber::fmt::layer()) + .init(); +} + +pub fn make_span(request: &Request) -> Span { + let uri = if let Some(OriginalUri(uri)) = request.extensions().get::() { + uri + } else { + request.uri() + }; + let route = request + .extensions() + .get::() + .map_or(uri.path(), axum::extract::MatchedPath::as_str); + let method = request.method().as_str(); + let target = uri + .path_and_query() + .map_or(uri.path(), PathAndQuery::as_str); + let name = format!("{method} {route}"); + + info_span!( + "request", + otel.name = %name, + http.route = %route, + http.method = %method, + http.target = %target, + http.status_code = Empty + ) +} + +pub fn on_response(response: &Response, _latency: Duration, span: &Span) { + span.record("http.status_code", response.status().as_str()); +} diff --git a/src/post.rs b/src/post.rs index c1b0d92..50ea5fe 100644 --- a/src/post.rs +++ b/src/post.rs @@ -1,5 +1,7 @@ use std::{collections::HashMap, path::Path}; +use anyhow::Result; + use cached::once_cell::sync::Lazy; use chrono::{DateTime, FixedOffset}; use glob::glob; @@ -15,10 +17,9 @@ use tracing::{ use crate::{helpers, markdown, AppState, WebsiteError}; -static FRONTMATTER_REGEX: Lazy = Lazy::new(|| Regex::new( - r"^[\s]*\+{3}(\r?\n(?s).*?(?-s))\+{3}[\s]*(?:$|(?:\r?\n((?s).*(?-s))$))" -) -.unwrap()); +static FRONTMATTER_REGEX: Lazy = Lazy::new(|| { + Regex::new(r"^[\s]*\+{3}(\r?\n(?s).*?(?-s))\+{3}[\s]*(?:$|(?:\r?\n((?s).*(?-s))$))").unwrap() +}); #[derive(Deserialize, Debug, Default)] pub struct TomlFrontMatter { @@ -76,7 +77,7 @@ impl Post { } #[instrument(skip(state))] -pub async fn load_all(state: &AppState) -> color_eyre::eyre::Result> { +pub async fn load_all(state: &AppState) -> Result> { let mut res = HashMap::::new(); for path in glob("posts/**/*.md")? { let path = path.unwrap(); @@ -101,7 +102,7 @@ pub async fn load_all(state: &AppState) -> color_eyre::eyre::Result color_eyre::eyre::Result { +pub async fn load_post(state: &AppState, slug: &str) -> Result { debug!("loading post: {slug}"); let file_path = Path::new("posts").join(slug); @@ -127,9 +128,7 @@ pub async fn load_post(state: &AppState, slug: &str) -> color_eyre::eyre::Result } #[instrument(skip(src))] -fn parse_frontmatter( - src: String, -) -> color_eyre::eyre::Result<(Option, Option)> { +fn parse_frontmatter(src: String) -> Result<(Option, Option)> { Ok(if let Some(captures) = FRONTMATTER_REGEX.captures(&src) { ( Some(toml::from_str(captures.get(1).unwrap().as_str())?),