From 8514663193694b3883b80404ea696f4a3fa64165 Mon Sep 17 00:00:00 2001 From: kana-rus Date: Wed, 21 Dec 2022 18:17:52 +0900 Subject: [PATCH 01/10] Add: frameworks/Rust/ohkami --- frameworks/Rust/ohkami/Cargo.lock | 1846 ++++++++++++++++++ frameworks/Rust/ohkami/Cargo.toml | 10 + frameworks/Rust/ohkami/README.md | 15 + frameworks/Rust/ohkami/benchmark_config.json | 27 + frameworks/Rust/ohkami/ohkami.dockerfile | 13 + frameworks/Rust/ohkami/src/components.rs | 50 + frameworks/Rust/ohkami/src/main.rs | 88 + 7 files changed, 2049 insertions(+) create mode 100644 frameworks/Rust/ohkami/Cargo.lock create mode 100644 frameworks/Rust/ohkami/Cargo.toml create mode 100644 frameworks/Rust/ohkami/README.md create mode 100644 frameworks/Rust/ohkami/benchmark_config.json create mode 100644 frameworks/Rust/ohkami/ohkami.dockerfile create mode 100644 frameworks/Rust/ohkami/src/components.rs create mode 100644 frameworks/Rust/ohkami/src/main.rs diff --git a/frameworks/Rust/ohkami/Cargo.lock b/frameworks/Rust/ohkami/Cargo.lock new file mode 100644 index 00000000000..1224acf4777 --- /dev/null +++ b/frameworks/Rust/ohkami/Cargo.lock @@ -0,0 +1,1846 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "async-channel" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-executor" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" +dependencies = [ + "async-lock", + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" +dependencies = [ + "async-channel", + "async-executor", + "async-io", + "async-lock", + "blocking", + "futures-lite", + "once_cell", +] + +[[package]] +name = "async-io" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" +dependencies = [ + "async-lock", + "autocfg", + "concurrent-queue", + "futures-lite", + "libc", + "log", + "parking", + "polling", + "slab", + "socket2", + "waker-fn", + "windows-sys 0.42.0", +] + +[[package]] +name = "async-lock" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" +dependencies = [ + "event-listener", + "futures-lite", +] + +[[package]] +name = "async-native-tls" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d57d4cec3c647232e1094dc013546c0b33ce785d8aeb251e1f20dfaf8a9a13fe" +dependencies = [ + "futures-util", + "native-tls", + "thiserror", + "url", +] + +[[package]] +name = "async-process" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6381ead98388605d0d9ff86371043b5aa922a3905824244de40dc263a14fcba4" +dependencies = [ + "async-io", + "async-lock", + "autocfg", + "blocking", + "cfg-if", + "event-listener", + "futures-lite", + "libc", + "signal-hook", + "windows-sys 0.42.0", +] + +[[package]] +name = "async-std" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +dependencies = [ + "async-channel", + "async-global-executor", + "async-io", + "async-lock", + "async-process", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-task" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" + +[[package]] +name = "atoi" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-waker" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "blocking" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c67b173a56acffd6d2326fb7ab938ba0b00a71480e14902b2591c87bc5741e8" +dependencies = [ + "async-channel", + "async-lock", + "async-task", + "atomic-waker", + "fastrand", + "futures-lite", +] + +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" + +[[package]] +name = "cc" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits", + "time", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "concurrent-queue" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53757d12b596c16c78b83458d732a5d1a17ab3f53f2f7412f6fb57cc8a140ab3" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d0165d2900ae6778e36e80bbc4da3b5eefccee9ba939761f9c2882a5d9af3ff" + +[[package]] +name = "crossbeam-queue" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "ctor" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "cxx" +version = "1.0.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27874566aca772cb515af4c6e997b5fe2119820bca447689145e39bb734d19a0" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb951f2523a49533003656a72121306b225ec16a49a09dc6b0ba0d6f3ec3c0" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be778b6327031c1c7b61dd2e48124eee5361e6aa76b8de93692f011b08870ab4" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b8a2b87662fe5a0a0b38507756ab66aff32638876a0866e5a5fc82ceb07ee49" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dotenvy" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0" + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" + +[[package]] +name = "futures-intrusive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" + +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-macro" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" + +[[package]] +name = "futures-task" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" + +[[package]] +name = "futures-util" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +dependencies = [ + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gloo-timers" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98c4a8d6391675c6b2ee1a6c8d06e8e2d03605c44cec1270675985a4c2a5500b" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashlink" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" + +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", + "value-bag", +] + +[[package]] +name = "md-5" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +dependencies = [ + "digest", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "ohkami" +version = "0.1.10" +source = "git+https://github.com/kana-rus/ohkami#d9c03f6debf6925491282848d032de14bf16c45c" +dependencies = [ + "async-std", + "chrono", + "serde", + "serde_json", + "sqlx", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "openssl" +version = "0.10.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29d971fd5722fec23977260f6e81aa67d2f22cadbdc2aa049f1022d9a3be1566" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[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.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5454462c0eced1e97f2ec09036abc8da362e66802f66fd20f86854d9d8cbcbc4" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "paste" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "polling" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22122d5ec4f9fe1b3916419b76be1e80bcb93f618d071d2edf841b137b2a2bd6" +dependencies = [ + "autocfg", + "cfg-if", + "libc", + "log", + "wepoll-ffi", + "windows-sys 0.42.0", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d89e5dba24725ae5678020bf8f1357a9aa7ff10736b551adbcd3f8d17d766f" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d0f47a940e895261e77dc200d5eadfc6ef644c179c6f5edfc105e3a2292c8" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "ryu" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" + +[[package]] +name = "schannel" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +dependencies = [ + "lazy_static", + "windows-sys 0.36.1", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" + +[[package]] +name = "security-framework" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fed41fc1a24994d044e6db6935e69511a1153b52c15eb42493b26fa87feba0" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8778cc0b528968fe72abec38b5db5a20a70d148116cd9325d2bc5f5180ca3faf" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signal-hook" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "sqlformat" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87e292b4291f154971a43c3774364e2cbcaec599d3f5bf6fa9d122885dbc38a" +dependencies = [ + "itertools", + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9249290c05928352f71c077cc44a464d880c63f26f7534728cca008e135c0428" +dependencies = [ + "sqlx-core", + "sqlx-macros", +] + +[[package]] +name = "sqlx-core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbc16ddba161afc99e14d1713a453747a2b07fc097d2009f4c300ec99286105" +dependencies = [ + "ahash", + "atoi", + "base64", + "bitflags", + "byteorder", + "bytes", + "crc", + "crossbeam-queue", + "dirs", + "dotenvy", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-util", + "hashlink", + "hex", + "hkdf", + "hmac", + "indexmap", + "itoa", + "libc", + "log", + "md-5", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "rand", + "serde", + "serde_json", + "sha1", + "sha2", + "smallvec", + "sqlformat", + "sqlx-rt", + "stringprep", + "thiserror", + "url", + "whoami", +] + +[[package]] +name = "sqlx-macros" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b850fa514dc11f2ee85be9d055c512aa866746adfacd1cb42d867d68e6a5b0d9" +dependencies = [ + "dotenvy", + "either", + "heck", + "once_cell", + "proc-macro2", + "quote", + "sha2", + "sqlx-core", + "sqlx-rt", + "syn", + "url", +] + +[[package]] +name = "sqlx-rt" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24c5b2d25fa654cc5f841750b8e1cdedbe21189bf9a9382ee90bfa9dd3562396" +dependencies = [ + "async-native-tls", + "async-std", + "native-tls", +] + +[[package]] +name = "stringprep" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ee3a69cd2c7e06684677e5629b3878b253af05e4714964204279c6bc02cf0b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "techempower" +version = "0.1.0" +dependencies = [ + "ohkami", + "rand", + "serde", + "sqlx", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" +dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "value-bag" +version = "1.0.0-alpha.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" +dependencies = [ + "ctor", + "version_check", +] + +[[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 = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "web-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wepoll-ffi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +dependencies = [ + "cc", +] + +[[package]] +name = "whoami" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6631b6a2fd59b1841b622e8f1a7ad241ef0a46f2d580464ce8140ac94cbd571" +dependencies = [ + "bumpalo", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" diff --git a/frameworks/Rust/ohkami/Cargo.toml b/frameworks/Rust/ohkami/Cargo.toml new file mode 100644 index 00000000000..45570a4a8f3 --- /dev/null +++ b/frameworks/Rust/ohkami/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "techempower" +version = "0.1.0" +edition = "2021" + +[dependencies] +ohkami = { version = "0.3", features = ["sqlx", "postgres"] } +serde = { versoin = "1.0", features = ["derive"] } +sqlx = "0.6" +rand = "0.8.5" \ No newline at end of file diff --git a/frameworks/Rust/ohkami/README.md b/frameworks/Rust/ohkami/README.md new file mode 100644 index 00000000000..ac9d04d9269 --- /dev/null +++ b/frameworks/Rust/ohkami/README.md @@ -0,0 +1,15 @@ +# [ohkami](https://github.com/kana-rus/ohkami) web framework + +## Description +ohkami is simple and macro free web framework. + +## Database +- PostgreSQL + +## Test URLs +- JSON Encoding: [http://localhost:8080/json](http://localhost:8080/json) +- Single Row Query: [http://localhost:8080/db](http://localhost:8080/db) +- Multi Row Query: [http://localhost:8080/queries?q=20](http://localhost:8080/queries?q=20) +- Fortunes: [http://localhost:8080/fortune](http://localhost:8080/fortune) +- Update Query: [http://localhost:8080/updates?q=20](http://localhost:8080/updates?q=20) +- Plaintext: [http://localhost:8080/plaintext](http://localhost:8080/plaintext) \ No newline at end of file diff --git a/frameworks/Rust/ohkami/benchmark_config.json b/frameworks/Rust/ohkami/benchmark_config.json new file mode 100644 index 00000000000..69fa09b55e1 --- /dev/null +++ b/frameworks/Rust/ohkami/benchmark_config.json @@ -0,0 +1,27 @@ +{ + "framework": "ohkami", + "tests": [ + { + "default": { + "json_url": "/json", + "plaintext_url": "/plaintext", + "fortune_url": "/fortune", + "db_url": "/db", + "query_url": "/queries?q=", + "update_url": "/updates?q=", + "port": 8080, + "approach": "Realistic", + "classification": "Micro", + "database": "Postgres", + "framework": "ohkami", + "language": "Rust", + "orm": "Raw", + "platform": "Rust", + "webserver": "ohkami", + "os": "Linux", + "database_os": "Linux", + "display_name": "ohkami" + } + } + ] +} \ No newline at end of file diff --git a/frameworks/Rust/ohkami/ohkami.dockerfile b/frameworks/Rust/ohkami/ohkami.dockerfile new file mode 100644 index 00000000000..ccecec92039 --- /dev/null +++ b/frameworks/Rust/ohkami/ohkami.dockerfile @@ -0,0 +1,13 @@ +FROM rust:1.65 + +RUN apt update -yqq \ + && apt install -yqq cmake g++ + +ADD ./ /ohkami +WORKDIR /ohkami + +RUN cargo clean \ + && RUSTFLAGS="-C target-cpu=native" cargo build --release + +EXPOSE 8080 +CMD ./target/release/ohkami \ No newline at end of file diff --git a/frameworks/Rust/ohkami/src/components.rs b/frameworks/Rust/ohkami/src/components.rs new file mode 100644 index 00000000000..eb178f772ff --- /dev/null +++ b/frameworks/Rust/ohkami/src/components.rs @@ -0,0 +1,50 @@ +pub(crate) mod consts { + use std::ops::RangeInclusive; + + pub const RAND_RANGE: RangeInclusive = 1..=10000; + pub const DB_URL: &'static str = "postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world?sslmode=disable"; + pub const MAX_CONNECTIONS: u32 = 10000; +} + +pub(crate) mod models { + use serde::Serialize; + use sqlx::FromRow; + + #[derive(FromRow, Serialize)] + pub struct World { + id: i32, + randomnumber: i32, + } + #[derive(FromRow, Serialize)] + pub struct Fortune { + pub id: i32, + pub message: String, + } +} + +pub(crate) mod functions { + use rand::Rng; + use ohkami::response::Body; + use super::{models::Fortune, consts::RAND_RANGE}; + + pub fn random_i32() -> i32 { + rand::thread_rng().gen_range(RAND_RANGE) as i32 + } + pub fn random_i32s(n: usize) -> std::vec::IntoIter { + let mut generator = rand::thread_rng(); + let mut i32s = Vec::with_capacity(n); + for _ in 0..n { + i32s.push(generator.gen_range(RAND_RANGE) as i32) + } + i32s.into_iter() + } + pub fn html_from(fortunes: Vec) -> Body { + Body::text_html(fortunes + .into_iter() + .fold( + String::from("Fortunes"), + |it, next| it + &format!("", next.id, next.message) + ) + "
idmessage
{}{}
" + ) + } +} diff --git a/frameworks/Rust/ohkami/src/main.rs b/frameworks/Rust/ohkami/src/main.rs new file mode 100644 index 00000000000..383590d154d --- /dev/null +++ b/frameworks/Rust/ohkami/src/main.rs @@ -0,0 +1,88 @@ +use ohkami::{prelude::*, json}; +use sqlx::postgres::PgPoolOptions; +mod components; use components::{ + consts::{DB_URL, MAX_CONNECTIONS}, + models::{World, Fortune}, + functions::{random_i32, random_i32s, html_from}, +}; + +fn main() -> Result<()> { + let config = Config { + db_profile: DBprofile { + pool_options: PgPoolOptions::new().max_connections(MAX_CONNECTIONS), + url: DB_URL, + }, + ..Default::default() + }; + + Server::setup_with(config) + .GET("/json", || async {Response::OK(json!("message": "Hello, World!"))}) + .GET("/plaintext", || async {Response::OK("Hello, World!")}) + .GET("/db", handle_db) + .GET("/fortunes", handle_fortunes) + .GET("/queries", handle_queries) + .GET("/updates", handle_updates) + .serve_on(":8080") +} + +async fn handle_db(ctx: Context) -> Result { + let id = random_i32(); + let world = sqlx::query_as::<_, World>( + "SELECT id, randomnumber FROM world WHERE id = $1" + ).bind(id) + .fetch_one(ctx.pool()) + .await?; + Response::OK(json(&world)?) +} + +async fn handle_fortunes(ctx: Context) -> Result { + let mut fortunes = sqlx::query_as::<_, Fortune>( + "SELECT id, message FROM fortune" + ) + .fetch_all(ctx.pool()) + .await?; + fortunes.push(Fortune { + id: 0, + message: "Additional fortune added at request time.".into(), + }); + fortunes.sort_unstable_by(|it, next| it.message.cmp(&next.message)); + Response::OK(html_from(fortunes)) +} + +async fn handle_queries(ctx: Context) -> Result { + let count = { + let queries = ctx.query::<&str>("q").unwrap_or("1").parse::().unwrap_or(1); + if queries < 1 {1} else if 500 < queries {500} else {queries} + }; + let mut worlds = Vec::with_capacity(count); + for id in random_i32s(count) { + worlds.push( + sqlx::query_as::<_, World>( + "SELECT id, randomnumber FROM world WHERE id = $1" + ).bind(id) + .fetch_one(ctx.pool()) + .await? + ) + } + Response::OK(json(&worlds)?) +} + +async fn handle_updates(ctx: Context) -> Result { + let count = { + let queries = ctx.query::<&str>("q").unwrap_or("1").parse::().unwrap_or(1); + if queries < 1 {1} else if 500 < queries {500} else {queries} + }; + let mut worlds = Vec::with_capacity(count); + let mut new_randomnumbers = random_i32s(count); + for id in random_i32s(count) { + let randomnumber = new_randomnumbers.next().unwrap(); + worlds.push( + sqlx::query_as::<_, World>( + "UPDATE world SET randomnumber = $1 WHERE id = $2 RETURNUNG id, randomnumber" + ).bind(randomnumber).bind(id) + .fetch_one(ctx.pool()) + .await? + ) + } + Response::OK(json(&worlds)?) +} From 80a3a3a69a0c0127a79b839df61c5b289b31efbf Mon Sep 17 00:00:00 2001 From: kana-rus Date: Wed, 21 Dec 2022 18:57:52 +0900 Subject: [PATCH 02/10] Update: 0.3.2 -> 0.3.3 --- frameworks/Rust/ohkami/Cargo.lock | 45 ++++++++++--------- frameworks/Rust/ohkami/Cargo.toml | 2 +- frameworks/Rust/ohkami/README.md | 15 ------- frameworks/Rust/ohkami/src/main.rs | 6 +-- .../ohkami/src/{components.rs => utils.rs} | 2 +- 5 files changed, 28 insertions(+), 42 deletions(-) delete mode 100644 frameworks/Rust/ohkami/README.md rename frameworks/Rust/ohkami/src/{components.rs => utils.rs} (97%) diff --git a/frameworks/Rust/ohkami/Cargo.lock b/frameworks/Rust/ohkami/Cargo.lock index 1224acf4777..1a38c29894c 100644 --- a/frameworks/Rust/ohkami/Cargo.lock +++ b/frameworks/Rust/ohkami/Cargo.lock @@ -356,9 +356,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27874566aca772cb515af4c6e997b5fe2119820bca447689145e39bb734d19a0" +checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" dependencies = [ "cc", "cxxbridge-flags", @@ -368,9 +368,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb951f2523a49533003656a72121306b225ec16a49a09dc6b0ba0d6f3ec3c0" +checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" dependencies = [ "cc", "codespan-reporting", @@ -383,15 +383,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be778b6327031c1c7b61dd2e48124eee5361e6aa76b8de93692f011b08870ab4" +checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" [[package]] name = "cxxbridge-macro" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b8a2b87662fe5a0a0b38507756ab66aff32638876a0866e5a5fc82ceb07ee49" +checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" dependencies = [ "proc-macro2", "quote", @@ -859,8 +859,9 @@ dependencies = [ [[package]] name = "ohkami" -version = "0.1.10" -source = "git+https://github.com/kana-rus/ohkami#d9c03f6debf6925491282848d032de14bf16c45c" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5865b230c6e90ca5146fc32495d8e6fc601756727affb1567d0a9d0096de6c0" dependencies = [ "async-std", "chrono", @@ -879,9 +880,9 @@ checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "openssl" -version = "0.10.44" +version = "0.10.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d971fd5722fec23977260f6e81aa67d2f22cadbdc2aa049f1022d9a3be1566" +checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" dependencies = [ "bitflags", "cfg-if", @@ -911,9 +912,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.79" +version = "0.9.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5454462c0eced1e97f2ec09036abc8da362e66802f66fd20f86854d9d8cbcbc4" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" dependencies = [ "autocfg", "cc", @@ -1011,18 +1012,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d89e5dba24725ae5678020bf8f1357a9aa7ff10736b551adbcd3f8d17d766f" +checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d0f47a940e895261e77dc200d5eadfc6ef644c179c6f5edfc105e3a2292c8" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] @@ -1159,9 +1160,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8778cc0b528968fe72abec38b5db5a20a70d148116cd9325d2bc5f5180ca3faf" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" dependencies = [ "itoa", "ryu", @@ -1361,9 +1362,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ee3a69cd2c7e06684677e5629b3878b253af05e4714964204279c6bc02cf0b" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", diff --git a/frameworks/Rust/ohkami/Cargo.toml b/frameworks/Rust/ohkami/Cargo.toml index 45570a4a8f3..a476c148b00 100644 --- a/frameworks/Rust/ohkami/Cargo.toml +++ b/frameworks/Rust/ohkami/Cargo.toml @@ -5,6 +5,6 @@ edition = "2021" [dependencies] ohkami = { version = "0.3", features = ["sqlx", "postgres"] } -serde = { versoin = "1.0", features = ["derive"] } +serde = { version = "1.0", features = ["derive"] } sqlx = "0.6" rand = "0.8.5" \ No newline at end of file diff --git a/frameworks/Rust/ohkami/README.md b/frameworks/Rust/ohkami/README.md deleted file mode 100644 index ac9d04d9269..00000000000 --- a/frameworks/Rust/ohkami/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# [ohkami](https://github.com/kana-rus/ohkami) web framework - -## Description -ohkami is simple and macro free web framework. - -## Database -- PostgreSQL - -## Test URLs -- JSON Encoding: [http://localhost:8080/json](http://localhost:8080/json) -- Single Row Query: [http://localhost:8080/db](http://localhost:8080/db) -- Multi Row Query: [http://localhost:8080/queries?q=20](http://localhost:8080/queries?q=20) -- Fortunes: [http://localhost:8080/fortune](http://localhost:8080/fortune) -- Update Query: [http://localhost:8080/updates?q=20](http://localhost:8080/updates?q=20) -- Plaintext: [http://localhost:8080/plaintext](http://localhost:8080/plaintext) \ No newline at end of file diff --git a/frameworks/Rust/ohkami/src/main.rs b/frameworks/Rust/ohkami/src/main.rs index 383590d154d..a21f8e0687c 100644 --- a/frameworks/Rust/ohkami/src/main.rs +++ b/frameworks/Rust/ohkami/src/main.rs @@ -1,6 +1,6 @@ use ohkami::{prelude::*, json}; use sqlx::postgres::PgPoolOptions; -mod components; use components::{ +mod utils; use utils::{ consts::{DB_URL, MAX_CONNECTIONS}, models::{World, Fortune}, functions::{random_i32, random_i32s, html_from}, @@ -19,7 +19,7 @@ fn main() -> Result<()> { .GET("/json", || async {Response::OK(json!("message": "Hello, World!"))}) .GET("/plaintext", || async {Response::OK("Hello, World!")}) .GET("/db", handle_db) - .GET("/fortunes", handle_fortunes) + .GET("/fortune", handle_fortune) .GET("/queries", handle_queries) .GET("/updates", handle_updates) .serve_on(":8080") @@ -35,7 +35,7 @@ async fn handle_db(ctx: Context) -> Result { Response::OK(json(&world)?) } -async fn handle_fortunes(ctx: Context) -> Result { +async fn handle_fortune(ctx: Context) -> Result { let mut fortunes = sqlx::query_as::<_, Fortune>( "SELECT id, message FROM fortune" ) diff --git a/frameworks/Rust/ohkami/src/components.rs b/frameworks/Rust/ohkami/src/utils.rs similarity index 97% rename from frameworks/Rust/ohkami/src/components.rs rename to frameworks/Rust/ohkami/src/utils.rs index eb178f772ff..eef18dcd419 100644 --- a/frameworks/Rust/ohkami/src/components.rs +++ b/frameworks/Rust/ohkami/src/utils.rs @@ -23,8 +23,8 @@ pub(crate) mod models { } pub(crate) mod functions { + use ohkami::prelude::Body; use rand::Rng; - use ohkami::response::Body; use super::{models::Fortune, consts::RAND_RANGE}; pub fn random_i32() -> i32 { From a4a9ed63cb9b9c41032c4b5a80063303f233bea6 Mon Sep 17 00:00:00 2001 From: kana-rus Date: Wed, 21 Dec 2022 19:07:54 +0900 Subject: [PATCH 03/10] Fix: Cargo.toml --- frameworks/Rust/ohkami/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/Rust/ohkami/Cargo.toml b/frameworks/Rust/ohkami/Cargo.toml index a476c148b00..da9ddf15913 100644 --- a/frameworks/Rust/ohkami/Cargo.toml +++ b/frameworks/Rust/ohkami/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "techempower" +name = "ohkami" version = "0.1.0" edition = "2021" From 0f499da42b478cbb7f7539193498e5fbf1affd64 Mon Sep 17 00:00:00 2001 From: kana-rus Date: Wed, 21 Dec 2022 19:22:42 +0900 Subject: [PATCH 04/10] Fix: typo --- frameworks/Rust/ohkami/Cargo.lock | 20 ++++++++++---------- frameworks/Rust/ohkami/src/main.rs | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frameworks/Rust/ohkami/Cargo.lock b/frameworks/Rust/ohkami/Cargo.lock index 1a38c29894c..be1562c9da0 100644 --- a/frameworks/Rust/ohkami/Cargo.lock +++ b/frameworks/Rust/ohkami/Cargo.lock @@ -857,6 +857,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "ohkami" +version = "0.1.0" +dependencies = [ + "ohkami 0.3.3", + "rand", + "serde", + "sqlx", +] + [[package]] name = "ohkami" version = "0.3.3" @@ -1371,16 +1381,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "techempower" -version = "0.1.0" -dependencies = [ - "ohkami", - "rand", - "serde", - "sqlx", -] - [[package]] name = "tempfile" version = "3.3.0" diff --git a/frameworks/Rust/ohkami/src/main.rs b/frameworks/Rust/ohkami/src/main.rs index a21f8e0687c..ce9fb0eacea 100644 --- a/frameworks/Rust/ohkami/src/main.rs +++ b/frameworks/Rust/ohkami/src/main.rs @@ -78,7 +78,7 @@ async fn handle_updates(ctx: Context) -> Result { let randomnumber = new_randomnumbers.next().unwrap(); worlds.push( sqlx::query_as::<_, World>( - "UPDATE world SET randomnumber = $1 WHERE id = $2 RETURNUNG id, randomnumber" + "UPDATE world SET randomnumber = $1 WHERE id = $2 RETURNING id, randomnumber" ).bind(randomnumber).bind(id) .fetch_one(ctx.pool()) .await? From 86b7398cd10959ce356d91987b6ea779cabd0197 Mon Sep 17 00:00:00 2001 From: kana-rus Date: Wed, 21 Dec 2022 19:38:37 +0900 Subject: [PATCH 05/10] Fix: ohkami --- frameworks/Rust/ohkami/.gitignore | 1 + frameworks/Rust/ohkami/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 frameworks/Rust/ohkami/.gitignore diff --git a/frameworks/Rust/ohkami/.gitignore b/frameworks/Rust/ohkami/.gitignore new file mode 100644 index 00000000000..c41cc9e35e3 --- /dev/null +++ b/frameworks/Rust/ohkami/.gitignore @@ -0,0 +1 @@ +/target \ No newline at end of file diff --git a/frameworks/Rust/ohkami/Cargo.toml b/frameworks/Rust/ohkami/Cargo.toml index da9ddf15913..745e0fae43e 100644 --- a/frameworks/Rust/ohkami/Cargo.toml +++ b/frameworks/Rust/ohkami/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ohkami = { version = "0.3", features = ["sqlx", "postgres"] } +ohkami = { git = "https://github.com/kana-rus/ohkami", features = ["sqlx", "postgres"] } serde = { version = "1.0", features = ["derive"] } sqlx = "0.6" rand = "0.8.5" \ No newline at end of file From 854f8cbe9080c138301e64df6c6fbf6789a6633e Mon Sep 17 00:00:00 2001 From: kana-rus Date: Wed, 21 Dec 2022 19:42:28 +0900 Subject: [PATCH 06/10] Change: -> log_subscribe: None --- frameworks/Rust/ohkami/Cargo.lock | 3 +-- frameworks/Rust/ohkami/src/main.rs | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/Rust/ohkami/Cargo.lock b/frameworks/Rust/ohkami/Cargo.lock index be1562c9da0..b80b9848049 100644 --- a/frameworks/Rust/ohkami/Cargo.lock +++ b/frameworks/Rust/ohkami/Cargo.lock @@ -870,8 +870,7 @@ dependencies = [ [[package]] name = "ohkami" version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5865b230c6e90ca5146fc32495d8e6fc601756727affb1567d0a9d0096de6c0" +source = "git+https://github.com/kana-rus/ohkami#c5f609c97fe610e4daef2c8263e3bb43348efc29" dependencies = [ "async-std", "chrono", diff --git a/frameworks/Rust/ohkami/src/main.rs b/frameworks/Rust/ohkami/src/main.rs index ce9fb0eacea..e42f89a7cd0 100644 --- a/frameworks/Rust/ohkami/src/main.rs +++ b/frameworks/Rust/ohkami/src/main.rs @@ -12,6 +12,7 @@ fn main() -> Result<()> { pool_options: PgPoolOptions::new().max_connections(MAX_CONNECTIONS), url: DB_URL, }, + log_subscribe: None, ..Default::default() }; From 3ab793d0c610e70e591e2f133e6634ca4d6e0217 Mon Sep 17 00:00:00 2001 From: kana-rus Date: Wed, 21 Dec 2022 19:57:31 +0900 Subject: [PATCH 07/10] Add: README --- frameworks/Rust/ohkami/README.md | 15 +++++++++++++++ frameworks/Rust/ohkami/benchmark_config.json | 2 +- frameworks/Rust/ohkami/src/main.rs | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 frameworks/Rust/ohkami/README.md diff --git a/frameworks/Rust/ohkami/README.md b/frameworks/Rust/ohkami/README.md new file mode 100644 index 00000000000..e234565d4b4 --- /dev/null +++ b/frameworks/Rust/ohkami/README.md @@ -0,0 +1,15 @@ +# [ohkami](https://github.com/kana-rus/ohkami) web framework + +## Description +ohkami is **simple** and **macro free** wen framework. + +## Database +- PostgreSQL + +## Test URLs +- JSON Encoding: [http://localhost:8080/json](http://localhost:8080/json) +- Single Row Query: [http://localhost:8080/db](http://localhost:8080/db) +- Multi Row Query: [http://localhost:8080/queries](http://localhost:8080/queries) +- Fortunes: [http://localhost:8080/fortunes](http://localhost:8080/fortunes) +- Update Query: [http://localhost:8080/updates](http://localhost:8080/updates) +- Plaintext: [http://localhost:8080/plaintext](http://localhost:8080/plaintext) \ No newline at end of file diff --git a/frameworks/Rust/ohkami/benchmark_config.json b/frameworks/Rust/ohkami/benchmark_config.json index 69fa09b55e1..b80c54f8be3 100644 --- a/frameworks/Rust/ohkami/benchmark_config.json +++ b/frameworks/Rust/ohkami/benchmark_config.json @@ -5,7 +5,7 @@ "default": { "json_url": "/json", "plaintext_url": "/plaintext", - "fortune_url": "/fortune", + "fortune_url": "/fortunes", "db_url": "/db", "query_url": "/queries?q=", "update_url": "/updates?q=", diff --git a/frameworks/Rust/ohkami/src/main.rs b/frameworks/Rust/ohkami/src/main.rs index e42f89a7cd0..603b60ff48c 100644 --- a/frameworks/Rust/ohkami/src/main.rs +++ b/frameworks/Rust/ohkami/src/main.rs @@ -20,7 +20,7 @@ fn main() -> Result<()> { .GET("/json", || async {Response::OK(json!("message": "Hello, World!"))}) .GET("/plaintext", || async {Response::OK("Hello, World!")}) .GET("/db", handle_db) - .GET("/fortune", handle_fortune) + .GET("/fortunes", handle_fortunes) .GET("/queries", handle_queries) .GET("/updates", handle_updates) .serve_on(":8080") @@ -36,7 +36,7 @@ async fn handle_db(ctx: Context) -> Result { Response::OK(json(&world)?) } -async fn handle_fortune(ctx: Context) -> Result { +async fn handle_fortunes(ctx: Context) -> Result { let mut fortunes = sqlx::query_as::<_, Fortune>( "SELECT id, message FROM fortune" ) From 3157d88208c440c10ded9a0461cc12a4c078f8e0 Mon Sep 17 00:00:00 2001 From: kana-rus Date: Wed, 21 Dec 2022 20:10:42 +0900 Subject: [PATCH 08/10] Fix: not to use `RETURNING` --- .../ohkami/src/{utils.rs => components.rs} | 4 +++ frameworks/Rust/ohkami/src/main.rs | 26 ++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) rename frameworks/Rust/ohkami/src/{utils.rs => components.rs} (91%) diff --git a/frameworks/Rust/ohkami/src/utils.rs b/frameworks/Rust/ohkami/src/components.rs similarity index 91% rename from frameworks/Rust/ohkami/src/utils.rs rename to frameworks/Rust/ohkami/src/components.rs index eef18dcd419..e6bf88a7844 100644 --- a/frameworks/Rust/ohkami/src/utils.rs +++ b/frameworks/Rust/ohkami/src/components.rs @@ -14,6 +14,10 @@ pub(crate) mod models { pub struct World { id: i32, randomnumber: i32, + } impl World { + pub fn set_randomnumber(&mut self, new_randomnumber: i32) { + self.randomnumber = new_randomnumber + } } #[derive(FromRow, Serialize)] pub struct Fortune { diff --git a/frameworks/Rust/ohkami/src/main.rs b/frameworks/Rust/ohkami/src/main.rs index 603b60ff48c..b473b241960 100644 --- a/frameworks/Rust/ohkami/src/main.rs +++ b/frameworks/Rust/ohkami/src/main.rs @@ -1,6 +1,6 @@ use ohkami::{prelude::*, json}; use sqlx::postgres::PgPoolOptions; -mod utils; use utils::{ +mod components; use components::{ consts::{DB_URL, MAX_CONNECTIONS}, models::{World, Fortune}, functions::{random_i32, random_i32s, html_from}, @@ -76,14 +76,22 @@ async fn handle_updates(ctx: Context) -> Result { let mut worlds = Vec::with_capacity(count); let mut new_randomnumbers = random_i32s(count); for id in random_i32s(count) { - let randomnumber = new_randomnumbers.next().unwrap(); - worlds.push( - sqlx::query_as::<_, World>( - "UPDATE world SET randomnumber = $1 WHERE id = $2 RETURNING id, randomnumber" - ).bind(randomnumber).bind(id) - .fetch_one(ctx.pool()) - .await? - ) + let mut world = sqlx::query_as::<_, World>( + "SELECT id, randomnumber FROM world WHERE id = $1" + ).bind(id) + .fetch_one(ctx.pool()) + .await?; + + let new_randomnumber = new_randomnumbers.next().unwrap(); + world.set_randomnumber(new_randomnumber); + + sqlx::query("UPDATE world SET randomnumber = $1 WHERE id = $2") + .bind(new_randomnumber) + .bind(id) + .execute(ctx.pool()) + .await?; + + worlds.push(world) } Response::OK(json(&worlds)?) } From 17cca97354c874cba8a9a1d414ce0efa3a6f436c Mon Sep 17 00:00:00 2001 From: kana-rus Date: Wed, 21 Dec 2022 21:03:20 +0900 Subject: [PATCH 09/10] Fix: to use yarte --- frameworks/Rust/ohkami/Cargo.lock | 212 ++++++++++++++++++ frameworks/Rust/ohkami/Cargo.toml | 3 +- frameworks/Rust/ohkami/src/components.rs | 26 ++- frameworks/Rust/ohkami/src/main.rs | 4 +- frameworks/Rust/ohkami/templates/fortunes.hbs | 5 + 5 files changed, 237 insertions(+), 13 deletions(-) create mode 100644 frameworks/Rust/ohkami/templates/fortunes.hbs diff --git a/frameworks/Rust/ohkami/Cargo.lock b/frameworks/Rust/ohkami/Cargo.lock index b80b9848049..18c5df4f61b 100644 --- a/frameworks/Rust/ohkami/Cargo.lock +++ b/frameworks/Rust/ohkami/Cargo.lock @@ -13,6 +13,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + [[package]] name = "android_system_properties" version = "0.1.5" @@ -22,6 +31,16 @@ dependencies = [ "libc", ] +[[package]] +name = "annotate-snippets" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3b9d411ecbaf79885c6df4d75fff75858d5995ff25385657a28af47e82f9c36" +dependencies = [ + "unicode-width", + "yansi-term", +] + [[package]] name = "async-channel" version = "1.8.0" @@ -275,6 +294,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "core-foundation" version = "0.9.3" @@ -398,6 +423,19 @@ dependencies = [ "syn", ] +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + [[package]] name = "digest" version = "0.10.6" @@ -435,6 +473,12 @@ version = "0.15.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0" +[[package]] +name = "dtoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c00704156a7de8df8da0911424e30c2049957b0a714542a44e05fe693dd85313" + [[package]] name = "either" version = "1.8.0" @@ -865,6 +909,7 @@ dependencies = [ "rand", "serde", "sqlx", + "yarte", ] [[package]] @@ -1019,6 +1064,16 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prettyplease" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c8992a85d8e93a28bdf76137db888d3874e3b230dee5ed8bebac4c9f7617773" +dependencies = [ + "proc-macro2", + "syn", +] + [[package]] name = "proc-macro2" version = "1.0.49" @@ -1087,6 +1142,23 @@ dependencies = [ "thiserror", ] +[[package]] +name = "regex" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + [[package]] name = "remove_dir_all" version = "0.5.3" @@ -1096,6 +1168,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "ryu" version = "1.0.12" @@ -1147,6 +1228,12 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" + [[package]] name = "serde" version = "1.0.151" @@ -1458,6 +1545,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "toml" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" +dependencies = [ + "serde", +] + [[package]] name = "tracing" version = "0.1.37" @@ -1555,6 +1651,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "unicode_categories" version = "0.1.1" @@ -1572,6 +1674,22 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "v_eval" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd8b599d797eb038d0dde9a3860aacb6bbba3bffa4ac64f807c8673820cc9d9" +dependencies = [ + "regex", + "syn", +] + +[[package]] +name = "v_htmlescape" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c" + [[package]] name = "valuable" version = "0.1.0" @@ -1844,3 +1962,97 @@ name = "windows_x86_64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + +[[package]] +name = "yansi-term" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1" +dependencies = [ + "winapi", +] + +[[package]] +name = "yarte" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfce1df93f3b16e5272221a559e60bbbaaa71dbc042a43996d223e51a690aab2" +dependencies = [ + "yarte_derive", + "yarte_helpers", +] + +[[package]] +name = "yarte_codegen" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1cf72076dbf4d39fe4779b58380d7213dcb3995d00666dd2d109f1b45879ea4" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "yarte_helpers", + "yarte_hir", +] + +[[package]] +name = "yarte_derive" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b296edd7e1a81717b6f794baa2de8dfe89646050847161550b2d963b3ca6fe80" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "yarte_codegen", + "yarte_helpers", + "yarte_hir", + "yarte_parser", +] + +[[package]] +name = "yarte_helpers" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dfe1ef3558dde14b4be5387bdd41e3bd45746570743521470ec3e9cd0826679" +dependencies = [ + "dtoa", + "itoa", + "prettyplease", + "serde", + "syn", + "toml", + "v_htmlescape", +] + +[[package]] +name = "yarte_hir" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee42d2f704a3b1d8bc111d47a705d1302a0943d85e4c230f4e8300ee0dde4a6" +dependencies = [ + "derive_more", + "proc-macro2", + "quote", + "syn", + "v_eval", + "v_htmlescape", + "yarte_helpers", + "yarte_parser", +] + +[[package]] +name = "yarte_parser" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "538f72049cf7104e12d5c444048d112cb8fc788a31308afd912442a381ba860c" +dependencies = [ + "annotate-snippets", + "derive_more", + "proc-macro2", + "quote", + "serde", + "syn", + "unicode-xid", + "yarte_helpers", +] diff --git a/frameworks/Rust/ohkami/Cargo.toml b/frameworks/Rust/ohkami/Cargo.toml index 745e0fae43e..a58fe838621 100644 --- a/frameworks/Rust/ohkami/Cargo.toml +++ b/frameworks/Rust/ohkami/Cargo.toml @@ -7,4 +7,5 @@ edition = "2021" ohkami = { git = "https://github.com/kana-rus/ohkami", features = ["sqlx", "postgres"] } serde = { version = "1.0", features = ["derive"] } sqlx = "0.6" -rand = "0.8.5" \ No newline at end of file +rand = "0.8.5" +yarte = "0.15" \ No newline at end of file diff --git a/frameworks/Rust/ohkami/src/components.rs b/frameworks/Rust/ohkami/src/components.rs index e6bf88a7844..7fab61e573b 100644 --- a/frameworks/Rust/ohkami/src/components.rs +++ b/frameworks/Rust/ohkami/src/components.rs @@ -9,6 +9,7 @@ pub(crate) mod consts { pub(crate) mod models { use serde::Serialize; use sqlx::FromRow; + use yarte::Template; #[derive(FromRow, Serialize)] pub struct World { @@ -19,17 +20,24 @@ pub(crate) mod models { self.randomnumber = new_randomnumber } } + #[derive(FromRow, Serialize)] pub struct Fortune { pub id: i32, pub message: String, } + #[derive(Template)] + #[template(path = "fortunes.hbs")] + pub(crate) struct FortunesTemplate { + pub(crate) fortunes: Vec + } } pub(crate) mod functions { - use ohkami::prelude::Body; + use ohkami::{prelude::Body, result::{Result, ElseResponseWithErr}, response::Response}; use rand::Rng; - use super::{models::Fortune, consts::RAND_RANGE}; + use yarte::Template; + use super::{models::{Fortune, FortunesTemplate}, consts::RAND_RANGE}; pub fn random_i32() -> i32 { rand::thread_rng().gen_range(RAND_RANGE) as i32 @@ -42,13 +50,11 @@ pub(crate) mod functions { } i32s.into_iter() } - pub fn html_from(fortunes: Vec) -> Body { - Body::text_html(fortunes - .into_iter() - .fold( - String::from("Fortunes"), - |it, next| it + &format!("", next.id, next.message) - ) + "
idmessage
{}{}
" - ) + pub fn render_html(fortunes: Vec) -> Result { + Response::OK(Body::html( + FortunesTemplate {fortunes} + .call() + ._else(|_| Response::InternalServerError("failed to render template"))? + )) } } diff --git a/frameworks/Rust/ohkami/src/main.rs b/frameworks/Rust/ohkami/src/main.rs index b473b241960..de77651f067 100644 --- a/frameworks/Rust/ohkami/src/main.rs +++ b/frameworks/Rust/ohkami/src/main.rs @@ -3,7 +3,7 @@ use sqlx::postgres::PgPoolOptions; mod components; use components::{ consts::{DB_URL, MAX_CONNECTIONS}, models::{World, Fortune}, - functions::{random_i32, random_i32s, html_from}, + functions::{random_i32, random_i32s, render_html}, }; fn main() -> Result<()> { @@ -47,7 +47,7 @@ async fn handle_fortunes(ctx: Context) -> Result { message: "Additional fortune added at request time.".into(), }); fortunes.sort_unstable_by(|it, next| it.message.cmp(&next.message)); - Response::OK(html_from(fortunes)) + render_html(fortunes) } async fn handle_queries(ctx: Context) -> Result { diff --git a/frameworks/Rust/ohkami/templates/fortunes.hbs b/frameworks/Rust/ohkami/templates/fortunes.hbs new file mode 100644 index 00000000000..988cf4fbe93 --- /dev/null +++ b/frameworks/Rust/ohkami/templates/fortunes.hbs @@ -0,0 +1,5 @@ +Fortunes + {{~# each fortunes ~}} + + {{~/each ~}} +
idmessage
{{id}}{{message}}
\ No newline at end of file From 4f7130ba6c963a407e7f7bdec774c68bfce541e0 Mon Sep 17 00:00:00 2001 From: kana-rus Date: Thu, 22 Dec 2022 17:12:48 +0900 Subject: [PATCH 10/10] Fix: to specify version 0.3.3 --- frameworks/Rust/ohkami/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/Rust/ohkami/Cargo.toml b/frameworks/Rust/ohkami/Cargo.toml index a58fe838621..a521a7b4f08 100644 --- a/frameworks/Rust/ohkami/Cargo.toml +++ b/frameworks/Rust/ohkami/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2021" [dependencies] -ohkami = { git = "https://github.com/kana-rus/ohkami", features = ["sqlx", "postgres"] } +ohkami = { version = "0.3.3", features = ["sqlx", "postgres"] } serde = { version = "1.0", features = ["derive"] } sqlx = "0.6" rand = "0.8.5" -yarte = "0.15" \ No newline at end of file +yarte = "0.15"