From 8af6881d3e92e4bcbc445d8b0fd1b0a69f25f5a3 Mon Sep 17 00:00:00 2001 From: Shautvast Date: Wed, 3 Jul 2024 13:23:57 +0200 Subject: [PATCH] added rest api --- .../github/shautvast/exceptional/Agent.java | 2 +- api/.gitignore | 1 + api/Cargo.lock | 1434 +++++++++++++++++ api/Cargo.toml | 34 + api/migrations/.keep | 0 .../down.sql | 6 + .../up.sql | 36 + .../2023-08-31-140536_create_posts/down.sql | 1 + .../2023-08-31-140536_create_posts/up.sql | 6 + api/pom.xml | 41 + api/src/config.rs | 61 + api/src/domain/mod.rs | 1 + api/src/domain/models/mod.rs | 1 + api/src/domain/models/post.rs | 54 + api/src/errors.rs | 30 + api/src/handlers/mod.rs | 1 + .../handlers/stacktraces/create_stacktrace.rs | 33 + .../handlers/stacktraces/get_stacktrace.rs | 31 + .../handlers/stacktraces/list_stacktraces.rs | 33 + api/src/handlers/stacktraces/mod.rs | 25 + api/src/infra/db/mod.rs | 1 + api/src/infra/db/schema.rs | 6 + api/src/infra/errors.rs | 47 + api/src/infra/mod.rs | 3 + api/src/infra/repositories/mod.rs | 1 + .../repositories/stacktrace_repository.rs | 90 ++ api/src/main.rs | 78 + api/src/models.rs.z | 37 + api/src/routes.rs | 33 + .../utils/custom_extractors/json_extractor.rs | 15 + api/src/utils/custom_extractors/mod.rs | 2 + .../utils/custom_extractors/path_extractor.rs | 14 + api/src/utils/mod.rs | 5 + lib/pom.xml | 5 + .../exceptional/ExceptionLogger.java | 4 +- .../exceptional/MPSCBufferWriter.java | 10 +- .../shautvast/exceptional/RingBuffer.java | 179 -- .../exceptional/ExceptionLoggerTest.java | 9 +- pom.xml | 1 + rustlib/Cargo.lock | 1309 ++++++++++++++- rustlib/Cargo.toml | 7 +- rustlib/bodies | 5 + rustlib/pom.xml | 41 + rustlib/src/Throwable.rs | 32 - rustlib/src/lib.rs | 47 +- 45 files changed, 3567 insertions(+), 245 deletions(-) create mode 100644 api/.gitignore create mode 100644 api/Cargo.lock create mode 100644 api/Cargo.toml create mode 100644 api/migrations/.keep create mode 100644 api/migrations/00000000000000_diesel_initial_setup/down.sql create mode 100644 api/migrations/00000000000000_diesel_initial_setup/up.sql create mode 100644 api/migrations/2023-08-31-140536_create_posts/down.sql create mode 100644 api/migrations/2023-08-31-140536_create_posts/up.sql create mode 100644 api/pom.xml create mode 100644 api/src/config.rs create mode 100644 api/src/domain/mod.rs create mode 100644 api/src/domain/models/mod.rs create mode 100644 api/src/domain/models/post.rs create mode 100644 api/src/errors.rs create mode 100644 api/src/handlers/mod.rs create mode 100644 api/src/handlers/stacktraces/create_stacktrace.rs create mode 100644 api/src/handlers/stacktraces/get_stacktrace.rs create mode 100644 api/src/handlers/stacktraces/list_stacktraces.rs create mode 100644 api/src/handlers/stacktraces/mod.rs create mode 100644 api/src/infra/db/mod.rs create mode 100644 api/src/infra/db/schema.rs create mode 100644 api/src/infra/errors.rs create mode 100644 api/src/infra/mod.rs create mode 100644 api/src/infra/repositories/mod.rs create mode 100644 api/src/infra/repositories/stacktrace_repository.rs create mode 100644 api/src/main.rs create mode 100644 api/src/models.rs.z create mode 100644 api/src/routes.rs create mode 100644 api/src/utils/custom_extractors/json_extractor.rs create mode 100644 api/src/utils/custom_extractors/mod.rs create mode 100644 api/src/utils/custom_extractors/path_extractor.rs create mode 100644 api/src/utils/mod.rs delete mode 100644 lib/src/main/java/com/github/shautvast/exceptional/RingBuffer.java create mode 100644 rustlib/bodies create mode 100644 rustlib/pom.xml delete mode 100644 rustlib/src/Throwable.rs diff --git a/agent/src/main/java/com/github/shautvast/exceptional/Agent.java b/agent/src/main/java/com/github/shautvast/exceptional/Agent.java index e06a45f..dacab06 100644 --- a/agent/src/main/java/com/github/shautvast/exceptional/Agent.java +++ b/agent/src/main/java/com/github/shautvast/exceptional/Agent.java @@ -73,7 +73,7 @@ public class Agent { ClassDesc.of(EXCEPTIONLOGGER), "log", MethodTypeDesc.ofDescriptor("(Ljava/lang/Throwable;)V")); } - builder.with(element); // leave any other element in place + builder.with(element); // leave every element in place }); })); } diff --git a/api/.gitignore b/api/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/api/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/api/Cargo.lock b/api/Cargo.lock new file mode 100644 index 0000000..d2f2650 --- /dev/null +++ b/api/Cargo.lock @@ -0,0 +1,1434 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[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 = "api" +version = "0.1.0" +dependencies = [ + "axum", + "axum-macros", + "chrono", + "deadpool-diesel", + "diesel", + "diesel_migrations", + "dotenvy", + "serde", + "serde_json", + "tokio", + "tracing", + "tracing-subscriber", + "uuid", +] + +[[package]] +name = "async-trait" +version = "0.1.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "axum-macros", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-macros" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdca6a10ecad987bda04e95606ef85a5417dcaac1a78455242d72e031e2b6b62" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cc" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" + +[[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.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets 0.52.5", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "darling" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "deadpool" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "421fe0f90f2ab22016f32a9881be5134fdd71c65298917084b0c7477cbc3856e" +dependencies = [ + "async-trait", + "deadpool-runtime", + "num_cpus", + "retain_mut", + "tokio", +] + +[[package]] +name = "deadpool-diesel" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9ce884fff09b610fd0bbd9e9447327fda9f613d5bd1fa114f57905cbcfd8d27" +dependencies = [ + "deadpool", + "deadpool-sync", + "diesel", +] + +[[package]] +name = "deadpool-runtime" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b" +dependencies = [ + "tokio", +] + +[[package]] +name = "deadpool-sync" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524bc3df0d57e98ecd022e21ba31166c2625e7d3e5bcc4510efaeeab4abcab04" +dependencies = [ + "deadpool-runtime", +] + +[[package]] +name = "diesel" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62d6dcd069e7b5fe49a302411f759d4cf1cf2c27fe798ef46fb8baefc053dd2b" +dependencies = [ + "bitflags 2.6.0", + "byteorder", + "diesel_derives", + "itoa", + "pq-sys", + "serde_json", + "uuid", +] + +[[package]] +name = "diesel_derives" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59de76a222c2b8059f789cbe07afbfd8deb8c31dd0bc2a21f85e256c1def8259" +dependencies = [ + "diesel_table_macro_syntax", + "dsl_auto_type", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "diesel_migrations" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a73ce704bad4231f001bff3314d91dce4aba0770cee8b233991859abc15c1f6" +dependencies = [ + "diesel", + "migrations_internals", + "migrations_macros", +] + +[[package]] +name = "diesel_table_macro_syntax" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "209c735641a413bc68c4923a9d6ad4bcb3ca306b794edaa7eb0b3228a99ffb25" +dependencies = [ + "syn", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "dsl_auto_type" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0892a17df262a24294c382f0d5997571006e7a4348b4327557c4ff1cd4a8bccc" +dependencies = [ + "darling", + "either", + "heck 0.5.0", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "migrations_internals" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd01039851e82f8799046eabbb354056283fb265c8ec0996af940f4e85a380ff" +dependencies = [ + "serde", + "toml", +] + +[[package]] +name = "migrations_macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb161cc72176cb37aa47f1fc520d3ef02263d67d661f44f05d05a079e1237fd" +dependencies = [ + "migrations_internals", + "proc-macro2", + "quote", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[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-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "pq-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a24ff9e4cf6945c988f0db7005d87747bf72864965c3529d259ad155ac41d584" +dependencies = [ + "vcpkg", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +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 = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.6", + "regex-syntax 0.8.3", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.3", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "retain_mut" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4389f1d5789befaf6029ebd9f7dac4af7f7e3d61b69d4f30e2ac02b57e7712b0" + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" +dependencies = [ + "itoa", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tokio" +version = "1.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +dependencies = [ + "backtrace", + "libc", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "toml" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "uuid" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" +dependencies = [ + "getrandom", + "rand", + "serde", +] + +[[package]] +name = "valuable" +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 = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[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.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[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-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] diff --git a/api/Cargo.toml b/api/Cargo.toml new file mode 100644 index 0000000..327b37c --- /dev/null +++ b/api/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "api" +version = "0.1.0" +edition = "2021" + + +[dependencies] +#serde_json = { version = "1.0", features = [] } +#serde = { version = "1.0", features = ["derive"] } +#anyhow = "1.0" +#postgres = "0.19" +#sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "any", "postgres", "json", "time"] } +#dotenvy = "0.15.0" +#chrono = "0.4" +#axum = "0.7" +#tokio = { version = "1", features = ["full"] } +#tokio-sqlite = "0.1" +#rusqlite = { version = "0.31", features = ["bundled"] } +#tracing-subscriber = { version = "0.3", features = ["env-filter"] } +#tracing = "0.1" + +axum = { version = "0.6", features = ["macros"] } +axum-macros = "0.3" +chrono = { version = "0.4.26", features = ["serde"] } +diesel = { version = "2.1", features = ["postgres", "uuid", "serde_json"] } +diesel_migrations = "2" +deadpool-diesel = { version = "0.4", features = ["postgres"] } +dotenvy = "0.15" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +tokio = { version = "1.0", features = ["sync", "macros", "rt-multi-thread"] } +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +uuid = { version = "1.4", features = ["fast-rng", "v4", "serde"] } diff --git a/api/migrations/.keep b/api/migrations/.keep new file mode 100644 index 0000000..e69de29 diff --git a/api/migrations/00000000000000_diesel_initial_setup/down.sql b/api/migrations/00000000000000_diesel_initial_setup/down.sql new file mode 100644 index 0000000..a9f5260 --- /dev/null +++ b/api/migrations/00000000000000_diesel_initial_setup/down.sql @@ -0,0 +1,6 @@ +-- This file was automatically created by Diesel to setup helper functions +-- and other internal bookkeeping. This file is safe to edit, any future +-- changes will be added to existing projects as new migrations. + +DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass); +DROP FUNCTION IF EXISTS diesel_set_updated_at(); diff --git a/api/migrations/00000000000000_diesel_initial_setup/up.sql b/api/migrations/00000000000000_diesel_initial_setup/up.sql new file mode 100644 index 0000000..2cad983 --- /dev/null +++ b/api/migrations/00000000000000_diesel_initial_setup/up.sql @@ -0,0 +1,36 @@ +-- This file was automatically created by Diesel to setup helper functions +-- and other internal bookkeeping. This file is safe to edit, any future +-- changes will be added to existing projects as new migrations. + + +-- Sets up a trigger for the given table to automatically set a column called +-- `updated_at` whenever the row is modified (unless `updated_at` was included +-- in the modified columns) +-- +-- # Example +-- +-- ```sql +-- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW()); +-- +-- SELECT diesel_manage_updated_at('users'); +-- ``` +CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS +$$ +BEGIN + EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s + FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl); +END; +$$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS +$$ +BEGIN + IF ( + NEW IS DISTINCT FROM OLD AND + NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at + ) THEN + NEW.updated_at := current_timestamp; + END IF; + RETURN NEW; +END; +$$ LANGUAGE plpgsql; diff --git a/api/migrations/2023-08-31-140536_create_posts/down.sql b/api/migrations/2023-08-31-140536_create_posts/down.sql new file mode 100644 index 0000000..04e1aa7 --- /dev/null +++ b/api/migrations/2023-08-31-140536_create_posts/down.sql @@ -0,0 +1 @@ +DROP TABLE stacktraces diff --git a/api/migrations/2023-08-31-140536_create_posts/up.sql b/api/migrations/2023-08-31-140536_create_posts/up.sql new file mode 100644 index 0000000..6ab5ea4 --- /dev/null +++ b/api/migrations/2023-08-31-140536_create_posts/up.sql @@ -0,0 +1,6 @@ +create table stacktraces +( + id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + timestamp timestamp, + stacktrace varchar +) \ No newline at end of file diff --git a/api/pom.xml b/api/pom.xml new file mode 100644 index 0000000..9d2bcf4 --- /dev/null +++ b/api/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + + org.github.shautvast.exceptional + exceptional-parent + 1.0-SNAPSHOT + + + exceptional-api + 1.0-SNAPSHOT + + + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + + Custom Command at Compile Phase + compile + + exec + + + cargo + ${project.basedir}/api + + build + + + + + + + + \ No newline at end of file diff --git a/api/src/config.rs b/api/src/config.rs new file mode 100644 index 0000000..671c068 --- /dev/null +++ b/api/src/config.rs @@ -0,0 +1,61 @@ +use std::env; + +use dotenvy::dotenv; +use tokio::sync::OnceCell; + +#[derive(Debug)] +struct ServerConfig { + host: String, + port: u16, +} + +#[derive(Debug)] +struct DatabaseConfig { + url: String, +} + +#[derive(Debug)] +pub struct Config { + server: ServerConfig, + db: DatabaseConfig, +} + +impl Config { + pub fn db_url(&self) -> &str { + &self.db.url + } + + pub fn server_host(&self) -> &str { + &self.server.host + } + + pub fn server_port(&self) -> u16 { + self.server.port + } +} + +pub static CONFIG: OnceCell = OnceCell::const_new(); + +async fn init_config() -> Config { + dotenv().ok(); + let server_config = ServerConfig { + host: env::var("HOST").unwrap_or_else(|_| String::from("127.0.0.1")), + port: env::var("PORT") + .unwrap_or_else(|_| String::from("3000")) + .parse::() + .unwrap(), + }; + + let database_config = DatabaseConfig { + url: env::var("DATABASE_URL").expect("DATABASE_URL must be set"), + }; + + Config { + server: server_config, + db: database_config, + } +} + +pub async fn config() -> &'static Config { + CONFIG.get_or_init(init_config).await +} diff --git a/api/src/domain/mod.rs b/api/src/domain/mod.rs new file mode 100644 index 0000000..c446ac8 --- /dev/null +++ b/api/src/domain/mod.rs @@ -0,0 +1 @@ +pub mod models; diff --git a/api/src/domain/models/mod.rs b/api/src/domain/models/mod.rs new file mode 100644 index 0000000..e8b6291 --- /dev/null +++ b/api/src/domain/models/mod.rs @@ -0,0 +1 @@ +pub mod post; diff --git a/api/src/domain/models/post.rs b/api/src/domain/models/post.rs new file mode 100644 index 0000000..2748484 --- /dev/null +++ b/api/src/domain/models/post.rs @@ -0,0 +1,54 @@ +use axum::http::StatusCode; +use axum::Json; +use axum::response::IntoResponse; +use serde::{Deserialize, Serialize}; +use serde_json::json; + +use crate::infra::errors::InfraError; + +// #[derive(Clone, Debug, PartialEq)] +// pub struct PostModel { +// pub id: Uuid, +// pub title: String, +// pub body: String, +// pub published: bool, +// } + +#[derive(Clone, Debug, PartialEq)] +pub struct SimpleStacktraceModel { + pub id: i32, + pub stacktrace: String, +} + +#[derive(Debug)] +pub enum StacktraceError { + InternalServerError, + NotFound(i32), + InfraError(InfraError), +} + +impl IntoResponse for StacktraceError { + fn into_response(self) -> axum::response::Response { + let (status, err_msg) = match self { + Self::NotFound(id) => ( + StatusCode::NOT_FOUND, + format!("StacktraceModel with id {} has not been found", id), + ), + Self::InfraError(db_error) => ( + StatusCode::INTERNAL_SERVER_ERROR, + format!("Internal server error: {}", db_error), + ), + _ => ( + StatusCode::INTERNAL_SERVER_ERROR, + String::from("Internal server error"), + ), + }; + ( + status, + Json( + json!({"resource":"StacktraceModel", "message": err_msg, "happened_at" : chrono::Utc::now() }), + ), + ) + .into_response() + } +} diff --git a/api/src/errors.rs b/api/src/errors.rs new file mode 100644 index 0000000..84263d4 --- /dev/null +++ b/api/src/errors.rs @@ -0,0 +1,30 @@ +use axum::http::StatusCode; +use axum::Json; +use axum::response::IntoResponse; +use serde_json::json; + +#[derive(Debug)] +pub enum AppError { + InternalServerError, + BodyParsingError(String), +} + +pub fn internal_error(_err: E) -> AppError { + AppError::InternalServerError +} + +impl IntoResponse for AppError { + fn into_response(self) -> axum::response::Response { + let (status, err_msg) = match self { + Self::InternalServerError => ( + StatusCode::INTERNAL_SERVER_ERROR, + String::from("Internal Server Error"), + ), + Self::BodyParsingError(message) => ( + StatusCode::BAD_REQUEST, + format!("Bad request error: {}", message), + ), + }; + (status, Json(json!({ "message": err_msg }))).into_response() + } +} diff --git a/api/src/handlers/mod.rs b/api/src/handlers/mod.rs new file mode 100644 index 0000000..45fcb5b --- /dev/null +++ b/api/src/handlers/mod.rs @@ -0,0 +1 @@ +pub mod stacktraces; diff --git a/api/src/handlers/stacktraces/create_stacktrace.rs b/api/src/handlers/stacktraces/create_stacktrace.rs new file mode 100644 index 0000000..d1aa19b --- /dev/null +++ b/api/src/handlers/stacktraces/create_stacktrace.rs @@ -0,0 +1,33 @@ +use axum::extract::State; +use axum::Json; +use tracing::info; + +use crate::AppState; +use crate::domain::models::post::StacktraceError; +use crate::handlers::stacktraces::StacktraceResponse; +use crate::infra::repositories::stacktrace_repository; + +static mut counter: usize = 0; + +pub async fn create_stacktrace( + State(state): State, + data: String, +) -> Result, StacktraceError> { + unsafe { + counter += 1; + } + let new_post_db = stacktrace_repository::NewPostDb { + stacktrace: data, + }; + + let created_stacktrace = stacktrace_repository::insert(&state.pool, new_post_db) + .await + .map_err(StacktraceError::InfraError)?; + + let post_response = StacktraceResponse { + id: created_stacktrace.id, + stacktrace: created_stacktrace.stacktrace, + }; + + Ok(Json(post_response)) +} diff --git a/api/src/handlers/stacktraces/get_stacktrace.rs b/api/src/handlers/stacktraces/get_stacktrace.rs new file mode 100644 index 0000000..a6c9a9e --- /dev/null +++ b/api/src/handlers/stacktraces/get_stacktrace.rs @@ -0,0 +1,31 @@ +use axum::extract::State; +use axum::Json; + +use crate::domain::models::post::{StacktraceError, SimpleStacktraceModel}; +use crate::handlers::stacktraces::StacktraceResponse; +use crate::infra::errors::InfraError; +use crate::infra::repositories::stacktrace_repository; +use crate::utils::PathExtractor; +use crate::AppState; + +pub async fn get_stacktrace( + State(state): State, + PathExtractor(post_id): PathExtractor, +) -> Result, StacktraceError> { + let post = + stacktrace_repository::get(&state.pool, post_id) + .await + .map_err(|db_error| match db_error { + InfraError::InternalServerError => StacktraceError::InternalServerError, + InfraError::NotFound => StacktraceError::NotFound(post_id), + })?; + + Ok(Json(adapt_post_to_post_response(post))) +} + +fn adapt_post_to_post_response(post: SimpleStacktraceModel) -> StacktraceResponse { + StacktraceResponse { + id: post.id, + stacktrace: post.stacktrace, + } +} diff --git a/api/src/handlers/stacktraces/list_stacktraces.rs b/api/src/handlers/stacktraces/list_stacktraces.rs new file mode 100644 index 0000000..c4d47f1 --- /dev/null +++ b/api/src/handlers/stacktraces/list_stacktraces.rs @@ -0,0 +1,33 @@ +use axum::extract::{Query, State}; +use axum::Json; + +use crate::domain::models::post::{StacktraceError, SimpleStacktraceModel}; +use crate::handlers::stacktraces::{ListStacktracesResponse, StacktraceResponse}; +use crate::infra::repositories::stacktrace_repository::{get_all}; +use crate::AppState; + +pub async fn list_stacktraces( + State(state): State, +) -> Result, StacktraceError> { + let stacktraces = get_all(&state.pool) + .await + .map_err(|_| StacktraceError::InternalServerError)?; + + Ok(Json(adapt_posts_to_list_posts_response(stacktraces))) +} + +fn adapt_post_to_post_response(post: SimpleStacktraceModel) -> StacktraceResponse { + StacktraceResponse { + id: post.id, + stacktrace: post.stacktrace, + } +} + +fn adapt_posts_to_list_posts_response(posts: Vec) -> ListStacktracesResponse { + let posts_response: Vec = + posts.into_iter().map(adapt_post_to_post_response).collect(); + + ListStacktracesResponse { + stacktraces: posts_response, + } +} diff --git a/api/src/handlers/stacktraces/mod.rs b/api/src/handlers/stacktraces/mod.rs new file mode 100644 index 0000000..79a16fb --- /dev/null +++ b/api/src/handlers/stacktraces/mod.rs @@ -0,0 +1,25 @@ +use serde::{Deserialize, Serialize}; + +pub use create_stacktrace::create_stacktrace; +pub use get_stacktrace::get_stacktrace; +pub use list_stacktraces::list_stacktraces; + +mod create_stacktrace; +mod get_stacktrace; +mod list_stacktraces; + +#[derive(Debug, Deserialize)] +pub struct CreatePostRequest { + stacktrace: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct StacktraceResponse { + id: i32, + stacktrace: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct ListStacktracesResponse { + stacktraces: Vec, +} diff --git a/api/src/infra/db/mod.rs b/api/src/infra/db/mod.rs new file mode 100644 index 0000000..1ce7e17 --- /dev/null +++ b/api/src/infra/db/mod.rs @@ -0,0 +1 @@ +pub mod schema; diff --git a/api/src/infra/db/schema.rs b/api/src/infra/db/schema.rs new file mode 100644 index 0000000..6bbc392 --- /dev/null +++ b/api/src/infra/db/schema.rs @@ -0,0 +1,6 @@ +diesel::table! { + stacktraces (id) { + id -> Integer, + stacktrace -> Varchar, + } +} diff --git a/api/src/infra/errors.rs b/api/src/infra/errors.rs new file mode 100644 index 0000000..dd72645 --- /dev/null +++ b/api/src/infra/errors.rs @@ -0,0 +1,47 @@ +use std::fmt; + +use deadpool_diesel::InteractError; + +#[derive(Debug)] +pub enum InfraError { + InternalServerError, + NotFound, +} + +pub fn adapt_infra_error(error: T) -> InfraError { + error.as_infra_error() +} + +impl fmt::Display for InfraError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + InfraError::NotFound => write!(f, "Not found"), + InfraError::InternalServerError => write!(f, "Internal server error"), + } + } +} + +pub trait Error { + fn as_infra_error(&self) -> InfraError; +} + +impl Error for diesel::result::Error { + fn as_infra_error(&self) -> InfraError { + match self { + diesel::result::Error::NotFound => InfraError::NotFound, + _ => InfraError::InternalServerError, + } + } +} + +impl Error for deadpool_diesel::PoolError { + fn as_infra_error(&self) -> InfraError { + InfraError::InternalServerError + } +} + +impl Error for InteractError { + fn as_infra_error(&self) -> InfraError { + InfraError::InternalServerError + } +} diff --git a/api/src/infra/mod.rs b/api/src/infra/mod.rs new file mode 100644 index 0000000..63bd3a6 --- /dev/null +++ b/api/src/infra/mod.rs @@ -0,0 +1,3 @@ +pub mod db; +pub mod errors; +pub mod repositories; diff --git a/api/src/infra/repositories/mod.rs b/api/src/infra/repositories/mod.rs new file mode 100644 index 0000000..dd7d6fc --- /dev/null +++ b/api/src/infra/repositories/mod.rs @@ -0,0 +1 @@ +pub mod stacktrace_repository; diff --git a/api/src/infra/repositories/stacktrace_repository.rs b/api/src/infra/repositories/stacktrace_repository.rs new file mode 100644 index 0000000..fa688a8 --- /dev/null +++ b/api/src/infra/repositories/stacktrace_repository.rs @@ -0,0 +1,90 @@ +use diesel::{ + ExpressionMethods, Insertable, QueryDsl, Queryable, RunQueryDsl, + Selectable, SelectableHelper, +}; +use serde::{Deserialize, Serialize}; + +use crate::domain::models::post::{SimpleStacktraceModel}; +use crate::infra::db::schema::stacktraces; +use crate::infra::errors::{adapt_infra_error, InfraError}; + +#[derive(Serialize, Queryable, Selectable)] +#[diesel(table_name = stacktraces)] +#[diesel(check_for_backend(diesel::pg::Pg))] +pub struct StacktraceDb { + pub id: i32, + pub stacktrace: String, +} + +#[derive(Insertable)] +#[diesel(table_name = stacktraces)] +pub struct NewPostDb { + pub stacktrace: String, +} + +pub async fn insert( + pool: &deadpool_diesel::postgres::Pool, + new_post: NewPostDb, +) -> Result { + let conn = pool.get().await.map_err(adapt_infra_error)?; + let res = conn + .interact(|conn| { + diesel::insert_into(stacktraces::table) + .values(new_post) + .returning(StacktraceDb::as_returning()) + .get_result(conn) + }) + .await + .map_err(adapt_infra_error)? + .map_err(adapt_infra_error)?; + + Ok(adapt_stacktracedb_to_stacktracemodel(res)) +} + +pub async fn get( + pool: &deadpool_diesel::postgres::Pool, + id: i32, +) -> Result { + let conn = pool.get().await.map_err(adapt_infra_error)?; + let res = conn + .interact(move |conn| { + stacktraces::table + .filter(stacktraces::id.eq(id)) + .select(StacktraceDb::as_select()) + .get_result(conn) + }) + .await + .map_err(adapt_infra_error)? + .map_err(adapt_infra_error)?; + + Ok(adapt_stacktracedb_to_stacktracemodel(res)) +} + +pub async fn get_all( + pool: &deadpool_diesel::postgres::Pool, +) -> Result, InfraError> { + let conn = pool.get().await.map_err(adapt_infra_error)?; + let res = conn + .interact(move |conn| { + let query = stacktraces::table.into_boxed::(); + + query.select(StacktraceDb::as_select()).load::(conn) + }) + .await + .map_err(adapt_infra_error)? + .map_err(adapt_infra_error)?; + + let posts: Vec = res + .into_iter() + .map(|post_db| adapt_stacktracedb_to_stacktracemodel(post_db)) + .collect(); + + Ok(posts) +} + +fn adapt_stacktracedb_to_stacktracemodel(post_db: StacktraceDb) -> SimpleStacktraceModel { + SimpleStacktraceModel { + id: post_db.id, + stacktrace: post_db.stacktrace, + } +} diff --git a/api/src/main.rs b/api/src/main.rs new file mode 100644 index 0000000..a32af44 --- /dev/null +++ b/api/src/main.rs @@ -0,0 +1,78 @@ +use std::net::SocketAddr; + +use deadpool_diesel::postgres::{Manager, Pool}; +use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness}; +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; + +use crate::config::config; +use crate::errors::internal_error; +use crate::routes::app_router; + +mod config; +mod domain; +mod errors; +mod handlers; +mod infra; +mod routes; +mod utils; + + +pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations/"); + +#[derive(Clone)] +pub struct AppState { + pool: Pool, +} + +#[tokio::main] +async fn main() { + init_tracing(); + + let config = config().await; + + let manager = Manager::new( + config.db_url().to_string(), + deadpool_diesel::Runtime::Tokio1, + ); + let pool = Pool::builder(manager).build().unwrap(); + + { + run_migrations(&pool).await; + } + + let state = AppState { pool }; + + let app = app_router(state.clone()).with_state(state); + + let host = config.server_host(); + let port = config.server_port(); + + let address = format!("{}:{}", host, port); + + let socket_addr: SocketAddr = address.parse().unwrap(); + + tracing::info!("listening on http://{}", socket_addr); + axum::Server::bind(&socket_addr) + .serve(app.into_make_service()) + .await + .map_err(internal_error) + .unwrap() +} + +fn init_tracing() { + tracing_subscriber::registry() + .with( + tracing_subscriber::EnvFilter::try_from_default_env() + .unwrap_or_else(|_| "example_tokio_postgres=debug".into()), + ) + .with(tracing_subscriber::fmt::layer()) + .init(); +} + +async fn run_migrations(pool: &Pool) { + let conn = pool.get().await.unwrap(); + conn.interact(|conn| conn.run_pending_migrations(MIGRATIONS).map(|_| ())) + .await + .unwrap() + .unwrap(); +} diff --git a/api/src/models.rs.z b/api/src/models.rs.z new file mode 100644 index 0000000..d64cdda --- /dev/null +++ b/api/src/models.rs.z @@ -0,0 +1,37 @@ +use serde::Deserialize; + +#[derive(Deserialize, Debug)] +pub struct SimpleStacktrace{ + stacktrace: String +} + +#[derive(Deserialize, Debug)] +pub struct Throwable { + cause: Option>, + #[serde(rename(deserialize = "stackTrace"))] + stack_trace: Vec, + message: Option, + suppressed: Vec, + #[serde(rename(deserialize = "localizedMessage"))] + localized_message: Option, +} + +#[derive(Deserialize, Debug)] +pub struct Stacktrace { + #[serde(rename(deserialize = "classLoaderName"))] + class_loader_name: Option, + #[serde(rename(deserialize = "moduleName"))] + module_name: Option, + #[serde(rename(deserialize = "moduleVersion"))] + module_version: Option, + #[serde(rename(deserialize = "methodName"))] + method_name: Option, + #[serde(rename(deserialize = "fileName"))] + file_name: Option, + #[serde(rename(deserialize = "lineNumber"))] + line_number: Option, + #[serde(rename(deserialize = "className"))] + class_name: Option, + #[serde(rename(deserialize = "nativeMethod"))] + native_method: Option, +} diff --git a/api/src/routes.rs b/api/src/routes.rs new file mode 100644 index 0000000..ea04593 --- /dev/null +++ b/api/src/routes.rs @@ -0,0 +1,33 @@ +use axum::http::StatusCode; +use axum::response::IntoResponse; +use axum::routing::{get, post}; +use axum::Router; + +use crate::handlers::stacktraces::{create_stacktrace, get_stacktrace, list_stacktraces}; +use crate::AppState; + +pub fn app_router(state: AppState) -> Router { + Router::new() + .route("/", get(root)) + .nest("/api/stacktraces", stacktraces_routes(state.clone())) + .fallback(handler_404) +} + +async fn root() -> &'static str { + "Server is running!" +} + +async fn handler_404() -> impl IntoResponse { + ( + StatusCode::NOT_FOUND, + "The requested resource was not found", + ) +} + +fn stacktraces_routes(state: AppState) -> Router { + Router::new() + .route("/", post(create_stacktrace)) + .route("/", get(list_stacktraces)) + .route("/:id", get(get_stacktrace)) + .with_state(state) +} diff --git a/api/src/utils/custom_extractors/json_extractor.rs b/api/src/utils/custom_extractors/json_extractor.rs new file mode 100644 index 0000000..1055aa2 --- /dev/null +++ b/api/src/utils/custom_extractors/json_extractor.rs @@ -0,0 +1,15 @@ +use axum::extract::rejection::JsonRejection; +use axum_macros::FromRequest; + +use crate::errors::AppError; + +#[derive(FromRequest)] +#[from_request(via(axum::Json), rejection(AppError))] +pub struct JsonExtractor(pub T); + + +impl From for AppError { + fn from(rejection: JsonRejection) -> Self { + AppError::BodyParsingError(rejection.to_string()) + } +} diff --git a/api/src/utils/custom_extractors/mod.rs b/api/src/utils/custom_extractors/mod.rs new file mode 100644 index 0000000..eaec848 --- /dev/null +++ b/api/src/utils/custom_extractors/mod.rs @@ -0,0 +1,2 @@ +pub mod json_extractor; +pub mod path_extractor; diff --git a/api/src/utils/custom_extractors/path_extractor.rs b/api/src/utils/custom_extractors/path_extractor.rs new file mode 100644 index 0000000..d796c8c --- /dev/null +++ b/api/src/utils/custom_extractors/path_extractor.rs @@ -0,0 +1,14 @@ +use axum::extract::rejection::PathRejection; +use axum_macros::FromRequestParts; + +use crate::errors::AppError; + +#[derive(FromRequestParts, Debug)] +#[from_request(via(axum::extract::Path), rejection(AppError))] +pub struct PathExtractor(pub T); + +impl From for AppError { + fn from(rejection: PathRejection) -> Self { + AppError::BodyParsingError(rejection.to_string()) + } +} diff --git a/api/src/utils/mod.rs b/api/src/utils/mod.rs new file mode 100644 index 0000000..f7fa572 --- /dev/null +++ b/api/src/utils/mod.rs @@ -0,0 +1,5 @@ +pub use custom_extractors::json_extractor::JsonExtractor; +pub use custom_extractors::path_extractor::PathExtractor; + +mod custom_extractors; + diff --git a/lib/pom.xml b/lib/pom.xml index 99ea5bb..b4e8b59 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -30,6 +30,11 @@ RELEASE test + + org.postgresql + postgresql + 42.6.2 + diff --git a/lib/src/main/java/com/github/shautvast/exceptional/ExceptionLogger.java b/lib/src/main/java/com/github/shautvast/exceptional/ExceptionLogger.java index a1a92ff..3b338cb 100644 --- a/lib/src/main/java/com/github/shautvast/exceptional/ExceptionLogger.java +++ b/lib/src/main/java/com/github/shautvast/exceptional/ExceptionLogger.java @@ -4,8 +4,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; @SuppressWarnings("unused") // this code is called from the instrumented code public class ExceptionLogger { - private final static ObjectMapper objectMapper = new ObjectMapper();; - private final static MPSCBufferWriter bufferWriter=new MPSCBufferWriter(); + private final static ObjectMapper objectMapper = new ObjectMapper(); + private final static MPSCBufferWriter bufferWriter = new MPSCBufferWriter(); public static void log(Throwable throwable) { try { diff --git a/lib/src/main/java/com/github/shautvast/exceptional/MPSCBufferWriter.java b/lib/src/main/java/com/github/shautvast/exceptional/MPSCBufferWriter.java index b8d15ba..48768b5 100644 --- a/lib/src/main/java/com/github/shautvast/exceptional/MPSCBufferWriter.java +++ b/lib/src/main/java/com/github/shautvast/exceptional/MPSCBufferWriter.java @@ -1,7 +1,6 @@ package com.github.shautvast.exceptional; import java.lang.foreign.*; -import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingDeque; @@ -14,10 +13,15 @@ public class MPSCBufferWriter implements AutoCloseable { private static Linker linker; private static SymbolLookup rustlib; private static final LinkedBlockingDeque writeQueue = new LinkedBlockingDeque<>(); // unbounded - private static final ExecutorService executorService = Executors.newSingleThreadExecutor(); + private static final ExecutorService executorService = Executors.newSingleThreadExecutor(runnable -> { + Thread thread = new Thread(runnable); + thread.setDaemon(true); + return thread; + }); private final AtomicBoolean active = new AtomicBoolean(false); public MPSCBufferWriter() { +// DatabaseInit.initializeDatabase(); startWriteQueueListener(); } @@ -58,8 +62,8 @@ public class MPSCBufferWriter implements AutoCloseable { } catch (Throwable e) { throw new RuntimeException(e); } - } + System.out.println("Shutting down"); }); } diff --git a/lib/src/main/java/com/github/shautvast/exceptional/RingBuffer.java b/lib/src/main/java/com/github/shautvast/exceptional/RingBuffer.java deleted file mode 100644 index f89b99f..0000000 --- a/lib/src/main/java/com/github/shautvast/exceptional/RingBuffer.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.github.shautvast.exceptional; - -import java.lang.foreign.MemorySegment; -import java.nio.ByteBuffer; -import java.time.Duration; -import java.util.Optional; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.LinkedBlockingDeque; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.locks.ReentrantLock; -import java.util.function.Consumer; - -//circular MPSC buffer -//TODO REMOVE -public class RingBuffer implements AutoCloseable { - private final ByteBuffer memory; - private final AtomicInteger readPointer; - private final AtomicInteger writePointer; - private final AtomicBoolean writerThreadRunning = new AtomicBoolean(true); - private final AtomicBoolean readerThreadRunning = new AtomicBoolean(false); - private final ReentrantLock lock = new ReentrantLock(); - private static final LinkedBlockingDeque writeQueue = new LinkedBlockingDeque<>(); - private final ExecutorService writerThread; - private ExecutorService readerThread; - - void setReadPointer(int readPointer) { - this.readPointer.set(readPointer); - } - - public RingBuffer(MemorySegment memory) { - if (memory.byteSize() > 0xfffd) { - throw new IllegalArgumentException("Max memory size is 65533"); //TODO probably ffff - } - this.memory = memory.asByteBuffer(); - memory.asByteBuffer(); - readPointer = new AtomicInteger(0); - writePointer = new AtomicInteger(0); - - writerThread = Executors.newSingleThreadExecutor(); - writerThread.submit(() -> { - while (writerThreadRunning.get()) { - try { - byte[] data = writeQueue.poll(5, TimeUnit.SECONDS); - if (data != null) { - while (!writeBytes(data)) { - Thread.sleep(5000); - } - ; - } - } catch (InterruptedException _) { - // honor the interrupt - writerThreadRunning.set(false); - } - } - }); - - } - - - /** - * Writes a byte array to the ring buffer. - *

- * If there is enough space in the buffer, the method writes the byte array to the buffer - * and returns true. If there is not enough space, the method does not write the byte array - * and returns false. - * - * @param data the byte array to write to the buffer - * @return true if the byte array was written successfully, false otherwise - */ - private boolean writeBytes(byte[] data) { - if (writePointer.get() > memory.capacity()) { - System.out.println("blocked"); - return false;//signal retry - } - System.out.println("write " + new String(data)); - int allocSize = data.length + 2; - int pos = writePointer.getAndAdd(allocSize); - if (writePointer.get() > (memory.capacity() - 2)) { - int max = memory.capacity() - (pos + 4); - if (data.length - max < readPointer.get()) { - System.out.println("wrap"); - memory.putShort(pos, (short) data.length); - memory.position(pos + 2); - memory.put(data, 0, max); - memory.position(0); - memory.put(data, max, data.length - max); - writePointer.set(data.length - max); - memory.putShort((short) 0); - return true; - } else { - return false; - } - } else { - memory.putShort(pos, (short) data.length); - memory.position(pos + 2); - memory.put(data); - memory.putShort((short) 0); - return true; - } - } - - /** - * Reads a byte array from the ring buffer with a specified timeout. - *

- * Blocks until there is data available to read or the timeout is reached. - * If the timeout is reached and there is still no data, the resul is empty. - * - * @param timeout the maximum time to wait for data to be available in the buffer - * @return the byte array read from the buffer - * @throws InterruptedException if the thread is interrupted while waiting for data - */ - private Optional read(Duration timeout) throws InterruptedException { - if (memory.getShort(readPointer.get()) == 0 || readPointer.get() >= memory.capacity()) { - return Optional.empty(); - } - return Optional.ofNullable(getBytes()); - } - - private byte[] getBytes() { - int currentReadPointerValue = readPointer.get(); - int lenToread = memory.getShort(currentReadPointerValue); - System.out.println(lenToread + " bytes"); - if (lenToread <= 0) { - return null; - } - currentReadPointerValue = readPointer.addAndGet(2); - byte[] data = new byte[lenToread]; - int bytesTilEnd = memory.capacity() - currentReadPointerValue; - if (lenToread > bytesTilEnd) { - memory.get(currentReadPointerValue, data, 0, bytesTilEnd); - memory.get(0, data, bytesTilEnd, lenToread - bytesTilEnd); - readPointer.set(lenToread - bytesTilEnd); - } else { - memory.get(currentReadPointerValue, data); - System.out.println("set "+readPointer.addAndGet(lenToread)); - } - return data; - } - - - public void write(byte[] bytes) { - while (!writeQueue.offer(bytes)) ; - } - - public void startReader(Consumer consumer) { - readerThreadRunning.set(true); - readerThread = Executors.newSingleThreadExecutor(); - - readerThread.submit(() -> { - while (readerThreadRunning.get()) { - try { - System.out.println("read"); - read(Duration.ofSeconds(5)).ifPresent(consumer); - Thread.sleep(5000); - } catch (InterruptedException _) { - readerThreadRunning.set(false); - } - } - }); - - } - - public void close() { - System.out.println("close"); - writerThreadRunning.set(false); - readerThreadRunning.set(false); - writerThread.close(); - readerThread.close(); - } - - public void drain() { - while (!writeQueue.isEmpty()) ; - close(); - } -} - diff --git a/lib/src/test/java/com/github/shautvast/exceptional/ExceptionLoggerTest.java b/lib/src/test/java/com/github/shautvast/exceptional/ExceptionLoggerTest.java index fd884b5..f8d6370 100644 --- a/lib/src/test/java/com/github/shautvast/exceptional/ExceptionLoggerTest.java +++ b/lib/src/test/java/com/github/shautvast/exceptional/ExceptionLoggerTest.java @@ -8,8 +8,13 @@ class ExceptionLoggerTest { @Test void test() throws InterruptedException { - ExceptionLogger.log(new Throwable()); - TimeUnit.SECONDS.sleep(1); + long t0 = System.currentTimeMillis(); + for (int i = 0; i < 1_000; i++) { + ExceptionLogger.log(new Throwable()); + TimeUnit.MILLISECONDS.sleep(1); + } + System.out.println(System.currentTimeMillis() - t0); + Thread.sleep(10000); } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index 90d7b6b..1ea99c0 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,7 @@ agent + rustlib lib diff --git a/rustlib/Cargo.lock b/rustlib/Cargo.lock index 6236b71..61ae06e 100644 --- a/rustlib/Cargo.lock +++ b/rustlib/Cargo.lock @@ -2,18 +2,675 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[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 = "anyhow" version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cc" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" + +[[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.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.52.5", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[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.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[package]] +name = "h2" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" + +[[package]] +name = "hyper" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + [[package]] name = "itoa" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +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.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[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.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + [[package]] name = "proc-macro2" version = "1.0.86" @@ -32,13 +689,132 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "reqwest" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustlib" version = "0.1.0" dependencies = [ "anyhow", - "serde", - "serde_json", + "chrono", + "crossbeam-deque", + "reqwest", +] + +[[package]] +name = "rustls" +version = "0.23.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" + +[[package]] +name = "rustls-webpki" +version = "0.102.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -47,6 +823,38 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "security-framework" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "serde" version = "1.0.203" @@ -78,6 +886,55 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.67" @@ -89,8 +946,456 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + +[[package]] +name = "tinyvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +dependencies = [ + "tinyvec_macros", +] + +[[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.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[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.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/rustlib/Cargo.toml b/rustlib/Cargo.toml index f7a7650..d4a0c8c 100644 --- a/rustlib/Cargo.toml +++ b/rustlib/Cargo.toml @@ -8,6 +8,7 @@ crate-type = ["cdylib"] bench = false [dependencies] -serde_json = { version = "1.0", features = [] } -serde = { version = "1.0", features = ["derive"] } -anyhow = "1.0" \ No newline at end of file +anyhow = "1.0" +chrono = "0.4" +reqwest = { version = "0.12", features = ["blocking"]} +crossbeam-deque = "0.8" \ No newline at end of file diff --git a/rustlib/bodies b/rustlib/bodies new file mode 100644 index 0000000..9011e18 --- /dev/null +++ b/rustlib/bodies @@ -0,0 +1,5 @@ +HTTP/1.1 200 OK +content-type: text/plain; charset=utf-8 +content-length: 19 +date: Tue, 02 Jul 2024 06:20:13 GMT + diff --git a/rustlib/pom.xml b/rustlib/pom.xml new file mode 100644 index 0000000..b68c175 --- /dev/null +++ b/rustlib/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + + org.github.shautvast.exceptional + exceptional-parent + 1.0-SNAPSHOT + + + exceptional-rustlib + 1.0-SNAPSHOT + + + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + + Custom Command at Compile Phase + compile + + exec + + + cargo + ${project.basedir}/rustlib + + build + + + + + + + + \ No newline at end of file diff --git a/rustlib/src/Throwable.rs b/rustlib/src/Throwable.rs deleted file mode 100644 index 9c1de6e..0000000 --- a/rustlib/src/Throwable.rs +++ /dev/null @@ -1,32 +0,0 @@ -use serde::Deserialize; - -#[derive(Deserialize, Debug)] -pub struct Throwable { - cause: Option>, - #[serde(rename (deserialize = "stackTrace"))] - stack_trace: Vec, - message: Option, - suppressed: Vec, - #[serde(rename (deserialize = "localizedMessage"))] - localized_message: Option, -} - -#[derive(Deserialize, Debug)] -pub struct Stacktrace{ - #[serde(rename (deserialize = "classLoaderName"))] - class_loader_name: Option, - #[serde(rename (deserialize = "moduleName"))] - module_name: Option, - #[serde(rename (deserialize = "moduleVersion"))] - module_version: Option, - #[serde(rename (deserialize = "methodName"))] - method_name: Option, - #[serde(rename (deserialize = "fileName"))] - file_name: Option, - #[serde(rename (deserialize = "lineNumber"))] - line_number: Option, - #[serde(rename (deserialize = "className"))] - class_name: Option, - #[serde(rename (deserialize = "nativeMethod"))] - native_method: Option, -} \ No newline at end of file diff --git a/rustlib/src/lib.rs b/rustlib/src/lib.rs index 1d17dcf..de44d57 100644 --- a/rustlib/src/lib.rs +++ b/rustlib/src/lib.rs @@ -1,18 +1,23 @@ +use std::cell::OnceCell; use std::ffi::c_char; +use std::slice; -mod throwable; +use reqwest::blocking::Client; // same value, but different meanings // TODO find a way to set the buffer size from java. // why not just add it to the function const CAPACITY: isize = 32760; const READ: isize = 32760; +const CLIENT: OnceCell = OnceCell::new(); #[no_mangle] pub extern "C" fn buffer_updated(buffer: *mut c_char) { + let client = CLIENT; + let client = client.get_or_init(|| Client::new()); let mut read_pos = get_u32(buffer, READ) as isize; - let mut remaining = CAPACITY - read_pos; + let mut remaining = CAPACITY - read_pos; // nr of bytes to read before end of buffer let len = if remaining == 1 { let byte_high = get_u8(buffer, read_pos); read_pos = 0; @@ -33,37 +38,37 @@ pub extern "C" fn buffer_updated(buffer: *mut c_char) { l } as isize; - let mut result = Vec::with_capacity(len as usize); + // copy only when needed if len <= remaining { - for i in 0..len { - unsafe { result.push(*buffer.offset(read_pos + i) as u8); } + unsafe { + let result = std::str::from_utf8_unchecked(slice::from_raw_parts(buffer.offset(read_pos).cast::(), len as usize)); + client.post("http://localhost:3000/api/stacktraces") + .body(result) + .send() + .unwrap(); } read_pos += len; } else { - for i in 0..remaining { - unsafe { result.push(*buffer.offset(read_pos + i) as u8); } + unsafe { + let s1 = std::str::from_utf8_unchecked(slice::from_raw_parts(buffer.offset(read_pos).cast::(), remaining as usize)); + let s2 = std::str::from_utf8_unchecked(slice::from_raw_parts(buffer.cast::(), (len - remaining) as usize)); + let mut s = String::with_capacity(len as usize); + s.push_str(s1); + s.push_str(s2); + client.post("http://localhost:3000/api/stacktraces") + .body(s) + .send() + .unwrap(); } - read_pos = 0; - for i in 0..len - remaining { - unsafe { result.push(*buffer.offset(i) as u8); } - } - read_pos += len - remaining; + read_pos = len - remaining; } put_u32(buffer, READ, read_pos as u32); - - let string = String::from_utf8(result); - if let Ok(json) = string { - println!("receiving {}", json); - } else { - println!("not ok"); - } } fn get_u8(s: *const c_char, pos: isize) -> u8 { unsafe { *s.offset(pos) as u8 } } - fn get_u16(s: *const c_char, pos: isize) -> u16 { let mut b: [u8; 2] = [0; 2]; unsafe { @@ -92,4 +97,4 @@ fn put_u32(s: *mut c_char, pos: isize, value: u32) { *s.offset(pos + 2) = bytes[2] as c_char; *s.offset(pos + 3) = bytes[3] as c_char; } -} \ No newline at end of file +}