From 4776b6f73913c73190e3ebf004f97df1482a3648 Mon Sep 17 00:00:00 2001 From: projectmoon Date: Sat, 5 Jun 2021 14:34:22 +0000 Subject: [PATCH] WIP on trying to get working graphql server --- Cargo.lock | 921 ++++++++++++++++++++++++++------ api/Cargo.toml | 20 +- api/src/grpc_web.rs | 42 ++ api/src/main.rs | 172 +++++- dicebot/Cargo.toml | 2 +- dicebot/src/bin/tonic_client.rs | 10 +- rpc/Cargo.toml | 4 +- web-ui/crate/Cargo.toml | 25 +- web-ui/crate/src/grpc.rs | 24 +- 9 files changed, 994 insertions(+), 226 deletions(-) create mode 100644 api/src/grpc_web.rs diff --git a/Cargo.lock b/Cargo.lock index dd17a78..1cdca59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -125,6 +125,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "ascii" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" + [[package]] name = "assign" version = "1.1.1" @@ -196,9 +202,9 @@ dependencies = [ "futures-core", "getrandom 0.2.3", "instant", - "pin-project", + "pin-project 1.0.7", "rand 0.8.3", - "tokio", + "tokio 1.6.0", ] [[package]] @@ -213,6 +219,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + [[package]] name = "base64" version = "0.13.0" @@ -272,6 +284,33 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfa8873f51c92e232f9bac4065cddef41b714152812bfc5f7672ba16d6ef8cd9" +[[package]] +name = "bson" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b6553abdb9d2d8f262f0b5bccf807321d5b7d1a12796bcede8e1f150e85f2e" +dependencies = [ + "base64 0.13.0", + "chrono", + "hex", + "lazy_static", + "linked-hash-map", + "rand 0.7.3", + "serde", + "serde_json", + "uuid", +] + +[[package]] +name = "buf_redux" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b953a6887648bb07a535631f2bc00fbdb2a2216f135552cb3f534ed136b9c07f" +dependencies = [ + "memchr", + "safemem", +] + [[package]] name = "build_const" version = "0.2.2" @@ -290,6 +329,12 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + [[package]] name = "bytes" version = "1.0.1" @@ -353,7 +398,7 @@ dependencies = [ "num-integer", "num-traits", "time 0.1.43", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -374,13 +419,26 @@ dependencies = [ "cc", ] +[[package]] +name = "combine" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" +dependencies = [ + "ascii", + "byteorder", + "either", + "memchr", + "unreachable", +] + [[package]] name = "combine" version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc4369b5e4c0cddf64ad8981c0111e7df4f7078f4d6ba98fb31f2e17c4c57b7e" dependencies = [ - "bytes", + "bytes 1.0.1", "memchr", ] @@ -528,6 +586,17 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "derive_utils" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "532b4c15dccee12c7044f1fcad956e98410860b22231e44a3b827464797ca7bf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "digest" version = "0.9.0" @@ -554,7 +623,7 @@ checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" dependencies = [ "libc", "redox_users", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -569,6 +638,12 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +[[package]] +name = "dtoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" + [[package]] name = "either" version = "1.6.1" @@ -643,9 +718,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" dependencies = [ "libc", - "winapi", + "winapi 0.3.9", ] +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + [[package]] name = "funty" version = "1.1.0" @@ -702,6 +793,17 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1" +[[package]] +name = "futures-enum" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3422d14de7903a52e9dbc10ae05a7e14445ec61890100e098754e120b2bd7b1e" +dependencies = [ + "derive_utils", + "quote", + "syn", +] + [[package]] name = "futures-executor" version = "0.3.15" @@ -777,7 +879,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite", + "pin-project-lite 0.2.6", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -893,24 +995,34 @@ dependencies = [ "web-sys", ] +[[package]] +name = "graphql-parser" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1abd4ce5247dfc04a03ccde70f87a048458c9356c7e41d21ad8c407b3dde6f2" +dependencies = [ + "combine 3.8.1", + "thiserror", +] + [[package]] name = "grpc-web-client" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52b8f66de5a7a111fcb5bc3ed646f9e6db8dde6bb0ab6c5555e718b4f97fa681" dependencies = [ - "base64", + "base64 0.13.0", "byteorder", - "bytes", + "bytes 1.0.1", "futures", "getrandom 0.2.3", "http", - "http-body", + "http-body 0.4.2", "httparse", - "hyper", + "hyper 0.14.7", "js-sys", "prost", - "tonic 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tonic", "wasm-bindgen", "wasm-bindgen-futures", "wasm-streams", @@ -919,11 +1031,11 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.3" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" +checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" dependencies = [ - "bytes", + "bytes 0.5.6", "fnv", "futures-core", "futures-sink", @@ -931,8 +1043,28 @@ dependencies = [ "http", "indexmap", "slab", - "tokio", - "tokio-util", + "tokio 0.2.25", + "tokio-util 0.3.1", + "tracing", + "tracing-futures", +] + +[[package]] +name = "h2" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" +dependencies = [ + "bytes 1.0.1", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio 1.6.0", + "tokio-util 0.6.7", "tracing", ] @@ -954,6 +1086,31 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "headers" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0b7591fb62902706ae8e7aaff416b1b0fa2c0fd0878b46dc13baa3712d8a855" +dependencies = [ + "base64 0.13.0", + "bitflags", + "bytes 1.0.1", + "headers-core", + "http", + "mime", + "sha-1", + "time 0.1.43", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http", +] + [[package]] name = "heck" version = "0.3.2" @@ -1019,20 +1176,30 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" dependencies = [ - "bytes", + "bytes 1.0.1", "fnv", "itoa", ] +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes 0.5.6", + "http", +] + [[package]] name = "http-body" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60daa14be0e0786db0f03a9e57cb404c9d756eed2b6c62b9ea98ec5743ec75a9" dependencies = [ - "bytes", + "bytes 1.0.1", "http", - "pin-project-lite", + "pin-project-lite 0.2.6", ] [[package]] @@ -1041,31 +1208,61 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" +[[package]] +name = "httpdate" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" + [[package]] name = "httpdate" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05842d0d43232b23ccb7060ecb0f0626922c21f30012e97b767b30afd4a5d4b9" +[[package]] +name = "hyper" +version = "0.13.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb" +dependencies = [ + "bytes 0.5.6", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.2.7", + "http", + "http-body 0.3.1", + "httparse", + "httpdate 0.3.2", + "itoa", + "pin-project 1.0.7", + "socket2 0.3.19", + "tokio 0.2.25", + "tower-service", + "tracing", + "want", +] + [[package]] name = "hyper" version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e5f105c494081baa3bf9e200b279e27ec1623895cd504c7dbef8d0b080fcf54" dependencies = [ - "bytes", + "bytes 1.0.1", "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.3.3", "http", - "http-body", + "http-body 0.4.2", "httparse", - "httpdate", + "httpdate 1.0.0", "itoa", - "pin-project", - "socket2", - "tokio", + "pin-project 1.0.7", + "socket2 0.4.0", + "tokio 1.6.0", "tower-service", "tracing", "want", @@ -1077,10 +1274,10 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes", - "hyper", + "bytes 1.0.1", + "hyper 0.14.7", "native-tls", - "tokio", + "tokio 1.6.0", "tokio-native-tls", ] @@ -1115,6 +1312,15 @@ dependencies = [ "unindent", ] +[[package]] +name = "input_buffer" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19a8a95243d5a0398cae618ec29477c6e3cb631152be5c19481f80bc71559754" +dependencies = [ + "bytes 0.5.6", +] + [[package]] name = "instant" version = "0.1.9" @@ -1128,6 +1334,15 @@ dependencies = [ "web-sys", ] +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + [[package]] name = "ipnet" version = "2.3.0" @@ -1176,6 +1391,67 @@ dependencies = [ "serde", ] +[[package]] +name = "juniper" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a0b1228e9cd2c1cf43186b593c2d09408e65a196f86f98e8520d85ac26b9c7a" +dependencies = [ + "async-trait", + "bson", + "chrono", + "fnv", + "futures", + "futures-enum", + "graphql-parser", + "indexmap", + "juniper_codegen", + "serde", + "smartstring", + "static_assertions", + "url", + "uuid", +] + +[[package]] +name = "juniper_codegen" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d86d3ba9151f4ba09a8ea8d15601d38b2289cecda77be081ee5c8951f013d54" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "juniper_warp" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d087dadaae0b71123f25b227afdc130de7e91d3a7ebd9ae3ee1dc4344569748f" +dependencies = [ + "anyhow", + "bytes 0.5.6", + "futures", + "juniper", + "serde", + "serde_json", + "thiserror", + "tokio 0.2.25", + "warp", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -1212,6 +1488,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linked-hash-map" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" + [[package]] name = "lock_api" version = "0.4.4" @@ -1289,7 +1571,7 @@ version = "0.2.0" source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#fe17dce813f500b4c633669a7078ee843bb44886" dependencies = [ "backoff", - "bytes", + "bytes 1.0.1", "dashmap", "futures", "futures-timer", @@ -1300,7 +1582,7 @@ dependencies = [ "reqwest", "serde_json", "thiserror", - "tokio", + "tokio 1.6.0", "tracing", "tracing-futures", "url", @@ -1325,7 +1607,7 @@ dependencies = [ "sha2", "sled", "thiserror", - "tokio", + "tokio 1.6.0", "tracing", "zeroize", ] @@ -1341,7 +1623,7 @@ dependencies = [ "instant", "ruma", "serde", - "tokio", + "tokio 1.6.0", "uuid", "wasm-bindgen-futures", ] @@ -1354,7 +1636,7 @@ dependencies = [ "aes-ctr", "aes-gcm", "atomic", - "base64", + "base64 0.13.0", "byteorder", "dashmap", "futures", @@ -1393,6 +1675,35 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +[[package]] +name = "mime_guess" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "mio" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +dependencies = [ + "cfg-if 0.1.10", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow 0.2.2", + "net2", + "slab", + "winapi 0.2.8", +] + [[package]] name = "mio" version = "0.7.11" @@ -1401,9 +1712,44 @@ checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956" dependencies = [ "libc", "log", - "miow", + "miow 0.3.7", "ntapi", - "winapi", + "winapi 0.3.9", +] + +[[package]] +name = "mio-named-pipes" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" +dependencies = [ + "log", + "mio 0.6.23", + "miow 0.3.7", + "winapi 0.3.9", +] + +[[package]] +name = "mio-uds" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" +dependencies = [ + "iovec", + "libc", + "mio 0.6.23", +] + +[[package]] +name = "miow" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", ] [[package]] @@ -1412,7 +1758,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -1421,6 +1767,24 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +[[package]] +name = "multipart" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050aeedc89243f5347c3e237e3e13dc76fbe4ae3742a57b94dc14f69acf76d4" +dependencies = [ + "buf_redux", + "httparse", + "log", + "mime", + "mime_guess", + "quick-error", + "rand 0.7.3", + "safemem", + "tempfile", + "twoway", +] + [[package]] name = "native-tls" version = "0.2.7" @@ -1439,6 +1803,17 @@ dependencies = [ "tempfile", ] +[[package]] +name = "net2" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.9", +] + [[package]] name = "new_debug_unreachable" version = "1.0.4" @@ -1475,7 +1850,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -1596,7 +1971,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -1684,13 +2059,33 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pin-project" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918192b5c59119d51e0cd221f4d49dde9112824ba717369e903c97d076083d0f" +dependencies = [ + "pin-project-internal 0.4.28", +] + [[package]] name = "pin-project" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7509cc106041c40a4518d2af7a61530e1eed0e6285296a3d8c5472806ccc4a4" dependencies = [ - "pin-project-internal", + "pin-project-internal 1.0.7", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be26700300be6d9d23264c73211d8190e755b6b5ca7a1b28230025511b52a5e" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1704,6 +2099,12 @@ dependencies = [ "syn", ] +[[package]] +name = "pin-project-lite" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" + [[package]] name = "pin-project-lite" version = "0.2.6" @@ -1765,6 +2166,30 @@ dependencies = [ "toml", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro-hack" version = "0.5.19" @@ -1792,7 +2217,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e6984d2f1a23009bd270b8bb56d0926810a3d483f59c987d77969e9d8e840b2" dependencies = [ - "bytes", + "bytes 1.0.1", "prost-derive", ] @@ -1802,7 +2227,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32d3ebd75ac2679c2af3a92246639f9fcc8a442ee420719cc4fe195b98dd5fa3" dependencies = [ - "bytes", + "bytes 1.0.1", "heck", "itertools 0.9.0", "log", @@ -1833,10 +2258,16 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b518d7cdd93dab1d1122cf07fa9a60771836c668dde9d9e2a139f957f0d9f1bb" dependencies = [ - "bytes", + "bytes 1.0.1", "prost", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" version = "1.0.9" @@ -2039,7 +2470,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2048,14 +2479,14 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2296f2fac53979e8ccbc4a1136b25dcefd37be9ed7e4a1f6b05a6029c84ff124" dependencies = [ - "base64", - "bytes", + "base64 0.13.0", + "bytes 1.0.1", "encoding_rs", "futures-core", "futures-util", "http", - "http-body", - "hyper", + "http-body 0.4.2", + "hyper 0.14.7", "hyper-tls", "ipnet", "js-sys", @@ -2064,10 +2495,10 @@ dependencies = [ "mime", "native-tls", "percent-encoding", - "pin-project-lite", + "pin-project-lite 0.2.6", "serde", - "serde_urlencoded", - "tokio", + "serde_urlencoded 0.7.0", + "tokio 1.6.0", "tokio-native-tls", "url", "wasm-bindgen", @@ -2099,7 +2530,7 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51df85b3e2c4097abc60919864502083def5c3b12982b0c46f6431e5b1e1476d" dependencies = [ - "bytes", + "bytes 1.0.1", "http", "percent-encoding", "ruma-api-macros", @@ -2129,7 +2560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fda53002660ebdf6eca81102bf4362d0f9234a4d3f7a3e5f9878ed7c1f133843" dependencies = [ "assign", - "bytes", + "bytes 1.0.1", "http", "js_int", "maplit", @@ -2240,7 +2671,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c888d69db1d5f134cbce7101f5610f1802966f359646ff48dbaf0f433d7bbd9f" dependencies = [ - "bytes", + "bytes 1.0.1", "form_urlencoded", "itoa", "js_int", @@ -2282,7 +2713,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" dependencies = [ - "base64", + "base64 0.13.0", "blake2b_simd", "constant_time_eq", "crossbeam-utils", @@ -2303,6 +2734,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + [[package]] name = "same-file" version = "1.0.6" @@ -2319,9 +2756,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" dependencies = [ "lazy_static", - "winapi", + "winapi 0.3.9", ] +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + [[package]] name = "scopeguard" version = "1.1.0" @@ -2404,6 +2847,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +dependencies = [ + "dtoa", + "itoa", + "serde", + "url", +] + [[package]] name = "serde_urlencoded" version = "0.7.0" @@ -2416,6 +2871,19 @@ dependencies = [ "serde", ] +[[package]] +name = "sha-1" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4cfa741c5832d0ef7fab46cabed29c2aae926db0b11bb2069edd8db5e64e16" +dependencies = [ + "block-buffer", + "cfg-if 1.0.0", + "cpufeatures", + "digest", + "opaque-debug", +] + [[package]] name = "sha1" version = "0.6.0" @@ -2487,6 +2955,26 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +[[package]] +name = "smartstring" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ada87540bf8ef4cf8a1789deb175626829bb59b1fefd816cf7f7f55efcdbae9" +dependencies = [ + "static_assertions", +] + +[[package]] +name = "socket2" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "winapi 0.3.9", +] + [[package]] name = "socket2" version = "0.4.0" @@ -2494,7 +2982,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" dependencies = [ "libc", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2530,7 +3018,7 @@ dependencies = [ "atoi", "bitflags", "byteorder", - "bytes", + "bytes 1.0.1", "crc", "crossbeam-channel", "crossbeam-queue", @@ -2592,7 +3080,7 @@ checksum = "4ce2e16b6774c671cc183e1d202386fdf9cde1e8468c1894a7f2a63eb671c4f4" dependencies = [ "native-tls", "once_cell", - "tokio", + "tokio 1.6.0", "tokio-native-tls", ] @@ -2750,7 +3238,7 @@ dependencies = [ "rand 0.8.3", "redox_syscall", "remove_dir_all", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2768,12 +3256,16 @@ dependencies = [ name = "tenebrous-api" version = "0.1.0" dependencies = [ + "juniper", + "juniper_warp", + "log", + "once_cell", "prost", "tenebrous-rpc", - "tokio", - "tokio-stream", - "tonic 0.4.3 (git+https://github.com/hyperium/tonic)", - "tonic-web", + "tokio 0.2.25", + "tonic", + "tracing-subscriber", + "warp", ] [[package]] @@ -2782,7 +3274,7 @@ version = "0.10.0" dependencies = [ "async-trait", "barrel", - "combine", + "combine 4.5.2", "dirs", "fuse-rust", "futures", @@ -2803,10 +3295,10 @@ dependencies = [ "tempfile", "tenebrous-rpc", "thiserror", - "tokio", + "tokio 1.6.0", "toml", - "tonic 0.4.3 (git+https://github.com/hyperium/tonic)", - "tonic-build 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tonic", + "tonic-build", "tracing-subscriber", "url", ] @@ -2816,8 +3308,8 @@ name = "tenebrous-rpc" version = "0.1.0" dependencies = [ "prost", - "tonic 0.4.3 (git+https://github.com/hyperium/tonic)", - "tonic-build 0.4.2 (git+https://github.com/hyperium/tonic)", + "tonic", + "tonic-build", ] [[package]] @@ -2825,10 +3317,6 @@ name = "tenebrous-web-ui" version = "0.1.0" dependencies = [ "grpc-web-client", - "prost", - "tenebrous-rpc", - "tonic 0.4.3 (git+https://github.com/hyperium/tonic)", - "tonic-build 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen", "yew", "yew-router", @@ -2872,7 +3360,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" dependencies = [ "libc", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2887,7 +3375,7 @@ dependencies = [ "stdweb", "time-macros", "version_check", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2928,6 +3416,30 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "tokio" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" +dependencies = [ + "bytes 0.5.6", + "fnv", + "futures-core", + "iovec", + "lazy_static", + "libc", + "memchr", + "mio 0.6.23", + "mio-named-pipes", + "mio-uds", + "num_cpus", + "pin-project-lite 0.1.12", + "signal-hook-registry", + "slab", + "tokio-macros 0.2.6", + "winapi 0.3.9", +] + [[package]] name = "tokio" version = "1.6.0" @@ -2935,17 +3447,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd3076b5c8cc18138b8f8814895c11eb4de37114a5d127bafdc5e55798ceef37" dependencies = [ "autocfg", - "bytes", + "bytes 1.0.1", "libc", "memchr", - "mio", + "mio 0.7.11", "num_cpus", "once_cell", "parking_lot", - "pin-project-lite", + "pin-project-lite 0.2.6", "signal-hook-registry", - "tokio-macros", - "winapi", + "tokio-macros 1.2.0", + "winapi 0.3.9", +] + +[[package]] +name = "tokio-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -2966,7 +3489,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" dependencies = [ "native-tls", - "tokio", + "tokio 1.6.0", ] [[package]] @@ -2976,8 +3499,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8864d706fdb3cc0843a49647ac892720dac98a6eeb818b77190592cf4994066" dependencies = [ "futures-core", - "pin-project-lite", - "tokio", + "pin-project-lite 0.2.6", + "tokio 1.6.0", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d9e878ad426ca286e4dcae09cbd4e1973a7f8987d97570e2469703dd7f5720c" +dependencies = [ + "futures-util", + "log", + "pin-project 0.4.28", + "tokio 0.2.25", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes 0.5.6", + "futures-core", + "futures-sink", + "log", + "pin-project-lite 0.1.12", + "tokio 0.2.25", ] [[package]] @@ -2986,12 +3536,12 @@ version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592" dependencies = [ - "bytes", + "bytes 1.0.1", "futures-core", "futures-sink", "log", - "pin-project-lite", - "tokio", + "pin-project-lite 0.2.6", + "tokio 1.6.0", ] [[package]] @@ -3008,46 +3558,25 @@ name = "tonic" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ac42cd97ac6bd2339af5bcabf105540e21e45636ec6fa6aae5e85d44db31be0" -dependencies = [ - "async-stream", - "base64", - "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "percent-encoding", - "pin-project", - "tokio-stream", - "tokio-util", - "tower-service", - "tracing", -] - -[[package]] -name = "tonic" -version = "0.4.3" -source = "git+https://github.com/hyperium/tonic?branch=master#3e95553c57c0a21a7ae150128ee0d35bc50f3b90" dependencies = [ "async-stream", "async-trait", - "base64", - "bytes", + "base64 0.13.0", + "bytes 1.0.1", "futures-core", "futures-util", - "h2", + "h2 0.3.3", "http", - "http-body", - "hyper", + "http-body 0.4.2", + "hyper 0.14.7", "percent-encoding", - "pin-project", + "pin-project 1.0.7", "prost", "prost-derive", - "tokio", + "tokio 1.6.0", "tokio-stream", - "tokio-util", + "tokio-util 0.6.7", "tower", - "tower-layer", "tower-service", "tracing", "tracing-futures", @@ -3065,34 +3594,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tonic-build" -version = "0.4.2" -source = "git+https://github.com/hyperium/tonic?branch=master#3e95553c57c0a21a7ae150128ee0d35bc50f3b90" -dependencies = [ - "proc-macro2", - "prost-build", - "quote", - "syn", -] - -[[package]] -name = "tonic-web" -version = "0.1.0" -source = "git+https://github.com/hyperium/tonic?branch=master#3e95553c57c0a21a7ae150128ee0d35bc50f3b90" -dependencies = [ - "base64", - "bytes", - "futures-core", - "http", - "http-body", - "hyper", - "pin-project", - "tonic 0.4.3 (git+https://github.com/hyperium/tonic)", - "tower-service", - "tracing", -] - [[package]] name = "tower" version = "0.4.8" @@ -3102,12 +3603,12 @@ dependencies = [ "futures-core", "futures-util", "indexmap", - "pin-project", + "pin-project 1.0.7", "rand 0.8.3", "slab", - "tokio", + "tokio 1.6.0", "tokio-stream", - "tokio-util", + "tokio-util 0.6.7", "tower-layer", "tower-service", "tracing", @@ -3133,7 +3634,7 @@ checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" dependencies = [ "cfg-if 1.0.0", "log", - "pin-project-lite", + "pin-project-lite 0.2.6", "tracing-attributes", "tracing-core", ] @@ -3164,7 +3665,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" dependencies = [ - "pin-project", + "pin-project 1.0.7", "tracing", ] @@ -3217,12 +3718,49 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +[[package]] +name = "tungstenite" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0308d80d86700c5878b9ef6321f020f29b1bb9d5ff3cab25e75e23f3a492a23" +dependencies = [ + "base64 0.12.3", + "byteorder", + "bytes 0.5.6", + "http", + "httparse", + "input_buffer", + "log", + "rand 0.7.3", + "sha-1", + "url", + "utf-8", +] + +[[package]] +name = "twoway" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b11b2b5241ba34be09c3cc85a36e56e48f9888862e19cedf23336d35316ed1" +dependencies = [ + "memchr", +] + [[package]] name = "typenum" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.5" @@ -3281,6 +3819,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "unreachable" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" +dependencies = [ + "void", +] + [[package]] name = "url" version = "2.2.2" @@ -3293,6 +3840,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "urlencoding" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a1f0175e03a0973cf4afd476bef05c26e228520400eb1fd473ad417b1c00ffb" + [[package]] name = "utf-8" version = "0.7.6" @@ -3321,6 +3874,12 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + [[package]] name = "walkdir" version = "2.3.2" @@ -3328,7 +3887,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", - "winapi", + "winapi 0.3.9", "winapi-util", ] @@ -3342,6 +3901,34 @@ dependencies = [ "try-lock", ] +[[package]] +name = "warp" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f41be6df54c97904af01aa23e613d4521eed7ab23537cede692d4058f6449407" +dependencies = [ + "bytes 0.5.6", + "futures", + "headers", + "http", + "hyper 0.13.10", + "log", + "mime", + "mime_guess", + "multipart", + "pin-project 0.4.28", + "scoped-tls", + "serde", + "serde_json", + "serde_urlencoded 0.6.1", + "tokio 0.2.25", + "tokio-tungstenite", + "tower-service", + "tracing", + "tracing-futures", + "urlencoding", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -3471,6 +4058,12 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6c48bd20df7e4ced539c12f570f937c6b4884928a87fee70a479d72f031d4e0" +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + [[package]] name = "winapi" version = "0.3.9" @@ -3481,6 +4074,12 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -3493,7 +4092,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -3508,7 +4107,17 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" dependencies = [ - "winapi", + "winapi 0.3.9", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", ] [[package]] @@ -3582,11 +4191,15 @@ checksum = "20f46279cd28a50e0e9271352ce6d7be7f10e6ba449c76544985e64222f5e999" dependencies = [ "cfg-if 0.1.10", "cfg-match", + "gloo", + "js-sys", "log", "nom 5.1.2", "serde", "serde_json", "wasm-bindgen", + "web-sys", + "yew", "yew-router-macro", "yew-router-route-parser", ] diff --git a/api/Cargo.toml b/api/Cargo.toml index 62bb22a..70f0a85 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -4,15 +4,19 @@ version = "0.1.0" authors = ["projectmoon "] edition = "2018" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -tonic = { git = "https://github.com/hyperium/tonic", branch = "master" } -tonic-web = { git = "https://github.com/hyperium/tonic", branch = "master" } +log = "0.4" +tracing-subscriber = "0.2" +tonic = { version = "0.4" } prost = "0.7" +once_cell = "1.7" tenebrous-rpc = { path = "../rpc" } -tokio-stream = { version = "0.1", features = ["net"] } +juniper = { git = "https://github.com/graphql-rust/juniper", branch = "master" } +juniper_rocket_async = { git = "https://github.com/graphql-rust/juniper", branch = "master" } +rocket = { git = "https://github.com/SergioBenitez/Rocket", branch = "master" } +warp = "0.2" +#tokio-stream = { version = "0.1", features = ["net"] } # needed for grpc-web? -[dependencies.tokio] -version = "1" -features = [ "full" ] +# [dependencies.tokio] +# version = "1" +# features = [ "full" ] diff --git a/api/src/grpc_web.rs b/api/src/grpc_web.rs new file mode 100644 index 0000000..2bdef9b --- /dev/null +++ b/api/src/grpc_web.rs @@ -0,0 +1,42 @@ +// use std::net::SocketAddr; +// use tenebrous_rpc::protos::web_api::{ +// web_api_server::{WebApi, WebApiServer}, +// RoomsListReply, UserIdRequest, +// }; +// use tokio::net::TcpListener; +// use tokio_stream::wrappers::TcpListenerStream; +// use tonic::{transport::Server, Request, Response, Status}; + +//grpc-web stuff +// struct WebApiService; + +// #[tonic::async_trait] +// impl WebApi for WebApiService { +// async fn list_room( +// &self, +// request: Request, +// ) -> Result, Status> { +// println!("Hello hopefully from a web browser"); +// Ok(Response::new(RoomsListReply { rooms: vec![] })) +// } +// } + +// #[tokio::main] +// pub async fn grpc_web() -> Result<(), Box> { +// let addr = SocketAddr::from(([127, 0, 0, 1], 10000)); +// let listener = TcpListener::bind(addr).await.expect("listener"); +// let url = format!("http://{}", listener.local_addr().unwrap()); +// println!("Listening at {}", url); + +// let svc = tonic_web::config() +// .allow_origins(vec!["http://localhost:8000"]) +// .enable(WebApiServer::new(WebApiService)); + +// let fut = Server::builder() +// .accept_http1(true) +// .add_service(svc) +// .serve_with_incoming(TcpListenerStream::new(listener)); + +// fut.await?; +// Ok(()) +// } diff --git a/api/src/main.rs b/api/src/main.rs index 8a11ebf..6f22cd8 100644 --- a/api/src/main.rs +++ b/api/src/main.rs @@ -1,41 +1,155 @@ -use std::net::SocketAddr; -use tenebrous_rpc::protos::web_api::{ - web_api_server::{WebApi, WebApiServer}, - RoomsListReply, UserIdRequest, +use juniper::{ + graphql_object, EmptyMutation, EmptySubscription, FieldError, FieldResult, GraphQLObject, + RootNode, }; -use tokio::net::TcpListener; -use tokio_stream::wrappers::TcpListenerStream; -use tonic::{transport::Server, Request, Response, Status}; +use once_cell::sync::OnceCell; +use rocket::{response::content, Rocket, State}; +use std::cell::RefCell; +use std::env; +use std::sync::{Arc, RwLock}; +use tenebrous_rpc::protos::dicebot::dicebot_client::DicebotClient; +use tenebrous_rpc::protos::dicebot::GetVariableRequest; +use tonic::{metadata::MetadataValue, transport::Channel as TonicChannel, Request as TonicRequest}; +use tracing_subscriber::filter::EnvFilter; -struct WebApiService; +//grpc stuff +async fn create_client( + shared_secret: &str, +) -> Result, Box> { + let channel = TonicChannel::from_static("http://0.0.0.0:9090") + .connect() + .await?; -#[tonic::async_trait] -impl WebApi for WebApiService { - async fn list_room( - &self, - request: Request, - ) -> Result, Status> { - println!("Hello hopefully from a web browser"); - Ok(Response::new(RoomsListReply { rooms: vec![] })) + let bearer = MetadataValue::from_str(&format!("Bearer {}", shared_secret))?; + let client = DicebotClient::with_interceptor(channel, move |mut req: TonicRequest<()>| { + req.metadata_mut().insert("authorization", bearer.clone()); + Ok(req) + }); + + Ok(client) +} + +//api stuff +#[derive(GraphQLObject)] +#[graphql(description = "User variable in a room.")] +struct UserVariable { + room_id: String, + variable_name: String, + value: i32, +} + +//graphql shit +#[derive(Clone)] +struct Context { + dicebot_client: DicebotClient, +} + +// To make our context usable by Juniper, we have to implement a marker trait. +impl juniper::Context for Context {} + +#[derive(Clone, Copy, Debug)] +struct Query; + +#[graphql_object( + // Here we specify the context type for the object. + // We need to do this in every type that + // needs access to the context. + context = Context, +)] +impl Query { + fn apiVersion() -> &str { + "1.0" + } + + async fn variable( + context: &mut Context, + room_id: String, + user_id: String, + variable: String, + ) -> FieldResult { + let request = TonicRequest::new(GetVariableRequest { + room_id: room_id.clone(), + user_id: user_id.clone(), + variable_name: variable.clone(), + }); + + let response = context + .dicebot_client + .clone() + .get_variable(request) + .await? + .into_inner(); + + Ok(UserVariable { + room_id: room_id.clone(), + variable_name: variable.clone(), + value: response.value, + }) } } -#[tokio::main] +type Schema = RootNode<'static, Query, EmptyMutation, EmptySubscription>; + +fn schema() -> Schema { + Schema::new( + Query, + EmptyMutation::::new(), + EmptySubscription::::new(), + ) +} + +//rocket stuff + +#[rocket::get("/")] +fn graphiql() -> content::Html { + juniper_rocket_async::graphiql_source("/graphql", None) +} + +#[rocket::get("/graphql?")] +fn get_graphql_handler( + context: &State, + request: juniper_rocket_async::GraphQLRequest, + schema: &State, +) -> juniper_rocket_async::GraphQLResponse { + request.execute_sync(&*schema, &*context) +} + +#[rocket::post("/graphql", data = "")] +fn post_graphql_handler( + context: &State, + request: juniper_rocket_async::GraphQLRequest, + schema: &State, +) -> juniper_rocket_async::GraphQLResponse { + request.execute_sync(&*schema, &*context) +} + +#[rocket::main] pub async fn main() -> Result<(), Box> { - let addr = SocketAddr::from(([127, 0, 0, 1], 10000)); - let listener = TcpListener::bind(addr).await.expect("listener"); - let url = format!("http://{}", listener.local_addr().unwrap()); - println!("Listening at {}", url); + let filter = if env::var("RUST_LOG").is_ok() { + EnvFilter::from_default_env() + } else { + EnvFilter::new("warp_async") + }; - let svc = tonic_web::config() - .allow_origins(vec!["http://localhost:8000"]) - .enable(WebApiServer::new(WebApiService)); + tracing_subscriber::fmt().with_env_filter(filter).init(); - let fut = Server::builder() - .accept_http1(true) - .add_service(svc) - .serve_with_incoming(TcpListenerStream::new(listener)); + let log = warp::log("warp_server"); + let client = create_client("abc123").await?; - fut.await?; + log::info!("Listening on 127.0.0.1:8080"); + let context = Context { + dicebot_client: client, + }; + + Rocket::build() + .manage(client) + .manage(schema()) + .mount( + "/", + rocket::routes![graphiql, get_graphql_handler, post_graphql_handler], + ) + .launch() + .await + .expect("server to launch"); Ok(()) } diff --git a/dicebot/Cargo.toml b/dicebot/Cargo.toml index 8db7b07..a19cefb 100644 --- a/dicebot/Cargo.toml +++ b/dicebot/Cargo.toml @@ -36,7 +36,7 @@ barrel = { version = "0.6", features = ["sqlite3"] } tempfile = "3" substring = "1.4" fuse-rust = "0.2" -tonic = { git = "https://github.com/hyperium/tonic", branch = "master" } +tonic = { version = "0.4" } prost = "0.7" tenebrous-rpc = { path = "../rpc" } diff --git a/dicebot/src/bin/tonic_client.rs b/dicebot/src/bin/tonic_client.rs index c2fec47..9177aff 100644 --- a/dicebot/src/bin/tonic_client.rs +++ b/dicebot/src/bin/tonic_client.rs @@ -10,12 +10,10 @@ async fn create_client( .await?; let bearer = MetadataValue::from_str(&format!("Bearer {}", shared_secret))?; - let client = DicebotClient::new(channel); - - // let client = DicebotClient::with_interceptor(channel, move |mut req: Request<()>| { - // req.metadata_mut().insert("authorization", bearer.clone()); - // Ok(req) - // }); + let client = DicebotClient::with_interceptor(channel, move |mut req: Request<()>| { + req.metadata_mut().insert("authorization", bearer.clone()); + Ok(req) + }); Ok(client) } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index fb26508..84d2a21 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -13,8 +13,8 @@ default = ["tonic/default", "tonic-build/default"] wasm = [ "tonic/codegen", "tonic/prost", "tonic-build/prost"] [build-dependencies] -tonic-build = { git = "https://github.com/hyperium/tonic", branch = "master", default_features = false } +tonic-build = { version = "0.4", default_features = false } [dependencies] -tonic = { git = "https://github.com/hyperium/tonic", branch = "master", default_features = false } +tonic = { version = "0.4", default_features = false } prost = "0.7" \ No newline at end of file diff --git a/web-ui/crate/Cargo.toml b/web-ui/crate/Cargo.toml index 8c1dc4c..dc064f4 100644 --- a/web-ui/crate/Cargo.toml +++ b/web-ui/crate/Cargo.toml @@ -9,21 +9,18 @@ edition = "2018" [lib] crate-type = ["cdylib", "rlib"] - -[build-dependencies] -tonic-build = { version = "0.4", default-features = false, features = ["prost"] } - [dependencies] -yew = { version = "0.17", default_features = false }#features = [ "agent", "web-sys" ] } +yew = { version = "0.17" } yewtil = {version = "0.3" } -yew-router = {version = "0.14", default_features = false } -yewdux = {version = "^0.6", default_features = false } -wasm-bindgen = { version = "0.2", default-features = false, features = ["serde-serialize"] } +yew-router = {version = "0.14" } +yewdux = {version = "^0.6" } +wasm-bindgen = { version = "0.2" } grpc-web-client = "0.1" -prost = { version = "0.7.0", default-features = false } -tonic = { git = "https://github.com/hyperium/tonic", branch = "master", default-features = false, features = ["codegen", "prost"] } -tenebrous-rpc = { path = "../../rpc", default_features = false, features = ["wasm"] } -# [dependencies.tokio] -# version = "1" -# features = [ "rt", "sync" ] +# hopefully we can add grpc-web later instead of graphql. +# prost = { version = "0.7.0", default-features = false } +# tonic = { git = "https://github.com/hyperium/tonic", branch = "master", default-features = false, features = ["codegen", "prost"] } +# tenebrous-rpc = { path = "../../rpc", default_features = false, features = ["wasm"] } + +# [build-dependencies] +# tonic-build = { version = "0.4", default-features = false, features = ["prost"] } diff --git a/web-ui/crate/src/grpc.rs b/web-ui/crate/src/grpc.rs index 74aa3f4..90fd87a 100644 --- a/web-ui/crate/src/grpc.rs +++ b/web-ui/crate/src/grpc.rs @@ -1,15 +1,15 @@ -async fn test_grpc_web() { - use grpc_web_client::Client as GrpcWebClient; - use tenebrous_rpc::protos::web_api::web_api_client::WebApiClient as TheCloud; - use tenebrous_rpc::protos::web_api::{RoomsListReply, UserIdRequest}; +// async fn test_grpc_web() { +// use grpc_web_client::Client as GrpcWebClient; +// use tenebrous_rpc::protos::web_api::web_api_client::WebApiClient as TheCloud; +// use tenebrous_rpc::protos::web_api::{RoomsListReply, UserIdRequest}; - let client = GrpcWebClient::new("http://localhost:10000".to_string()); - let mut client = TheCloud::new(client); +// let client = GrpcWebClient::new("http://localhost:10000".to_string()); +// let mut client = TheCloud::new(client); - let request = tonic::Request::new(UserIdRequest { - user_id: "WebTonic".into(), - }); +// let request = tonic::Request::new(UserIdRequest { +// user_id: "WebTonic".into(), +// }); - let response = client.list_room(request).await.unwrap().into_inner(); - println!("Room reply: {:?}", response); -} +// let response = client.list_room(request).await.unwrap().into_inner(); +// println!("Room reply: {:?}", response); +// }