mirror of
https://github.com/mikedilger/chorus.git
synced 2026-01-03 06:15:33 +00:00
Switch to tracing-subscriber and setup for tokio-console
This commit is contained in:
parent
280e9a90a6
commit
6218c83b5b
2
.cargo/config
Normal file
2
.cargo/config
Normal file
@ -0,0 +1,2 @@
|
||||
[build]
|
||||
rustflags = ["--cfg", "tokio_unstable"]
|
||||
580
Cargo.lock
generated
580
Cargo.lock
generated
@ -26,12 +26,74 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1"
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.49",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "axum"
|
||||
version = "0.6.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum-core",
|
||||
"bitflags 1.3.2",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"itoa",
|
||||
"matchit",
|
||||
"memchr",
|
||||
"mime",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"sync_wrapper",
|
||||
"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 = "backtrace"
|
||||
version = "0.3.69"
|
||||
@ -145,13 +207,12 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
name = "chorus"
|
||||
version = "1.0.4"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"console-subscriber",
|
||||
"futures",
|
||||
"heed",
|
||||
"hyper",
|
||||
"hyper-tungstenite",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"mmap-append",
|
||||
"ron",
|
||||
"rustls-pemfile",
|
||||
@ -161,9 +222,47 @@ dependencies = [
|
||||
"textnonce",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console-api"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2895653b4d9f1538a83970077cb01dfc77a4810524e51a110944688e916b18e"
|
||||
dependencies = [
|
||||
"prost",
|
||||
"prost-types",
|
||||
"tonic",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console-subscriber"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4cf42660ac07fcebed809cfe561dd8730bcd35b075215e6479c516bcd0d11cb"
|
||||
dependencies = [
|
||||
"console-api",
|
||||
"crossbeam-channel",
|
||||
"crossbeam-utils",
|
||||
"futures",
|
||||
"hdrhistogram",
|
||||
"humantime",
|
||||
"prost-types",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thread_local",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tonic",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.12"
|
||||
@ -173,6 +272,24 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.11"
|
||||
@ -224,17 +341,16 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.10.2"
|
||||
name = "either"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
|
||||
dependencies = [
|
||||
"humantime",
|
||||
"is-terminal",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
@ -252,6 +368,16 @@ version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
@ -323,7 +449,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.49",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -394,6 +520,50 @@ version = "0.28.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.3.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"http",
|
||||
"indexmap 2.2.3",
|
||||
"slab",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
|
||||
|
||||
[[package]]
|
||||
name = "hdrhistogram"
|
||||
version = "7.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "765c9198f173dd59ce26ff9f95ef0aafd0a0fe01fb9d72841bc5066a4c06511d"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
"byteorder",
|
||||
"flate2",
|
||||
"nom",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heed"
|
||||
version = "0.20.0-alpha.8"
|
||||
@ -493,6 +663,7 @@ dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"httparse",
|
||||
@ -506,6 +677,18 @@ dependencies = [
|
||||
"want",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-timeout"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
|
||||
dependencies = [
|
||||
"hyper",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
"tokio-io-timeout",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-tungstenite"
|
||||
version = "0.11.1"
|
||||
@ -530,14 +713,32 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.12"
|
||||
name = "indexmap"
|
||||
version = "1.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b"
|
||||
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
"autocfg",
|
||||
"hashbrown 0.12.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.14.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -590,6 +791,21 @@ version = "0.4.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||
|
||||
[[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.1"
|
||||
@ -605,6 +821,18 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mime"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.7.2"
|
||||
@ -634,6 +862,35 @@ dependencies = [
|
||||
"memmap2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
|
||||
dependencies = [
|
||||
"overload",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.16.0"
|
||||
@ -659,6 +916,12 @@ 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 = "page_size"
|
||||
version = "0.5.0"
|
||||
@ -728,7 +991,7 @@ dependencies = [
|
||||
"phf_shared",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.49",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -740,6 +1003,26 @@ dependencies = [
|
||||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0"
|
||||
dependencies = [
|
||||
"pin-project-internal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-internal"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.49",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.13"
|
||||
@ -767,6 +1050,38 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"prost-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-derive"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-types"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13"
|
||||
dependencies = [
|
||||
"prost",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.35"
|
||||
@ -864,8 +1179,17 @@ checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
"regex-automata 0.4.5",
|
||||
"regex-syntax 0.8.2",
|
||||
]
|
||||
|
||||
[[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]]
|
||||
@ -876,9 +1200,15 @@ checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.2",
|
||||
]
|
||||
|
||||
[[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.2"
|
||||
@ -962,6 +1292,12 @@ dependencies = [
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.17"
|
||||
@ -1021,7 +1357,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.49",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1046,6 +1382,15 @@ dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[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 = "signal-hook-registry"
|
||||
version = "1.4.1"
|
||||
@ -1092,6 +1437,17 @@ version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.49"
|
||||
@ -1103,6 +1459,12 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sync_wrapper"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
|
||||
|
||||
[[package]]
|
||||
name = "synchronoise"
|
||||
version = "1.0.1"
|
||||
@ -1124,15 +1486,6 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textnonce"
|
||||
version = "1.0.0"
|
||||
@ -1160,7 +1513,17 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.49",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1194,9 +1557,20 @@ dependencies = [
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"tracing",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-io-timeout"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
|
||||
dependencies = [
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.2.0"
|
||||
@ -1205,7 +1579,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.49",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1218,6 +1592,17 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-stream"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-tungstenite"
|
||||
version = "0.20.1"
|
||||
@ -1230,6 +1615,74 @@ dependencies = [
|
||||
"tungstenite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tonic"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
"base64 0.21.7",
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"hyper-timeout",
|
||||
"percent-encoding",
|
||||
"pin-project",
|
||||
"prost",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tower",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower"
|
||||
version = "0.4.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"indexmap 1.9.3",
|
||||
"pin-project",
|
||||
"pin-project-lite",
|
||||
"rand 0.8.5",
|
||||
"slab",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"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"
|
||||
@ -1243,9 +1696,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
|
||||
dependencies = [
|
||||
"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 2.0.49",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.32"
|
||||
@ -1253,6 +1718,36 @@ 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]]
|
||||
@ -1330,6 +1825,12 @@ version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
@ -1373,15 +1874,6 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
||||
@ -8,21 +8,22 @@ repository = "https://github.com/mikedilger/chorus"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
env_logger = "0.10"
|
||||
console-subscriber = "0.1"
|
||||
futures = "0.3"
|
||||
heed = { git = "https://github.com/meilisearch/heed", rev = "64fd6fec293c0dee94855b8267557ce03e7ce5d8" }
|
||||
hyper = { version = "0.14", features = [ "http1", "server", "runtime", "stream" ] }
|
||||
hyper-tungstenite = "0.11"
|
||||
lazy_static = "1.4"
|
||||
log = "0.4"
|
||||
mmap-append = { git = "https://github.com/mikedilger/mmap-append", rev = "0d20e193e7f13a442865a4a40a5da9a120e87411" }
|
||||
ron = "0.8"
|
||||
rustls-pemfile = "1.0"
|
||||
secp256k1 = { version = "0.28", features = [ "hashes", "global-context", "rand-std" ] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
textnonce = "1"
|
||||
tokio = { version = "1", features = [ "full" ] }
|
||||
tokio = { version = ">=1.21.0", features = [ "full", "tracing" ] }
|
||||
tokio-rustls = "0.24"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
url = "2.5"
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
15
src/error.rs
15
src/error.rs
@ -103,6 +103,9 @@ pub enum ChorusError {
|
||||
// Rustls
|
||||
Rustls(tokio_rustls::rustls::Error),
|
||||
|
||||
// Tracing Setup error
|
||||
TracingSetupError(tracing::subscriber::SetGlobalDefaultError),
|
||||
|
||||
// Tungstenite
|
||||
Tungstenite(hyper_tungstenite::tungstenite::error::Error),
|
||||
|
||||
@ -167,6 +170,7 @@ impl std::fmt::Display for ChorusError {
|
||||
ChorusError::NoPrivateKey => write!(f, "Private Key Not Found"),
|
||||
ChorusError::Restricted => write!(f, "Restricted"),
|
||||
ChorusError::Rustls(e) => write!(f, "{e}"),
|
||||
ChorusError::TracingSetupError(e) => write!(f, "{e}"),
|
||||
ChorusError::Tungstenite(e) => write!(f, "{e}"),
|
||||
ChorusError::Scraper => write!(f, "Filter is underspecified. Scrapers are not allowed"),
|
||||
ChorusError::TooManyErrors => write!(f, "Too many errors"),
|
||||
@ -190,6 +194,7 @@ impl StdError for ChorusError {
|
||||
ChorusError::Io(e) => Some(e),
|
||||
ChorusError::Lmdb(e) => Some(e),
|
||||
ChorusError::Rustls(e) => Some(e),
|
||||
ChorusError::TracingSetupError(e) => Some(e),
|
||||
ChorusError::Tungstenite(e) => Some(e),
|
||||
ChorusError::UrlParse(e) => Some(e),
|
||||
ChorusError::Utf8(e) => Some(e),
|
||||
@ -345,3 +350,13 @@ impl From<url::ParseError> for Error {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<tracing::subscriber::SetGlobalDefaultError> for Error {
|
||||
#[track_caller]
|
||||
fn from(err: tracing::subscriber::SetGlobalDefaultError) -> Self {
|
||||
Error {
|
||||
inner: ChorusError::TracingSetupError(err),
|
||||
location: std::panic::Location::caller(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
69
src/main.rs
69
src/main.rs
@ -42,7 +42,7 @@ use tungstenite::Message;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Error> {
|
||||
env_logger::init();
|
||||
console_subscriber::init();
|
||||
|
||||
// Get args (config path)
|
||||
let mut args = env::args();
|
||||
@ -58,7 +58,7 @@ async fn main() -> Result<(), Error> {
|
||||
file.read_to_string(&mut contents)?;
|
||||
let friendly_config: FriendlyConfig = ron::from_str(&contents)?;
|
||||
let config: Config = friendly_config.into_config()?;
|
||||
log::debug!("Loaded config file.");
|
||||
tracing::debug!("Loaded config file.");
|
||||
|
||||
// Setup store
|
||||
let store = Store::new(&config.data_directory, config.allow_scraping)?;
|
||||
@ -66,16 +66,16 @@ async fn main() -> Result<(), Error> {
|
||||
|
||||
// TLS setup
|
||||
let maybe_tls_acceptor = if config.use_tls {
|
||||
log::info!("Using TLS");
|
||||
tracing::info!("Using TLS");
|
||||
Some(tls::tls_acceptor(&config)?)
|
||||
} else {
|
||||
log::info!("Not using TLS");
|
||||
tracing::info!("Not using TLS");
|
||||
None
|
||||
};
|
||||
|
||||
// Bind listener to port
|
||||
let listener = TcpListener::bind((&*config.ip_address, config.port)).await?;
|
||||
log::info!("Running on {}:{}", config.ip_address, config.port);
|
||||
tracing::info!("Running on {}:{}", config.ip_address, config.port);
|
||||
|
||||
// Store config into GLOBALS
|
||||
let _ = GLOBALS.config.set(config);
|
||||
@ -88,15 +88,15 @@ async fn main() -> Result<(), Error> {
|
||||
tokio::select! {
|
||||
// Exits gracefully upon exit-type signals
|
||||
v = interrupt_signal.recv() => if v.is_some() {
|
||||
log::info!("SIGINT");
|
||||
tracing::info!("SIGINT");
|
||||
break;
|
||||
},
|
||||
v = quit_signal.recv() => if v.is_some() {
|
||||
log::info!("SIGQUIT");
|
||||
tracing::info!("SIGQUIT");
|
||||
break;
|
||||
},
|
||||
v = terminate_signal.recv() => if v.is_some() {
|
||||
log::info!("SIGTERM");
|
||||
tracing::info!("SIGTERM");
|
||||
break;
|
||||
},
|
||||
|
||||
@ -108,7 +108,7 @@ async fn main() -> Result<(), Error> {
|
||||
if let Some(ban_until) = GLOBALS.banlist.read().await.get(&ipaddr) {
|
||||
let now = Time::now();
|
||||
if *ban_until > now {
|
||||
log::debug!("{peer_addr}: Blocking reconnection until {ban_until}");
|
||||
tracing::debug!("{peer_addr}: Blocking reconnection until {ban_until}");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -117,10 +117,10 @@ async fn main() -> Result<(), Error> {
|
||||
let tls_acceptor_clone = tls_acceptor.clone();
|
||||
tokio::spawn(async move {
|
||||
match tls_acceptor_clone.accept(tcp_stream).await {
|
||||
Err(e) => log::error!("{}", e),
|
||||
Err(e) => tracing::error!("{}", e),
|
||||
Ok(tls_stream) => {
|
||||
if let Err(e) = serve(MaybeTlsStream::Rustls(tls_stream), peer_addr).await {
|
||||
log::error!("{}", e);
|
||||
tracing::error!("{}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -141,10 +141,11 @@ async fn main() -> Result<(), Error> {
|
||||
// Wait for active websockets to shutdown gracefully
|
||||
let mut num_clients = GLOBALS.num_clients.load(Ordering::Relaxed);
|
||||
if num_clients != 0 {
|
||||
log::info!("Waiting for {num_clients} websockets to shutdown...");
|
||||
tracing::info!("Waiting for {num_clients} websockets to shutdown...");
|
||||
|
||||
// We will check if all clients have shutdown every 25ms
|
||||
let interval = tokio::time::interval(Duration::from_millis(25));
|
||||
let mut interval = tokio::time::interval(Duration::from_millis(25));
|
||||
let _ = interval.tick(); // consume the first tick
|
||||
tokio::pin!(interval);
|
||||
|
||||
while num_clients != 0 {
|
||||
@ -167,7 +168,7 @@ async fn main() -> Result<(), Error> {
|
||||
}
|
||||
}
|
||||
|
||||
log::info!("Syncing and shutting down.");
|
||||
tracing::info!("Syncing and shutting down.");
|
||||
let _ = GLOBALS.store.get().unwrap().sync();
|
||||
|
||||
Ok(())
|
||||
@ -191,12 +192,12 @@ async fn serve(stream: MaybeTlsStream<TcpStream>, peer_addr: SocketAddr) -> Resu
|
||||
// do nothing
|
||||
} else {
|
||||
// Print in detail
|
||||
log::error!("{:?}", src);
|
||||
tracing::error!("{:?}", src);
|
||||
}
|
||||
} else {
|
||||
// Print in less detail
|
||||
let e: Error = he.into();
|
||||
log::error!("{}", e);
|
||||
tracing::error!("{}", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -258,7 +259,7 @@ async fn handle_http_request(
|
||||
// Increment count of active websockets
|
||||
let old_num_websockets = GLOBALS.num_clients.fetch_add(1, Ordering::SeqCst);
|
||||
|
||||
log::info!(
|
||||
tracing::info!(
|
||||
"{}: websocket started (making {} active websockets)",
|
||||
peer,
|
||||
old_num_websockets + 1
|
||||
@ -281,7 +282,7 @@ async fn handle_http_request(
|
||||
ban_seconds = 60;
|
||||
}
|
||||
_ => {
|
||||
log::error!("{}: {}", peer, e);
|
||||
tracing::error!("{}: {}", peer, e);
|
||||
ban_seconds = 15;
|
||||
}
|
||||
}
|
||||
@ -290,7 +291,7 @@ async fn handle_http_request(
|
||||
// Decrement count of active websockets
|
||||
let old_num_websockets = GLOBALS.num_clients.fetch_sub(1, Ordering::SeqCst);
|
||||
|
||||
log::info!(
|
||||
tracing::info!(
|
||||
"{}: websocket ended (making {} active websockets)",
|
||||
peer,
|
||||
old_num_websockets - 1
|
||||
@ -300,7 +301,7 @@ async fn handle_http_request(
|
||||
Globals::ban(peer.ip(), ban_seconds).await;
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("{}", e);
|
||||
tracing::error!("{}", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -347,7 +348,7 @@ impl WebSocketService {
|
||||
let _ = interval.tick().await; // consume the first tick
|
||||
tokio::pin!(interval);
|
||||
|
||||
loop {
|
||||
'handle: loop {
|
||||
tokio::select! {
|
||||
instant = interval.tick() => {
|
||||
// Drop them if they have no subscriptions
|
||||
@ -355,7 +356,7 @@ impl WebSocketService {
|
||||
// And they are idle for 5 seconds with no subscriptions
|
||||
if last_message_at + Duration::from_secs(5) < instant {
|
||||
self.websocket.send(Message::Close(None)).await?;
|
||||
break;
|
||||
break 'handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -366,12 +367,12 @@ impl WebSocketService {
|
||||
let message = message?;
|
||||
if let Err(e) = self.handle_websocket_message(message).await {
|
||||
if let Err(e) = self.websocket.close(None).await {
|
||||
log::info!("Err on websocket close: {e}");
|
||||
tracing::info!("Err on websocket close: {e}");
|
||||
}
|
||||
return Err(e);
|
||||
}
|
||||
},
|
||||
None => break, // the websocket is closed
|
||||
None => break 'handle, // the websocket is closed
|
||||
}
|
||||
},
|
||||
offset_result = new_events.recv() => {
|
||||
@ -381,7 +382,7 @@ impl WebSocketService {
|
||||
_r = shutting_down.changed() => {
|
||||
// Shutdown the websocket gracefully
|
||||
self.websocket.send(Message::Close(None)).await?;
|
||||
break;
|
||||
break 'handle;
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -425,15 +426,15 @@ impl WebSocketService {
|
||||
async fn handle_websocket_message(&mut self, message: Message) -> Result<(), Error> {
|
||||
match message {
|
||||
Message::Text(msg) => {
|
||||
log::trace!("{}: <= {}", self.peer, msg);
|
||||
tracing::trace!("{}: <= {}", self.peer, msg);
|
||||
// This is defined in nostr.rs
|
||||
if let Err(e) = self.handle_nostr_message(&msg).await {
|
||||
self.errcount += 1;
|
||||
log::error!("{}: {e}", self.peer);
|
||||
tracing::error!("{}: {e}", self.peer);
|
||||
if msg.len() < 2048 {
|
||||
log::error!("{}: msg was {}", self.peer, msg);
|
||||
tracing::error!("{}: msg was {}", self.peer, msg);
|
||||
} else {
|
||||
log::error!("{}: msg was {} ...", self.peer, &msg[..2048]);
|
||||
tracing::error!("{}: msg was {} ...", self.peer, &msg[..2048]);
|
||||
}
|
||||
let reply = NostrReply::Notice(format!("error: {}", e));
|
||||
self.websocket.send(Message::text(reply.as_json())).await?;
|
||||
@ -451,7 +452,7 @@ impl WebSocketService {
|
||||
"binary messages are not processed by this relay".to_owned(),
|
||||
);
|
||||
self.websocket.send(Message::text(reply.as_json())).await?;
|
||||
log::info!(
|
||||
tracing::info!(
|
||||
"{}: Received unhandled binary message: {:02X?}",
|
||||
self.peer,
|
||||
msg
|
||||
@ -459,22 +460,22 @@ impl WebSocketService {
|
||||
}
|
||||
Message::Ping(msg) => {
|
||||
// No need to send a reply: tungstenite takes care of this for you.
|
||||
log::debug!("{}: Received ping message: {:02X?}", self.peer, msg);
|
||||
tracing::debug!("{}: Received ping message: {:02X?}", self.peer, msg);
|
||||
}
|
||||
Message::Pong(msg) => {
|
||||
log::debug!("{}: Received pong message: {:02X?}", self.peer, msg);
|
||||
tracing::debug!("{}: Received pong message: {:02X?}", self.peer, msg);
|
||||
}
|
||||
Message::Close(msg) => {
|
||||
// No need to send a reply: tungstenite takes care of this for you.
|
||||
if let Some(msg) = &msg {
|
||||
log::debug!(
|
||||
tracing::debug!(
|
||||
"{}: Received close message with code {} and message: {}",
|
||||
self.peer,
|
||||
msg.code,
|
||||
msg.reason
|
||||
);
|
||||
} else {
|
||||
log::debug!("{}: Received close message", self.peer);
|
||||
tracing::debug!("{}: Received close message", self.peer);
|
||||
}
|
||||
}
|
||||
Message::Frame(_msg) => {
|
||||
|
||||
@ -10,6 +10,7 @@ use hyper_tungstenite::tungstenite::Message;
|
||||
use url::Url;
|
||||
|
||||
impl WebSocketService {
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub async fn handle_nostr_message(&mut self, msg: &str) -> Result<(), Error> {
|
||||
// If the msg is large, grow the session buffer
|
||||
// (it will be freed when they disconnect)
|
||||
@ -33,7 +34,7 @@ impl WebSocketService {
|
||||
} else if &input[inpos..inpos + 5] == b"AUTH\"" {
|
||||
self.auth(msg, inpos + 5).await?;
|
||||
} else {
|
||||
log::warn!("{}: Received unhandled text message: {}", self.peer, msg);
|
||||
tracing::warn!("{}: Received unhandled text message: {}", self.peer, msg);
|
||||
let reply = NostrReply::Notice("Command unrecognized".to_owned());
|
||||
self.websocket.send(Message::text(reply.as_json())).await?;
|
||||
}
|
||||
@ -138,7 +139,7 @@ impl WebSocketService {
|
||||
// Store subscription
|
||||
self.subscriptions.insert(subid.to_owned(), filters);
|
||||
|
||||
log::debug!(
|
||||
tracing::debug!(
|
||||
"{}, new subscription \"{subid}\", {} total",
|
||||
self.peer,
|
||||
self.subscriptions.len()
|
||||
@ -179,11 +180,11 @@ impl WebSocketService {
|
||||
"That event is deleted".to_string(),
|
||||
),
|
||||
ChorusError::EventIsInvalid(ref why) => {
|
||||
log::error!("{}: {}", self.peer, e);
|
||||
tracing::error!("{}: {}", self.peer, e);
|
||||
NostrReply::Ok(id, false, NostrReplyPrefix::Invalid, why.to_string())
|
||||
}
|
||||
ChorusError::Restricted => {
|
||||
log::error!("{}: {}", self.peer, e);
|
||||
tracing::error!("{}: {}", self.peer, e);
|
||||
NostrReply::Ok(
|
||||
id,
|
||||
false,
|
||||
|
||||
@ -56,7 +56,7 @@ impl EventStore {
|
||||
// Memory map it
|
||||
let event_map = unsafe { MmapAppend::new(&event_map_file, new)? };
|
||||
|
||||
log::info!(
|
||||
tracing::info!(
|
||||
"Event Store: new={:?} end={} len={}",
|
||||
new,
|
||||
event_map.get_end(),
|
||||
|
||||
@ -17,7 +17,7 @@ impl Store {
|
||||
u32::from_be_bytes(migration_level_bytes[..4].try_into().unwrap())
|
||||
};
|
||||
|
||||
log::info!("Storage migration level = {}", migration_level);
|
||||
tracing::info!("Storage migration level = {}", migration_level);
|
||||
|
||||
while migration_level < CURRENT_MIGRATION_LEVEL {
|
||||
self.migrate_to(&mut txn, migration_level + 1)?;
|
||||
@ -35,7 +35,7 @@ impl Store {
|
||||
}
|
||||
|
||||
fn migrate_to(&self, txn: &mut RwTxn<'_>, level: u32) -> Result<(), Error> {
|
||||
log::info!("Migrating database to {}", level);
|
||||
tracing::info!("Migrating database to {}", level);
|
||||
match level {
|
||||
1 => self.migrate_to_1(txn)?,
|
||||
_ => panic!("Unknown migration level {level}"),
|
||||
|
||||
@ -10,6 +10,7 @@ use heed::types::{OwnedType, UnalignedSlice, Unit, U64};
|
||||
use heed::{Database, Env, EnvFlags, EnvOpenOptions, RwTxn};
|
||||
use std::fs;
|
||||
use std::ops::Bound;
|
||||
use tracing::instrument;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Store {
|
||||
@ -42,7 +43,7 @@ impl Store {
|
||||
let env = match builder.open(&dir) {
|
||||
Ok(env) => env,
|
||||
Err(e) => {
|
||||
log::error!("Unable to open LMDB at {}", dir);
|
||||
tracing::error!("Unable to open LMDB at {}", dir);
|
||||
return Err(e.into());
|
||||
}
|
||||
};
|
||||
@ -90,10 +91,10 @@ impl Store {
|
||||
.create(&mut txn)?;
|
||||
|
||||
if let Ok(count) = ids.len(&txn) {
|
||||
log::info!("{count} events in storage");
|
||||
tracing::info!("{count} events in storage");
|
||||
}
|
||||
if let Ok(count) = deleted_offsets.len(&txn) {
|
||||
log::info!("{count} deleted events in the map");
|
||||
tracing::info!("{count} deleted events in the map");
|
||||
}
|
||||
|
||||
txn.commit()?;
|
||||
@ -226,9 +227,10 @@ impl Store {
|
||||
}
|
||||
|
||||
/// Find all events that match the filter
|
||||
#[instrument(skip(self, screen))]
|
||||
pub fn find_events<F>(&self, filter: Filter, screen: F) -> Result<Vec<Event>, Error>
|
||||
where
|
||||
F: Fn(&Event) -> bool,
|
||||
F: Fn(&Event) -> bool
|
||||
{
|
||||
let mut output: Vec<Event> = Vec::new();
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ use hyper::{Body, Request, Response, StatusCode};
|
||||
use std::net::SocketAddr;
|
||||
|
||||
pub async fn serve_http(peer: SocketAddr, request: Request<Body>) -> Result<Response<Body>, Error> {
|
||||
log::debug!("{}: HTTP request for {}", peer, request.uri());
|
||||
tracing::debug!("{}: HTTP request for {}", peer, request.uri());
|
||||
let response = Response::builder()
|
||||
.header("Access-Control-Allow-Origin", "*")
|
||||
.header("Access-Control-Allow-Headers", "*")
|
||||
@ -16,7 +16,7 @@ pub async fn serve_http(peer: SocketAddr, request: Request<Body>) -> Result<Resp
|
||||
}
|
||||
|
||||
pub async fn serve_nip11(peer: SocketAddr) -> Result<Response<Body>, Error> {
|
||||
log::debug!("{}: sent NIP-11", peer);
|
||||
tracing::debug!("{}: sent NIP-11", peer);
|
||||
let rid = {
|
||||
let config = GLOBALS.config.get().unwrap();
|
||||
GLOBALS.rid.get_or_init(|| build_rid(config))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user