From 82916102bf3387c765c1022bdb03fb5b814623fb Mon Sep 17 00:00:00 2001 From: Hannes de Jager Date: Fri, 2 Apr 2021 10:15:51 +0200 Subject: [PATCH] Update slog-redis dependencies and bump version The dependencies of the bundled slog-redis crate was rather outdated. In this commit I upgrade the dependencies and then also: - Improve the documentation - Add a contribution guide - Add a makefile so we can do make pr-prep - Improve the pr-prep target of the parent project so that it builds the whole workspace. --- CONTRIBUTING.md | 3 + Cargo.lock | 440 +++++--------------------------- Cargo.toml | 2 +- Makefile | 8 +- README.md | 2 +- crates/redislog/CONTRIBUTING.md | 35 +++ crates/redislog/Cargo.toml | 16 +- crates/redislog/Makefile | 33 +++ crates/redislog/README.md | 37 +++ crates/redislog/src/lib.rs | 63 ++++- 10 files changed, 246 insertions(+), 393 deletions(-) create mode 100644 crates/redislog/CONTRIBUTING.md create mode 100644 crates/redislog/Makefile diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5fa7a6e..191a0bf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,8 @@ # Contributing to unFTP +Great projects are never established alone. Therefore we thank you for your interest to help out and offer this guide to +help you along. + unFTP welcomes contribution from everyone in the form of suggestions, bug reports, pull requests, and feedback. Please reach out here in a GitHub issue if we can do anything to help you contribute. diff --git a/Cargo.lock b/Cargo.lock index 345f967..ff594fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" dependencies = [ - "winapi 0.3.8", + "winapi", ] [[package]] @@ -24,12 +24,6 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d663a8e9a99154b5fb793032533f6328da35e23aac63d5c152279aa8ba356825" -[[package]] -name = "ascii" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" - [[package]] name = "async-trait" version = "0.1.48" @@ -49,7 +43,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", - "winapi 0.3.8", + "winapi", ] [[package]] @@ -88,22 +82,6 @@ version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - [[package]] name = "bytes" version = "1.0.1" @@ -142,7 +120,7 @@ dependencies = [ "num-traits", "serde", "time", - "winapi 0.3.8", + "winapi", ] [[package]] @@ -180,15 +158,12 @@ dependencies = [ [[package]] name = "combine" -version = "3.8.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" +checksum = "cc4369b5e4c0cddf64ad8981c0111e7df4f7078f4d6ba98fb31f2e17c4c57b7e" dependencies = [ - "ascii", - "byteorder", - "either", + "bytes", "memchr", - "unreachable", ] [[package]] @@ -214,18 +189,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.1", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", + "crossbeam-utils", ] [[package]] @@ -277,9 +241,15 @@ checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users", - "winapi 0.3.8", + "winapi", ] +[[package]] +name = "dtoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" + [[package]] name = "either" version = "1.5.3" @@ -292,28 +262,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" -[[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 = "futures" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" - [[package]] name = "futures" version = "0.3.13" @@ -427,7 +375,7 @@ dependencies = [ "libc", "libgit2-sys", "log", - "url 2.1.1", + "url", ] [[package]] @@ -436,7 +384,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5" dependencies = [ - "bytes 1.0.1", + "bytes", "fnv", "futures-core", "futures-sink", @@ -465,7 +413,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" dependencies = [ - "bytes 1.0.1", + "bytes", "fnv", "itoa", ] @@ -476,7 +424,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" dependencies = [ - "bytes 1.0.1", + "bytes", "http", ] @@ -498,7 +446,7 @@ version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8e946c2b1349055e0b72ae281b238baf1a3ea7307c7e9f9d64673bdd9c26ac7" dependencies = [ - "bytes 1.0.1", + "bytes", "futures-channel", "futures-core", "futures-util", @@ -533,17 +481,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "idna" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "idna" version = "0.2.0" @@ -570,15 +507,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485" -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - [[package]] name = "itertools" version = "0.10.0" @@ -612,16 +540,6 @@ dependencies = [ "wasm-bindgen", ] -[[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" @@ -653,10 +571,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffd1f741c3c67cc0ac7d788c8d84c17838a121e40bec0608447d7f7849dfea42" dependencies = [ "async-trait", - "bytes 1.0.1", + "bytes", "chrono", "derive_more", - "futures 0.3.13", + "futures", "itertools", "lazy_static", "prometheus", @@ -721,12 +639,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.3.3" @@ -739,25 +651,6 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" -[[package]] -name = "mio" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" -dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow 0.2.1", - "net2", - "slab", - "winapi 0.2.8", -] - [[package]] name = "mio" version = "0.7.6" @@ -766,21 +659,9 @@ checksum = "f33bc887064ef1fd66020c9adfc45bb9f33d75a42096c81e7c56c65b75dd1a8b" dependencies = [ "libc", "log", - "miow 0.3.6", + "miow", "ntapi", - "winapi 0.3.8", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", + "winapi", ] [[package]] @@ -790,18 +671,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ "socket2", - "winapi 0.3.8", -] - -[[package]] -name = "net2" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.8", + "winapi", ] [[package]] @@ -810,7 +680,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a31937dea023539c72ddae0e3571deadc1414b300483fa7aaec176168cfa9d2" dependencies = [ - "winapi 0.3.8", + "winapi", ] [[package]] @@ -874,17 +744,6 @@ dependencies = [ "libc", ] -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.6.2", - "rustc_version", -] - [[package]] name = "parking_lot" version = "0.10.2" @@ -906,21 +765,6 @@ dependencies = [ "parking_lot_core 0.8.0", ] -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi 0.0.3", - "libc", - "redox_syscall 0.1.56", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", -] - [[package]] name = "parking_lot_core" version = "0.7.1" @@ -931,8 +775,8 @@ dependencies = [ "cloudabi 0.0.3", "libc", "redox_syscall 0.1.56", - "smallvec 1.4.2", - "winapi 0.3.8", + "smallvec", + "winapi", ] [[package]] @@ -946,8 +790,8 @@ dependencies = [ "instant", "libc", "redox_syscall 0.1.56", - "smallvec 1.4.2", - "winapi 0.3.8", + "smallvec", + "winapi", ] [[package]] @@ -962,12 +806,6 @@ dependencies = [ "stfu8", ] -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" - [[package]] name = "percent-encoding" version = "2.1.0" @@ -1086,7 +924,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5b06e3438447e2b41b510996e0807ef6d776253b3c6c68b1f057652575e01" dependencies = [ - "bytes 1.0.1", + "bytes", "thiserror", ] @@ -1101,20 +939,20 @@ dependencies = [ [[package]] name = "r2d2" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1497e40855348e4a8a40767d8e55174bce1e445a3ac9254ad44ad468ee0485af" +checksum = "545c5bc2b880973c9c10e4067418407a0ccaa3091781d1671d46eb35107cb26f" dependencies = [ "log", - "parking_lot 0.10.2", + "parking_lot 0.11.0", "scheduled-thread-pool", ] [[package]] name = "r2d2_redis" -version = "0.8.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98318a90bb5f4990e084cd54e875aedb794f73dcef8668287cc74e875955b9db" +checksum = "182473b876b0b93e353682ec58e207dd1cb4a62278bbe0045fe52b86b74363bb" dependencies = [ "r2d2", "redis", @@ -1162,19 +1000,17 @@ dependencies = [ [[package]] name = "redis" -version = "0.9.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c747d743d48233f9bc3ed3fb00cb84c1d98d8c7f54ed2d4cca9adf461a7ef3" +checksum = "eeb8f8d059ead7805e171fc22de8348a3d611c0f985aaa4f5cf6c0dfc7645407" dependencies = [ - "bytes 0.4.12", + "async-trait", "combine", - "futures 0.1.29", + "dtoa", + "itoa", + "percent-encoding", "sha1", - "tokio-codec", - "tokio-executor", - "tokio-io", - "tokio-tcp", - "url 1.7.2", + "url", ] [[package]] @@ -1232,16 +1068,7 @@ dependencies = [ "spin", "untrusted", "web-sys", - "winapi 0.3.8", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", + "winapi", ] [[package]] @@ -1288,7 +1115,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "039c25b130bd8c1321ee2d7de7fde2659fa9c2744e4bb29711cfc852ea53cd19" dependencies = [ "lazy_static", - "winapi 0.3.8", + "winapi", ] [[package]] @@ -1382,9 +1209,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.62" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ "itoa", "ryu", @@ -1433,7 +1260,7 @@ dependencies = [ [[package]] name = "slog-redis" -version = "0.1.0" +version = "0.1.1" dependencies = [ "chrono", "r2d2", @@ -1441,6 +1268,7 @@ dependencies = [ "redis", "serde_json", "slog", + "slog-async", ] [[package]] @@ -1478,15 +1306,6 @@ dependencies = [ "thread_local", ] -[[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] - [[package]] name = "smallvec" version = "1.4.2" @@ -1502,7 +1321,7 @@ dependencies = [ "cfg-if 0.1.10", "libc", "redox_syscall 0.1.56", - "winapi 0.3.8", + "winapi", ] [[package]] @@ -1558,7 +1377,7 @@ checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" dependencies = [ "dirs-next", "rustversion", - "winapi 0.3.8", + "winapi", ] [[package]] @@ -1606,7 +1425,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" dependencies = [ "libc", - "winapi 0.3.8", + "winapi", ] [[package]] @@ -1616,49 +1435,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "134af885d758d645f0f0505c9a8b3f9bf8a348fd822e112ab5248138348f1722" dependencies = [ "autocfg", - "bytes 1.0.1", + "bytes", "libc", "memchr", - "mio 0.7.6", + "mio", "num_cpus", "once_cell", "parking_lot 0.11.0", "pin-project-lite", "signal-hook-registry", "tokio-macros", - "winapi 0.3.8", -] - -[[package]] -name = "tokio-codec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "tokio-io", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.29", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "log", + "winapi", ] [[package]] @@ -1672,25 +1459,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.29", - "lazy_static", - "log", - "mio 0.6.21", - "num_cpus", - "parking_lot 0.9.0", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - [[package]] name = "tokio-rustls" version = "0.22.0" @@ -1713,37 +1481,13 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -dependencies = [ - "fnv", - "futures 0.1.29", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "iovec", - "mio 0.6.21", - "tokio-io", - "tokio-reactor", -] - [[package]] name = "tokio-util" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebb7cb2f00c5ae8df755b252306272cd1790d39728363936e01827e11f0b017b" dependencies = [ - "bytes 1.0.1", + "bytes", "futures-core", "futures-io", "futures-sink", @@ -1805,7 +1549,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" dependencies = [ - "futures 0.3.13", + "futures", "futures-task", "pin-project 0.4.23", "tracing", @@ -1824,7 +1568,7 @@ dependencies = [ "async-trait", "built", "clap", - "futures 0.3.13", + "futures", "http", "hyper", "lazy_static", @@ -1881,7 +1625,7 @@ dependencies = [ "hyper", "hyper-rustls", "libunftp", - "percent-encoding 2.1.0", + "percent-encoding", "regex", "serde", "serde_json", @@ -1898,7 +1642,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8edaa4ed1fa2425db1c9a7aa1aedb9327a69cff4aa18213be87428668d3f3616" dependencies = [ "async-trait", - "futures 0.3.13", + "futures", "libunftp", "path_abs", "tokio", @@ -1914,14 +1658,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5dcbce327800fe1b01cc380cedb20054b1ec214903bdd13a51ca60d96e01f03" dependencies = [ "async-trait", - "bytes 1.0.1", + "bytes", "chrono", - "futures 0.3.13", + "futures", "hyper", "hyper-rustls", "libunftp", "mime", - "percent-encoding 2.1.0", + "percent-encoding", "serde", "serde_json", "tokio", @@ -1948,7 +1692,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" dependencies = [ - "smallvec 1.4.2", + "smallvec", ] [[package]] @@ -1963,41 +1707,21 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -dependencies = [ - "void", -] - [[package]] name = "untrusted" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" -[[package]] -name = "url" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -dependencies = [ - "idna 0.1.5", - "matches", - "percent-encoding 1.0.1", -] - [[package]] name = "url" version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" dependencies = [ - "idna 0.2.0", + "idna", "matches", - "percent-encoding 2.1.0", + "percent-encoding", ] [[package]] @@ -2030,12 +1754,6 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - [[package]] name = "want" version = "0.3.0" @@ -2126,12 +1844,6 @@ dependencies = [ "untrusted", ] -[[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.8" @@ -2142,12 +1854,6 @@ 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" @@ -2160,16 +1866,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[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]] name = "yup-oauth2" version = "5.0.3" @@ -2178,16 +1874,16 @@ checksum = "72c6dfbc7a0d18f43774daf38bd5c895f1cf3f39105770acfa1ae4ccbf3b0113" dependencies = [ "base64", "chrono", - "futures 0.3.13", + "futures", "http", "hyper", "hyper-rustls", "log", - "percent-encoding 2.1.0", + "percent-encoding", "rustls", "seahash", "serde", "serde_json", "tokio", - "url 2.1.1", + "url", ] diff --git a/Cargo.toml b/Cargo.toml index 7f922c9..431a9f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ documentation = "https://github.com/bolcom/unFTP" [dependencies.slog-redis] path="crates/redislog" -version="0.1.0" +version="0.1.1" [dependencies] async-trait = "0.1.45" diff --git a/Makefile b/Makefile index 87538ca..840a43a 100644 --- a/Makefile +++ b/Makefile @@ -61,10 +61,10 @@ docker-list: # List the available docker images .PHONY: pr-prep pr-prep: # Runs checks to ensure you're ready for a pull request cargo fmt --all -- --check - cargo clippy --all-features -- -D warnings - cargo build --verbose --all --all-features - cargo test --verbose --all --all-features - cargo doc --all-features --no-deps + cargo clippy --all-features --workspace -- -D warnings + cargo test --verbose --workspace --all --all-features + cargo doc --workspace --all-features --no-deps + cargo build --verbose --workspace --all --all-features .PHONY: release-artifacts release-artifacts: # Generates artifacts for a release diff --git a/README.md b/README.md index 1f389b0..3344ce8 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ Run sending logs to a Redis list: ```sh unftp \ - --log-redis-host=2121 \ + --log-redis-host=localhost \ --log-redis-key=logs-key \ --log-redis-port=6379 ``` diff --git a/crates/redislog/CONTRIBUTING.md b/crates/redislog/CONTRIBUTING.md new file mode 100644 index 0000000..f84be21 --- /dev/null +++ b/crates/redislog/CONTRIBUTING.md @@ -0,0 +1,35 @@ +# Contributing to slog-redis + +Great projects are never established alone. Therefore we thank you for your interest to help out and offer this guide to +help you along. + +- For bug reports you can log a [Github issue](https://github.com/bolcom/unFTP/issues) +- For ideas and feedback you can proceed to the [slog-redis general discussion](https://github.com/bolcom/unFTP/discussions/83) +- Off course pull requests for code and documentation improvements are welcomed. + +## Submitting bug reports and feature requests + +When reporting a bug or asking for help, please include enough details so that the people helping you can reproduce the +behavior you are seeing. For some tips on how to approach this, read about how to produce +a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). + +When making a feature request, please make it clear what problem you intend to solve with the feature, any ideas for how unFTP could support solving that problem, any possible alternatives, and any disadvantages. + +## Checking your code + +We encourage you to check that the test suite passes locally and make sure that clippy and rustfmt are happy before +submitting a pull request with your changes. If anything does not pass, typically it will be easier to iterate and +fix it locally than waiting for the CI servers to run tests for you. Pull requests that do not pass the CI pipeline +will unfortunately not be merged. + +To make sure it will pass please run the following before you submit your pull request: + +```sh +cargo fmt --all +cargo clippy +cargo build --all +cargo test --all +cargo doc --no-deps +``` + +For your convenience we've added a makefile target to check if you got it right. Simply run `make pr-prep`. \ No newline at end of file diff --git a/crates/redislog/Cargo.toml b/crates/redislog/Cargo.toml index b03a6bd..b36a9a9 100644 --- a/crates/redislog/Cargo.toml +++ b/crates/redislog/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "slog-redis" description = "Redis drain for slog-rs" -version = "0.1.0" +version = "0.1.1" authors = ["Hannes de Jager "] edition = "2018" license = "Apache-2.0" @@ -14,8 +14,12 @@ readme = "README.md" [dependencies] chrono = "0.4.6" -r2d2 = "0.8.3" -r2d2_redis = "0.8.0" -redis = "0.9.0" -serde_json = "1.0.57" -slog = { version = "2.4.1", features = ["max_level_trace", "release_max_level_info"] } +r2d2 = "0.8.9" +r2d2_redis = "0.14.0" +redis = "0.20.0" +serde_json = "1.0.64" +slog = { version = "2.7.0", features = ["max_level_trace", "release_max_level_info"] } + + +[dev-dependencies] +slog-async = "2.6.0" \ No newline at end of file diff --git a/crates/redislog/Makefile b/crates/redislog/Makefile new file mode 100644 index 0000000..de57c45 --- /dev/null +++ b/crates/redislog/Makefile @@ -0,0 +1,33 @@ +.PHONY: help +help: # Show available `make` commands + @awk -F'#' '\ + BEGIN{n=split("$(DOCKER_IMAGES)", docker_images, " ")} \ + /^[%a-z][.A-Za-z0-9]+/ { \ + if (NF > 1) { \ + sub(/:[^#]*/, ""); \ + if ($$1 ~ /%/ && $$1 ~ /[Dd]ocker/) { \ + line=$$0; \ + for (i=1; i<=n; ++i) { \ + $$0 = line; \ + gsub(/%/, docker_images[i]); \ + printf("%-25s %s\n", $$1, $$2) \ + } \ + } else { \ + printf("%-25s %s\n", $$1, $$2) \ + } \ + } \ + }\ + /^##/ { printf("\n") }' Makefile + +## +.PHONY: pr-prep +pr-prep: # Runs checks to ensure you're ready for a pull request + cargo fmt --all -- --check + cargo clippy -- -D warnings + cargo test + cargo test --doc + cargo build + cargo doc --no-deps + +publish: + cargo publish --verbose diff --git a/crates/redislog/README.md b/crates/redislog/README.md index c14b2b4..16a280c 100644 --- a/crates/redislog/README.md +++ b/crates/redislog/README.md @@ -1,3 +1,40 @@ # slog-redis This crate implements a [slog](https://crates.io/crates/slog) drain that outputs to a [Redis](https://redis.io/) list. + +Useful for **centralized logging** using a RELK stack (Redis, Elasticsearch, Logstash and Kibana). All log messages are +sent to a Redis server, in **Logstash message V0 format**, ready to be parsed/processed by Logstash. + +The format looks like this: + + ```json + { + "@timestamp": ${timeRFC3339}, + "@source_host": ${hostname}, + "@message": ${message}, + "@fields": { + "level": ${levelLowercase}, + "application": ${appName} + ... // logged field 1 + ... // logged field 2 + ... + } +``` + +Example Usage: + +```rust + use slog::*; + use slog_redis::Builder; + + let redis_drain = Builder::new("my-app-name") + .redis_host("localhost") + .redis_key("my_redis_list_key") + .build() + .unwrap(); + + let drain = slog_async::Async::new(redis_drain.fuse()).build().fuse(); + + let log = Logger::root(drain, o!()); + info!(log, "Send me to {}!", "Redis"; "msg" => "Hello World!"); +``` diff --git a/crates/redislog/src/lib.rs b/crates/redislog/src/lib.rs index fe9a379..59dee22 100644 --- a/crates/redislog/src/lib.rs +++ b/crates/redislog/src/lib.rs @@ -1,5 +1,44 @@ -//! This crate implements a [slog](https://crates.io/crates/slog) drain that outputs to a Redis list -//! in a structured way. +//! This crate implements a [slog](https://crates.io/crates/slog) drain that outputs JSON formatted +//! logs to a Redis list +//! +//! Useful for structured, **centralized logging** using a RELK stack (Redis, Elasticsearch, +//! Logstash and Kibana). All log messages are sent to a Redis server, in **Logstash message V0 format**, +//! ready to be parsed/processed by Logstash. +//! +//! The format looks like this: +//! +//! ```json +//! { +//! "@timestamp": ${timeRFC3339}, +//! "@source_host": ${hostname}, +//! "@message": ${message}, +//! "@fields": { +//! "level": ${levelLowercase}, +//! "application": ${appName} +//! ... // logged field 1 +//! ... // logged field 2 +//! ... +//! } +//! ``` +//! +//! Example usage: +//! +//! ```no_run +//! use slog::*; +//! use slog_redis::Builder; +//! +//! let redis_drain = Builder::new("my-app-name") +//! .redis_host("localhost") +//! .redis_key("my_redis_list_key") +//! .build() +//! .unwrap(); +//! +//! let drain = slog_async::Async::new(redis_drain.fuse()).build().fuse(); +//! +//! let log = Logger::root(drain, o!()); +//! info!(log, "Send me to {}!", "Redis"; "msg" => "Hello World!"); +//! ``` +//! use std::cell::RefCell; use std::fmt; @@ -128,14 +167,14 @@ impl Builder { String::from_utf8_lossy(&output.stdout).replace("\n", "") } - let con_str = format!("redis://{}:{}", self.redis_host, self.redis_port); - let manager = RedisConnectionManager::new(con_str.as_str())?; + let connection_str = format!("redis://{}:{}", self.redis_host, self.redis_port); + let manager = RedisConnectionManager::new(connection_str.as_str())?; let pool = r2d2::Pool::builder() .connection_timeout(Duration::new(1, 0)) .build(manager)?; - let con = pool.get()?; - redis::cmd("PING").query(&*con)?; + let mut con = pool.get()?; + redis::cmd("PING").query(&mut *con)?; Ok(Logger { redis_host: self.redis_host, @@ -182,12 +221,18 @@ impl Logger { /// Sends a message constructed by v0_msg to the redis server fn send_to_redis(&self, msg: &str) -> Result<(), Error> { - let con = self.pool.get()?; + let mut con = self.pool.get()?; - redis::cmd("RPUSH").arg(self.redis_key.as_str()).arg(msg).query(&*con)?; + redis::cmd("RPUSH") + .arg(self.redis_key.as_str()) + .arg(msg) + .query(&mut *con)?; if let Some(t) = self.ttl_seconds { - redis::cmd("EXPIRE").arg(self.redis_key.as_str()).arg(t).query(&*con)? + redis::cmd("EXPIRE") + .arg(self.redis_key.as_str()) + .arg(t) + .query(&mut *con)? } Ok(()) }