diff --git a/Cargo.lock b/Cargo.lock index 39c87e2f89..f3b94f628c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,7 @@ dependencies = [ "parking_lot 0.10.2", "pin-project 0.4.27", "smallvec 1.6.1", - "tokio", + "tokio 0.2.24", "tokio-util 0.2.0", ] @@ -33,7 +33,7 @@ dependencies = [ "futures-core", "futures-sink", "log", - "tokio", + "tokio 0.2.24", "tokio-util 0.2.0", ] @@ -49,7 +49,7 @@ dependencies = [ "futures-sink", "log", "pin-project 0.4.27", - "tokio", + "tokio 0.2.24", "tokio-util 0.3.1", ] @@ -164,7 +164,7 @@ dependencies = [ "futures-core", "futures-util", "fxhash", - "h2", + "h2 0.2.7", "http", "httparse", "indexmap", @@ -211,7 +211,7 @@ dependencies = [ "futures-core", "futures-util", "fxhash", - "h2", + "h2 0.2.7", "http", "httparse", "indexmap", @@ -229,7 +229,7 @@ dependencies = [ "serde_urlencoded 0.7.0", "sha-1", "slab", - "time 0.2.24", + "time 0.2.25", ] [[package]] @@ -239,7 +239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ca8ce00b267af8ccebbd647de0d61e0674b6e61185cc7a592ff88772bed655" dependencies = [ "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -267,7 +267,7 @@ dependencies = [ "futures-channel", "futures-util", "smallvec 1.6.1", - "tokio", + "tokio 0.2.24", ] [[package]] @@ -470,7 +470,7 @@ dependencies = [ "serde_json", "serde_urlencoded 0.7.0", "socket2", - "time 0.2.24", + "time 0.2.25", "tinyvec", "url 2.2.0", ] @@ -483,7 +483,7 @@ checksum = "a71bf475cbe07281d0b3696abb48212db118e7e23219f13596ce865235ff5766" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -494,7 +494,7 @@ checksum = "ad26f77093333e0e7c6ffe54ebe3582d908a104e448723eec6d43d08b07143fb" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -518,7 +518,7 @@ checksum = "b95aceadaf327f18f0df5962fedc1bde2f870566a0b9f65c89508a3b1f79334c" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -696,7 +696,7 @@ dependencies = [ "futures-core", "memchr", "pin-project-lite 0.2.4", - "tokio", + "tokio 0.2.24", "xz2", ] @@ -807,6 +807,27 @@ dependencies = [ "wasm-bindgen-futures", ] +[[package]] +name = "async-stream" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3670df70cbc01729f901f94c887814b3c68db038aad1329a418bae178bc5295c" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3548b8efc9f8e8a5a0a2808c5bd8451a9031b9e5b879a79590304ae928b0a70" +dependencies = [ + "proc-macro2 1.0.24", + "quote 1.0.8", + "syn 1.0.60", +] + [[package]] name = "async-task" version = "4.0.3" @@ -821,7 +842,7 @@ checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -923,9 +944,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" dependencies = [ "addr2line", "cfg-if 1.0.0", @@ -1217,9 +1238,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" +checksum = "f07aa6688c702439a1be0307b6a94dffe1168569e45b9500c1372bc580740d59" [[package]] name = "byte-slice-cast" @@ -1435,6 +1456,21 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "console" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cc80946b3480f421c2f17ed1cb841753a371c7c5104f51d507e13f532c856aa" +dependencies = [ + "encode_unicode 0.3.6", + "lazy_static", + "libc", + "regex", + "terminal_size", + "unicode-width", + "winapi 0.3.9", +] + [[package]] name = "const_fn" version = "0.4.5" @@ -1464,7 +1500,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784ad0fbab4f3e9cef09f20e0aea6000ae08d2cb98ac4c0abc53df18803d702f" dependencies = [ "percent-encoding 2.1.0", - "time 0.2.24", + "time 0.2.25", "version_check 0.9.2", ] @@ -1703,7 +1739,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10bcb9d7dcbf7002aaffbb53eac22906b64cdcc127971dcc387d8eb7c95d5560" dependencies = [ "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -1737,7 +1773,7 @@ dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", "strsim 0.9.3", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -1748,18 +1784,18 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" dependencies = [ "darling_core", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] name = "derivative" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaed5874effa6cde088c644ddcdcb4ffd1511391c5be4fdd7a5ccd02c7e4a183" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -1770,7 +1806,7 @@ checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -1779,7 +1815,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b5eb0fce3c4f955b8d8d864b131fb8863959138da962026c106ba7a2e3bf7a" dependencies = [ - "console", + "console 0.10.3", "lazy_static", "tempfile", ] @@ -1806,7 +1842,7 @@ checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -2027,7 +2063,7 @@ dependencies = [ "heck", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -2216,7 +2252,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", "synstructure 0.12.4", ] @@ -2258,18 +2294,18 @@ dependencies = [ "num-traits", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] name = "filetime" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c122a393ea57648015bf06fbd3d372378992e86b9ff5a7a497b076a28c79efe" +checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.1.57", + "redox_syscall 0.2.4", "winapi 0.3.9", ] @@ -2528,7 +2564,7 @@ dependencies = [ "proc-macro-hack", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -2651,7 +2687,7 @@ dependencies = [ "structopt", "tempdir", "thiserror", - "tokio", + "tokio 0.2.24", "url 2.2.0", "ya-core-model", "ya-service-bus", @@ -2682,7 +2718,7 @@ dependencies = [ "proc-macro-hack", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -2744,7 +2780,7 @@ dependencies = [ "serde_json", "strip-ansi-escapes", "structopt", - "tokio", + "tokio 0.2.24", "url 2.2.0", "ya-compile-time-utils", "ya-core-model", @@ -2764,8 +2800,8 @@ dependencies = [ "chrono", "hex", "http", - "hyper", - "hyper-tls", + "hyper 0.13.9", + "hyper-tls 0.4.3", "openssl", "serde", "serde_json", @@ -2786,12 +2822,32 @@ dependencies = [ "http", "indexmap", "slab", - "tokio", + "tokio 0.2.24", "tokio-util 0.3.1", "tracing", "tracing-futures", ] +[[package]] +name = "h2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5" +dependencies = [ + "bytes 1.0.1", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio 1.1.0", + "tokio-util 0.6.2", + "tracing", + "tracing-futures", +] + [[package]] name = "hashbrown" version = "0.9.1" @@ -2893,6 +2949,16 @@ dependencies = [ "http", ] +[[package]] +name = "http-body" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" +dependencies = [ + "bytes 1.0.1", + "http", +] + [[package]] name = "httparse" version = "1.3.4" @@ -2930,15 +2996,39 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.2.7", + "http", + "http-body 0.3.1", + "httparse", + "httpdate", + "itoa", + "pin-project 1.0.4", + "socket2", + "tokio 0.2.24", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12219dc884514cb4a6a03737f4413c0e01c23a1b059b0156004b23f1e19dccbe" +dependencies = [ + "bytes 1.0.1", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.3.0", "http", - "http-body", + "http-body 0.4.0", "httparse", "httpdate", "itoa", "pin-project 1.0.4", "socket2", - "tokio", + "tokio 1.1.0", "tower-service", "tracing", "want", @@ -2951,12 +3041,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" dependencies = [ "bytes 0.5.6", - "hyper", + "hyper 0.13.9", "native-tls", - "tokio", + "tokio 0.2.24", "tokio-tls", ] +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes 1.0.1", + "hyper 0.14.2", + "native-tls", + "tokio 1.1.0", + "tokio-native-tls", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -3054,6 +3157,18 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "indicatif" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7baab56125e25686df467fe470785512329883aab42696d661247aca2a2896e4" +dependencies = [ + "console 0.14.0", + "lazy_static", + "number_prefix", + "regex", +] + [[package]] name = "inotify" version = "0.7.1" @@ -3259,7 +3374,7 @@ dependencies = [ "darling", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -3351,7 +3466,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e14017d204ae062dc5c68a321e3dbdcd9b30181305cb6b067932f7f03f754e27" dependencies = [ - "hyper", + "hyper 0.13.9", "log", "metrics-core", ] @@ -3364,7 +3479,7 @@ checksum = "f3fc63816bd5f8bde5eb31ce471f9633adc69ba1c55b44191b4d5fc7e263e8ab" dependencies = [ "log", "metrics-core", - "tokio", + "tokio 0.2.24", ] [[package]] @@ -3452,7 +3567,7 @@ dependencies = [ "migrations_internals", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -3864,14 +3979,20 @@ dependencies = [ "proc-macro-crate", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] +[[package]] +name = "number_prefix" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b02fc0ff9a9e4b35b3342880f48e896ebf69f2967921fe8646bf5b7125956a" + [[package]] name = "object" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" [[package]] name = "ole32-sys" @@ -4212,7 +4333,7 @@ checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -4223,7 +4344,7 @@ checksum = "caa25a6393f22ce819b0f50e0be89287292fda8d425be38ee0ca14c4931d9e71" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -4327,7 +4448,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", "version_check 0.9.2", ] @@ -4428,7 +4549,7 @@ dependencies = [ "itertools", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -4468,6 +4589,15 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quick-xml" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26aab6b48e2590e4a64d1ed808749ba06257882b461d01ca71baeb747074a6dd" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "0.6.13" @@ -4853,9 +4983,9 @@ dependencies = [ "futures-core", "futures-util", "http", - "http-body", - "hyper", - "hyper-tls", + "http-body 0.3.1", + "hyper 0.13.9", + "hyper-tls 0.4.3", "ipnet", "js-sys", "lazy_static", @@ -4868,7 +4998,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded 0.7.0", - "tokio", + "tokio 0.2.24", "tokio-tls", "trust-dns-resolver 0.19.6", "url 2.2.0", @@ -4878,6 +5008,41 @@ dependencies = [ "winreg 0.7.0", ] +[[package]] +name = "reqwest" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd281b1030aa675fb90aa994d07187645bb3c8fc756ca766e7c3070b439de9de" +dependencies = [ + "base64 0.13.0", + "bytes 1.0.1", + "encoding_rs", + "futures-core", + "futures-util", + "http", + "http-body 0.4.0", + "hyper 0.14.2", + "hyper-tls 0.5.0", + "ipnet", + "js-sys", + "lazy_static", + "log", + "mime", + "native-tls", + "percent-encoding 2.1.0", + "pin-project-lite 0.2.4", + "serde", + "serde_json", + "serde_urlencoded 0.7.0", + "tokio 1.1.0", + "tokio-native-tls", + "url 2.2.0", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg 0.7.0", +] + [[package]] name = "resolv-conf" version = "0.6.3" @@ -5204,6 +5369,23 @@ dependencies = [ "libc", ] +[[package]] +name = "self_update" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "502f26626811e30581f6cb80ee588ccc709f8e490d14a4363f4b16f5d24cd7e2" +dependencies = [ + "hyper 0.14.2", + "indicatif", + "log", + "quick-xml", + "regex", + "reqwest 0.11.0", + "semver 0.11.0", + "serde_json", + "tempfile", +] + [[package]] name = "semver" version = "0.9.0" @@ -5249,9 +5431,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.120" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "166b2349061381baf54a58e4b13c89369feb0ef2eaa57198899e2312aac30aab" +checksum = "974ef1bd2ad8a507599b336595454081ff68a9599b4890af7643c0c0ed73a62c" dependencies = [ "serde_derive", ] @@ -5267,13 +5449,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.120" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca2a8cb5805ce9e3b95435e3765b7b553cecc762d938d409434338386cb5775" +checksum = "8dee1f300f838c8ac340ecb0112b3ac472464fa67e87292bdb3dfc9c49128e17" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -5351,7 +5533,7 @@ source = "git+https://github.com/tworec/serial_test.git?branch=actix_rt_test#6c8 dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -5586,7 +5768,7 @@ dependencies = [ "quote 1.0.8", "serde", "serde_derive", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -5602,7 +5784,7 @@ dependencies = [ "serde_derive", "serde_json", "sha1", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -5662,7 +5844,7 @@ dependencies = [ "proc-macro-error", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -5680,7 +5862,7 @@ dependencies = [ "heck", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -5708,9 +5890,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.58" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" +checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", @@ -5737,7 +5919,7 @@ checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", "unicode-xid 0.2.1", ] @@ -5797,9 +5979,9 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd2d183bd3fac5f5fe38ddbeb4dc9aec4a39a9d7d59e7491d900302da01cbe1" +checksum = "86ca8ced750734db02076f44132d802af0b33b09942331f4459dde8636fd2406" dependencies = [ "libc", "winapi 0.3.9", @@ -5840,16 +6022,16 @@ checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] name = "thread_local" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447" +checksum = "d8208a331e1cb318dd5bd76951d2b8fc48ca38a69f5f4e4af1b6a9f8c6236915" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] @@ -5874,9 +6056,9 @@ dependencies = [ [[package]] name = "time" -version = "0.2.24" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "273d3ed44dca264b0d6b3665e8d48fb515042d42466fad93d2a45b90ec4058f7" +checksum = "1195b046942c221454c2539395f85413b33383a067449d78aab2b7b052a142f7" dependencies = [ "const_fn", "libc", @@ -5907,7 +6089,7 @@ dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", "standback", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -5967,6 +6149,21 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "tokio" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8efab2086f17abcddb8f756117665c958feee6b2e39974c2f1600592ab3a4195" +dependencies = [ + "autocfg 1.0.1", + "bytes 1.0.1", + "libc", + "memchr", + "mio 0.7.7", + "num_cpus", + "pin-project-lite 0.2.4", +] + [[package]] name = "tokio-byteorder" version = "0.2.0" @@ -5974,7 +6171,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac46f27b0d0bb37aa3a38ccfea54b029e85ea0145a0a47adfad8601097407567" dependencies = [ "byteorder", - "tokio", + "tokio 0.2.24", ] [[package]] @@ -6006,7 +6203,17 @@ checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio 1.1.0", ] [[package]] @@ -6016,7 +6223,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c4b08c5f4208e699ede3df2520aca2e82401b2de33f45e96696a074480be594" dependencies = [ "openssl", - "tokio", + "tokio 0.2.24", ] [[package]] @@ -6025,7 +6232,7 @@ version = "0.1.0" dependencies = [ "libc", "nix 0.11.1", - "tokio", + "tokio 0.2.24", ] [[package]] @@ -6047,6 +6254,17 @@ dependencies = [ "tokio-sync", ] +[[package]] +name = "tokio-stream" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76066865172052eb8796c686f0b441a93df8b08d40a950b062ffb9a426f00edd" +dependencies = [ + "futures-core", + "pin-project-lite 0.2.4", + "tokio 1.1.0", +] + [[package]] name = "tokio-sync" version = "0.1.8" @@ -6067,7 +6285,7 @@ dependencies = [ "futures-core", "libc", "redox_syscall 0.1.57", - "tokio", + "tokio 0.2.24", "xattr", ] @@ -6078,7 +6296,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" dependencies = [ "native-tls", - "tokio", + "tokio 0.2.24", ] [[package]] @@ -6092,7 +6310,7 @@ dependencies = [ "futures-sink", "log", "pin-project-lite 0.1.11", - "tokio", + "tokio 0.2.24", ] [[package]] @@ -6106,7 +6324,23 @@ dependencies = [ "futures-sink", "log", "pin-project-lite 0.1.11", - "tokio", + "tokio 0.2.24", +] + +[[package]] +name = "tokio-util" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb971a26599ffd28066d387f109746df178eff14d5ea1e235015c5601967a4b" +dependencies = [ + "async-stream", + "bytes 1.0.1", + "futures-core", + "futures-sink", + "log", + "pin-project-lite 0.2.4", + "tokio 1.1.0", + "tokio-stream", ] [[package]] @@ -6120,9 +6354,9 @@ dependencies = [ [[package]] name = "tower-service" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" @@ -6171,7 +6405,7 @@ dependencies = [ "rand 0.7.3", "smallvec 1.6.1", "socket2", - "tokio", + "tokio 0.2.24", "url 2.2.0", ] @@ -6192,7 +6426,7 @@ dependencies = [ "smallvec 1.6.1", "socket2", "thiserror", - "tokio", + "tokio 0.2.24", "url 2.2.0", ] @@ -6211,7 +6445,7 @@ dependencies = [ "lru-cache", "resolv-conf 0.6.3", "smallvec 1.6.1", - "tokio", + "tokio 0.2.24", "trust-dns-proto 0.18.0-alpha.2", ] @@ -6231,7 +6465,7 @@ dependencies = [ "resolv-conf 0.7.0", "smallvec 1.6.1", "thiserror", - "tokio", + "tokio 0.2.24", "trust-dns-proto 0.19.6", ] @@ -6442,7 +6676,7 @@ dependencies = [ "nom 4.2.3", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -6454,7 +6688,7 @@ dependencies = [ "nom 4.2.3", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -6594,7 +6828,7 @@ dependencies = [ "log", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", "wasm-bindgen-shared", ] @@ -6628,7 +6862,7 @@ checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6664,8 +6898,8 @@ dependencies = [ "ethereum-types 0.9.2", "futures 0.3.12", "futures-timer", - "hyper", - "hyper-tls", + "hyper 0.13.9", + "hyper-tls 0.4.3", "jsonrpc-core", "log", "native-tls", @@ -6838,7 +7072,7 @@ dependencies = [ "shlex", "structopt", "thiserror", - "tokio", + "tokio 0.2.24", "uuid 0.8.2", "ya-client-model", "ya-core-model", @@ -6944,7 +7178,7 @@ dependencies = [ "proc-macro-hack", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.58", + "syn 1.0.60", ] [[package]] @@ -6991,7 +7225,7 @@ dependencies = [ "openssl", "rand 0.6.5", "regex", - "reqwest", + "reqwest 0.10.10", "rustyline 7.1.0", "secp256k1 0.19.0", "serde", @@ -7003,7 +7237,7 @@ dependencies = [ "structopt", "tempdir", "thiserror", - "tokio", + "tokio 0.2.24", "tokio-util 0.2.0", "url 2.2.0", "winapi 0.3.9", @@ -7064,7 +7298,7 @@ dependencies = [ "sha3", "thiserror", "tiny-keccak 2.0.2", - "tokio", + "tokio 0.2.24", "trust-dns-resolver 0.19.6", "uint 0.7.1", "ureq", @@ -7104,7 +7338,7 @@ dependencies = [ "sha2 0.9.2", "structopt", "thiserror", - "tokio", + "tokio 0.2.24", "uuid 0.8.2", "ya-client-model", "ya-core-model", @@ -7152,7 +7386,7 @@ dependencies = [ "strum", "strum_macros", "thiserror", - "tokio", + "tokio 0.2.24", "uuid 0.8.2", "ya-agreement-utils", "ya-client", @@ -7200,7 +7434,7 @@ dependencies = [ "metrics-runtime", "percent-encoding 2.1.0", "structopt", - "tokio", + "tokio 0.2.24", "url 2.2.0", "ya-core-model", "ya-service-api", @@ -7221,7 +7455,7 @@ dependencies = [ "serde_json", "structopt", "thiserror", - "tokio", + "tokio 0.2.24", "trust-dns-resolver 0.19.6", "ya-core-model", "ya-sb-proto", @@ -7260,7 +7494,7 @@ dependencies = [ "serde_json", "structopt", "thiserror", - "tokio", + "tokio 0.2.24", "uint 0.7.1", "uuid 0.8.2", "ya-agreement-utils", @@ -7297,7 +7531,7 @@ dependencies = [ "num", "r2d2", "thiserror", - "tokio", + "tokio 0.2.24", "ya-client-model", "ya-core-model", "ya-persistence", @@ -7318,7 +7552,7 @@ dependencies = [ "r2d2", "serde_json", "thiserror", - "tokio", + "tokio 0.2.24", "ya-client-model", "ya-core-model", ] @@ -7361,7 +7595,7 @@ dependencies = [ "strum_macros", "sys-info", "thiserror", - "tokio", + "tokio 0.2.24", "url 2.2.0", "walkdir", "winapi 0.3.9", @@ -7389,7 +7623,7 @@ dependencies = [ "prost-build", "serde", "serde_json", - "tokio", + "tokio 0.2.24", "tokio-util 0.2.0", ] @@ -7402,7 +7636,7 @@ dependencies = [ "prost", "prost-build", "thiserror", - "tokio", + "tokio 0.2.24", "tokio-util 0.2.0", "url 2.2.0", ] @@ -7420,7 +7654,7 @@ dependencies = [ "log", "prost", "structopt", - "tokio", + "tokio 0.2.24", "tokio-util 0.2.0", "url 2.2.0", "uuid 0.8.2", @@ -7475,7 +7709,7 @@ dependencies = [ "structopt", "strum", "strum_macros", - "syn 1.0.58", + "syn 1.0.60", "ya-service-api-interfaces", ] @@ -7530,7 +7764,7 @@ dependencies = [ "semver 0.11.0", "serde", "thiserror", - "tokio", + "tokio 0.2.24", "tokio-util 0.2.0", "url 2.2.0", "uuid 0.8.2", @@ -7573,7 +7807,7 @@ dependencies = [ "futures 0.3.12", "gftp", "globset", - "h2", + "h2 0.2.7", "hex", "lazy_static", "log", @@ -7585,7 +7819,7 @@ dependencies = [ "structopt", "tempdir", "thiserror", - "tokio", + "tokio 0.2.24", "tokio-byteorder", "tokio-tar", "url 2.2.0", @@ -7613,7 +7847,7 @@ name = "ya-utils-futures" version = "0.1.0" dependencies = [ "futures 0.3.12", - "tokio", + "tokio 0.2.24", ] [[package]] @@ -7638,7 +7872,7 @@ dependencies = [ "libc", "nix 0.17.0", "shared_child", - "tokio", + "tokio 0.2.24", ] [[package]] @@ -7648,6 +7882,32 @@ dependencies = [ "chrono", ] +[[package]] +name = "ya-version" +version = "0.1.0" +dependencies = [ + "actix-web 3.3.2", + "anyhow", + "chrono", + "diesel", + "diesel_migrations", + "log", + "metrics", + "self_update", + "serde", + "serde_json", + "structopt", + "thiserror", + "tokio 0.2.24", + "ya-client", + "ya-compile-time-utils", + "ya-core-model", + "ya-persistence", + "ya-service-api", + "ya-service-api-interfaces", + "ya-service-bus", +] + [[package]] name = "ya-zksync-driver" version = "0.1.0" @@ -7671,7 +7931,7 @@ dependencies = [ "serde_json", "structopt", "tiny-keccak 1.5.0", - "tokio", + "tokio 0.2.24", "uuid 0.8.2", "ya-client-model", "ya-payment-driver", @@ -7698,7 +7958,7 @@ dependencies = [ "log", "openssl", "structopt", - "tokio", + "tokio 0.2.24", "url 2.2.0", "ya-activity", "ya-compile-time-utils", @@ -7722,6 +7982,7 @@ dependencies = [ "ya-utils-futures", "ya-utils-path", "ya-utils-process", + "ya-version", "ya-zksync-driver", ] @@ -7779,7 +8040,7 @@ dependencies = [ "flate2", "thiserror", "time 0.1.44", - "tokio", + "tokio 0.2.24", "tokio-byteorder", ] @@ -7791,12 +8052,12 @@ dependencies = [ "ethabi", "jsonrpc-core", "num", - "reqwest", + "reqwest 0.10.10", "serde", "serde_json", "sha2 0.8.2", "thiserror", - "tokio", + "tokio 0.2.24", "web3", "zksync_crypto", "zksync_eth_client", @@ -7854,7 +8115,7 @@ dependencies = [ "hex", "jsonrpc-core", "parity-crypto 0.6.2", - "reqwest", + "reqwest 0.10.10", "rlp", "serde", "serde_derive", diff --git a/Cargo.toml b/Cargo.toml index f10eff090b..cb97182325 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,7 @@ ya-sgx = "0.1" ya-utils-path = "0.1" ya-utils-futures = "0.1" ya-utils-process = { version = "0.1", features = ["lock"] } +ya-version = "0.1" actix-rt = "1.0" actix-service = "1.0" @@ -119,6 +120,7 @@ members = [ "core/serv-api/interfaces", "core/serv-api/web", "core/sgx", + "core/version", "exe-unit", "exe-unit/runtime-api", "exe-unit/tokio-process-ns", @@ -138,17 +140,18 @@ members = [ [patch.crates-io] ## SERVICES +ya-identity = { path = "core/identity" } +ya-net = { path = "core/net" } +ya-market = { path = "core/market" } +ya-market-resolver = { path = "core/market/resolver" } ya-activity = { path = "core/activity" } +ya-sgx = { path = "core/sgx" } +ya-payment = { path = "core/payment" } ya-payment-driver = { path = "core/payment-driver/base" } ya-dummy-driver = { path = "core/payment-driver/dummy" } ya-gnt-driver = { path = "core/payment-driver/gnt" } ya-zksync-driver = { path = "core/payment-driver/zksync" } -ya-identity = { path = "core/identity" } -ya-market = { path = "core/market" } -ya-market-resolver = { path = "core/market/resolver" } -ya-net = { path = "core/net" } -ya-payment = { path = "core/payment" } -ya-sgx = { path = "core/sgx" } +ya-version = { path = "core/version" } ## CORE UTILS ya-core-model = { path = "core/model" } diff --git a/core/market/tests/test_agreement.rs b/core/market/tests/test_agreement.rs index da0559c151..2539520460 100644 --- a/core/market/tests/test_agreement.rs +++ b/core/market/tests/test_agreement.rs @@ -1049,9 +1049,7 @@ async fn test_terminate_from_wrong_states() { from: AgreementState::Proposal, to: AgreementState::Terminated, }, - )) => { - assert_eq!(id, agreement_id) - } + )) => assert_eq!(id, agreement_id), e => panic!("Wrong error returned, got: {:?}", e), }; @@ -1078,9 +1076,7 @@ async fn test_terminate_from_wrong_states() { from: AgreementState::Pending, to: AgreementState::Terminated, }, - )) => { - assert_eq!(id, agreement_id) - } + )) => assert_eq!(id, agreement_id), e => panic!("Wrong error returned, got: {:?}", e), }; @@ -1102,9 +1098,7 @@ async fn test_terminate_from_wrong_states() { from: AgreementState::Pending, to: AgreementState::Terminated, }, - )) => { - assert_eq!(id, agreement_id) - } + )) => assert_eq!(id, agreement_id), e => panic!("Wrong error returned, got: {:?}", e), }; } diff --git a/core/model/Cargo.toml b/core/model/Cargo.toml index f8158c099f..0054f8cdca 100644 --- a/core/model/Cargo.toml +++ b/core/model/Cargo.toml @@ -20,7 +20,8 @@ full = [ 'net', 'payment', 'gftp', - 'sgx' + 'sgx', + 'version', ] activity = [] appkey = [] @@ -31,6 +32,7 @@ market = [] net = [] payment = ['bigdecimal', 'bitflags'] sgx = ['graphene-sgx'] +version = [] [dependencies] ya-client-model = "0.2" diff --git a/core/model/src/lib.rs b/core/model/src/lib.rs index 3f9d00119b..eee62f1e95 100644 --- a/core/model/src/lib.rs +++ b/core/model/src/lib.rs @@ -28,6 +28,9 @@ pub mod gftp; #[cfg(feature = "sgx")] pub mod sgx; +#[cfg(feature = "version")] +pub mod version; + use derive_more::Display; use serde::{Deserialize, Serialize}; pub use ya_client_model::NodeId; diff --git a/core/model/src/version.rs b/core/model/src/version.rs new file mode 100644 index 0000000000..d9785b1691 --- /dev/null +++ b/core/model/src/version.rs @@ -0,0 +1,85 @@ +//! Version handling service bus API. + +use chrono::NaiveDateTime; +use serde::{Deserialize, Serialize}; + +use ya_client_model::ErrorMessage; +use ya_service_bus::RpcMessage; + +pub const BUS_ID: &'static str = "/local/version"; + +/// Skip upgrading to the latest Yagna release. +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Skip(); + +impl RpcMessage for Skip { + const ID: &'static str = "skip"; + type Item = Option; + type Error = ErrorMessage; +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Get { + pub check: bool, +} + +impl Get { + pub fn show_only() -> Self { + Get { check: false } + } + + pub fn with_check() -> Self { + Get { check: true } + } +} + +impl RpcMessage for Get { + const ID: &'static str = "check"; + type Item = VersionInfo; + type Error = ErrorMessage; +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, thiserror::Error)] +#[serde(rename_all = "camelCase")] +#[error("Version {version} '{name}' released {}", release_ts.format("%Y-%m-%d"))] +pub struct Release { + pub version: String, + pub name: String, + pub seen: bool, + pub release_ts: NaiveDateTime, + pub insertion_ts: Option, + pub update_ts: Option, +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct VersionInfo { + pub current: Release, + pub pending: Option, +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_release_to_string() { + let now = NaiveDateTime::parse_from_str("2015-10-13T15:43:00GMT+2", "%Y-%m-%dT%H:%M:%S%Z") + .unwrap(); + let r = Release { + version: "0.6.1".to_string(), + name: "some code name".to_string(), + seen: false, + release_ts: now, + insertion_ts: None, + update_ts: None, + }; + + assert_eq!( + r.to_string(), + "Version 0.6.1 'some code name' released 2015-10-13" + ); + } +} diff --git a/core/serv-api/web/src/middleware/auth/mod.rs b/core/serv-api/web/src/middleware/auth/mod.rs index 0db861c1a2..1f2ad98c03 100644 --- a/core/serv-api/web/src/middleware/auth/mod.rs +++ b/core/serv-api/web/src/middleware/auth/mod.rs @@ -81,7 +81,9 @@ where let service = self.service.clone(); // TODO: remove this hack; possibly by enabling creation of arbitrary appkey from CLI - if req.uri().to_string().starts_with("/metrics-api") { + if req.uri().to_string().starts_with("/metrics-api") + || req.uri().to_string().starts_with("/version") + { log::debug!("skipping authorization for uri={}", req.uri()); return Box::pin(service.borrow_mut().call(req)); } diff --git a/core/serv/src/main.rs b/core/serv/src/main.rs index 361a47cca5..57e6d67ca5 100644 --- a/core/serv/src/main.rs +++ b/core/serv/src/main.rs @@ -30,6 +30,7 @@ use ya_service_api_web::{ use ya_sgx::SgxService; use ya_utils_path::data_dir::DataDir; use ya_utils_process::lock::ProcLock; +use ya_version::VersionService; mod autocomplete; use autocomplete::CompleteCommand; @@ -183,12 +184,15 @@ impl TryFrom for ServiceContext { #[ya_service_api_derive::services(ServiceContext)] enum Services { - // Metrics service must be activated first, to allow all - // other services to initialize counters and other metrics. - #[enable(gsb, rest)] - Metrics(MetricsService), + // Metrics service must be activated before all other services + // to that will use it. Identity service is used by the Metrics, + // so must be initialized before. #[enable(gsb, cli(flatten))] Identity(IdentityService), + #[enable(gsb, rest)] + Metrics(MetricsService), + #[enable(gsb, rest, cli)] + Version(VersionService), #[enable(gsb)] Net(NetService), #[enable(gsb, rest)] diff --git a/core/version/Cargo.toml b/core/version/Cargo.toml new file mode 100644 index 0000000000..7c2ea1e26d --- /dev/null +++ b/core/version/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "ya-version" +version = "0.1.0" +description = "Version handling" +authors = ["Golem Factory "] +edition = "2018" + +[dependencies] +ya-client = "0.4" +ya-compile-time-utils = "0.1" +ya-core-model = { version = "0.2.0", features = ["version"] } +ya-persistence = "0.2" +ya-service-api = "0.1" +ya-service-api-interfaces = "0.1" +ya-service-bus = "0.3" + +actix-web = "3.2" +anyhow = "1.0" +chrono = { version = "0.4", features = ["serde"] } +diesel = { version = "1.4", features = ["chrono", "sqlite", "r2d2"] } +diesel_migrations = "1.4" +log = "0.4" +metrics = "0.12" +self_update = "0.23" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +structopt = "0.3.21" +thiserror = "^1.0" +tokio = { version = "0.2", features = ["time", "sync"] } diff --git a/core/version/diesel.toml b/core/version/diesel.toml new file mode 100644 index 0000000000..71215dbf76 --- /dev/null +++ b/core/version/diesel.toml @@ -0,0 +1,5 @@ +# For documentation on how to configure this file, +# see diesel.rs/guides/configuring-diesel-cli + +[print_schema] +file = "src/db/schema.rs" diff --git a/core/version/migrations/.gitkeep b/core/version/migrations/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/core/version/migrations/2021-01-22-093722_initial/down.sql b/core/version/migrations/2021-01-22-093722_initial/down.sql new file mode 100644 index 0000000000..b1b660a1a2 --- /dev/null +++ b/core/version/migrations/2021-01-22-093722_initial/down.sql @@ -0,0 +1,2 @@ +-- Note that triggers are automatically dropped when the associated table is dropped. +DROP TABLE version_release; diff --git a/core/version/migrations/2021-01-22-093722_initial/up.sql b/core/version/migrations/2021-01-22-093722_initial/up.sql new file mode 100644 index 0000000000..1f44777c0f --- /dev/null +++ b/core/version/migrations/2021-01-22-093722_initial/up.sql @@ -0,0 +1,17 @@ +CREATE TABLE version_release ( + version TEXT PRIMARY KEY, + name TEXT NOT NULL, + seen BOOLEAN NOT NULL DEFAULT false, + release_ts TIMESTAMP NOT NULL, + insertion_ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TRIGGER version_release_update_ts + AFTER UPDATE + ON version_release + FOR EACH ROW + WHEN NEW.update_ts <= OLD.update_ts --- this avoids infinite loop +BEGIN + UPDATE version_release SET update_ts=CURRENT_TIMESTAMP WHERE version=OLD.version; +END; diff --git a/core/version/src/db.rs b/core/version/src/db.rs new file mode 100644 index 0000000000..01cbc9b505 --- /dev/null +++ b/core/version/src/db.rs @@ -0,0 +1,9 @@ +pub(crate) mod dao; +pub(crate) mod model; +pub(crate) mod schema; + +#[allow(dead_code)] +pub(crate) mod migrations { + #[derive(EmbedMigrations)] + struct _Dummy; +} diff --git a/core/version/src/db/dao.rs b/core/version/src/db/dao.rs new file mode 100644 index 0000000000..37d5d9abb6 --- /dev/null +++ b/core/version/src/db/dao.rs @@ -0,0 +1,118 @@ +use anyhow::anyhow; +use diesel::prelude::*; + +use ya_core_model::version::{Release, VersionInfo}; +use ya_persistence::executor::{ + do_with_transaction, readonly_transaction, AsDao, ConnType, PoolType, +}; + +use crate::db::model::DBRelease; +use crate::db::schema::version_release::dsl as release; +use crate::db::schema::version_release::dsl::version_release; +use self_update::version::bump_is_greater; + +pub struct ReleaseDAO<'c> { + pool: &'c PoolType, +} +impl<'a> AsDao<'a> for ReleaseDAO<'a> { + fn as_dao(pool: &'a PoolType) -> Self { + Self { pool } + } +} + +impl<'c> ReleaseDAO<'c> { + pub async fn save_new(&self, db_rel: DBRelease) -> anyhow::Result { + do_with_transaction(self.pool, move |conn| { + match get_release(conn, &db_rel.version)? { + Some(rel) => Ok(rel), + None => { + diesel::insert_into(version_release) + .values(&db_rel) + .execute(conn)?; + Ok(db_rel.into()) + } + } + }) + .await + } + + pub async fn current_release(&self) -> anyhow::Result> { + readonly_transaction(self.pool, move |conn| get_current_release(conn)).await + } + + pub async fn pending_release(&self) -> anyhow::Result> { + readonly_transaction(self.pool, move |conn| get_pending_release(conn)).await + } + + pub async fn version(&self) -> anyhow::Result { + log::debug!("Getting Yagna version: current and pending from DB"); + readonly_transaction(self.pool, move |conn| { + Ok(VersionInfo { + current: get_current_release(conn)?.ok_or(anyhow!("Can't get current release."))?, + pending: get_pending_release(conn)?, + }) + }) + .await + } + + pub async fn skip_pending_release(&self) -> anyhow::Result> { + log::debug!("Skipping latest pending Yagna release"); + do_with_transaction(self.pool, move |conn| { + let mut pending_rel = match get_pending_release(conn)? { + Some(rel) => rel, + None => return Ok(None), + }; + let num_updated = diesel::update(version_release.find(&pending_rel.version)) + .set(release::seen.eq(true)) + .execute(conn)?; + pending_rel.seen = true; + match num_updated { + 0 => anyhow::bail!("Release not skipped: {}", pending_rel), + 1 => Ok(Some(pending_rel)), + _ => anyhow::bail!("More than one release skipped: {}", pending_rel), + } + }) + .await + } +} + +fn get_current_release(conn: &ConnType) -> anyhow::Result> { + get_release(conn, ya_compile_time_utils::semver_str()) +} + +fn get_release(conn: &ConnType, ver: &str) -> anyhow::Result> { + Ok(version_release + .filter(release::version.eq(&ver)) + .first::(conn) + .optional()? + .map(|db_rel| db_rel.into())) +} + +fn get_pending_release(conn: &ConnType) -> anyhow::Result> { + let query = version_release + .filter(release::seen.eq(false)) + // insertion_ts is to distinguish among fake-entries of `DBRelease::current` + .order((release::release_ts.desc(), release::insertion_ts.desc())) + .into_boxed(); + + match query.first::(conn).optional()? { + Some(db_rel) => { + let running_ver = ya_compile_time_utils::semver_str(); + if !bump_is_greater(running_ver, &db_rel.version) + .map_err(|e| { + log::error!( + "Failed to compare if version {} > {}: {}", + running_ver, + db_rel.version, + e + ) + }) + .unwrap_or(false) + { + return Ok(None); + } + Ok(Some(db_rel.into())) + } + None => Ok(None), + } +} diff --git a/core/version/src/db/model.rs b/core/version/src/db/model.rs new file mode 100644 index 0000000000..bf8c6b3470 --- /dev/null +++ b/core/version/src/db/model.rs @@ -0,0 +1,82 @@ +use chrono::NaiveDateTime; +use serde::{Deserialize, Serialize}; +use std::convert::TryFrom; + +use crate::db::schema::version_release; +use ya_compile_time_utils::tag2semver; + +pub(crate) const DEFAULT_RELEASE_TS: &'static str = "2015-10-13T15:43:00GMT+2"; + +#[derive(Clone, Debug, Identifiable, Insertable, Queryable, Serialize, Deserialize)] +#[primary_key(version)] +#[table_name = "version_release"] +pub struct DBRelease { + pub version: String, + pub name: String, + pub seen: bool, + pub release_ts: NaiveDateTime, + pub insertion_ts: Option, + pub update_ts: Option, +} + +impl DBRelease { + pub(crate) fn current() -> anyhow::Result { + Ok(DBRelease { + version: ya_compile_time_utils::semver_str().into(), + name: format!( + "({} {}{})", + ya_compile_time_utils::git_rev(), + ya_compile_time_utils::build_date(), + ya_compile_time_utils::build_number_str() + .map(|bn| format!(" build #{}", bn)) + .unwrap_or("".into()) + ), + seen: true, + release_ts: parse_release_ts(DEFAULT_RELEASE_TS)?, + insertion_ts: None, + update_ts: None, + }) + } +} + +impl From for ya_core_model::version::Release { + fn from(db_rel: DBRelease) -> Self { + Self { + version: db_rel.version, + name: db_rel.name, + seen: db_rel.seen, + release_ts: db_rel.release_ts, + insertion_ts: db_rel.insertion_ts, + update_ts: db_rel.update_ts, + } + } +} + +impl TryFrom for DBRelease { + type Error = anyhow::Error; + fn try_from(rel: self_update::update::Release) -> Result { + Ok(Self { + version: tag2semver(&rel.version).into(), + name: rel.name.clone(), + seen: false, + release_ts: parse_release_ts(&rel.date)?, + insertion_ts: None, + update_ts: None, + }) + } +} + +fn parse_release_ts(ts: &str) -> anyhow::Result { + Ok(NaiveDateTime::parse_from_str(&ts, "%Y-%m-%dT%H:%M:%S%Z")?) +} + +#[cfg(test)] +mod test { + use crate::db::model::DBRelease; + + #[test] + fn test_current() { + let c = DBRelease::current().unwrap(); + println!("{:?}", c) + } +} diff --git a/core/version/src/db/schema.rs b/core/version/src/db/schema.rs new file mode 100644 index 0000000000..aa0d2bdb8c --- /dev/null +++ b/core/version/src/db/schema.rs @@ -0,0 +1,10 @@ +table! { + version_release(version) { + version -> Text, + name -> Text, + seen -> Bool, + release_ts -> Timestamp, + insertion_ts -> Nullable, + update_ts -> Nullable, + } +} diff --git a/core/version/src/github.rs b/core/version/src/github.rs new file mode 100644 index 0000000000..5c18e25a9f --- /dev/null +++ b/core/version/src/github.rs @@ -0,0 +1,95 @@ +use anyhow::anyhow; +use metrics::counter; +use self_update::backends::github::UpdateBuilder; +use std::convert::TryFrom; + +use ya_core_model::version::Release; +use ya_persistence::executor::DbExecutor; + +use crate::db::dao::ReleaseDAO; +use crate::db::model::DBRelease; +use crate::service::cli::ReleaseMessage; + +const REPO_OWNER: &'static str = "golemfactory"; +const REPO_NAME: &'static str = "yagna"; + +pub async fn check_latest_release(db: &DbExecutor) -> anyhow::Result { + log::debug!("Checking latest Yagna release"); + let gh_rel = UpdateBuilder::new() + .repo_owner(REPO_OWNER) + .repo_name(REPO_NAME) + .bin_name("") // seems required by builder but unused + .current_version("") // similar as above + .build()? + .get_latest_release()?; + + log::trace!("Got latest Yagna release {:?}", gh_rel); + + let db_rel = DBRelease::try_from(gh_rel)?; + let rel = match db.as_dao::().save_new(db_rel.clone()).await { + Err(e) => { + let r = db_rel.into(); + log::error!("Storing new Yagna release {} to DB. {}", r, e); + r + } + Ok(r) => r, + }; + + if self_update::version::bump_is_greater(ya_compile_time_utils::semver_str(), &rel.version) + .map_err(|e| { + anyhow!( + "Github release version `{}` parse error: {}", + rel.version, + e + ) + })? + { + counter!("version.new", 1); + log::warn!("{}", ReleaseMessage::Available(&rel)); + }; + Ok(rel) +} + +pub(crate) async fn check_running_release(db: &DbExecutor) -> anyhow::Result { + if let Some(release) = db.as_dao::().current_release().await? { + return Ok(release); + } + + let running_tag = ya_compile_time_utils::git_tag(); + log::debug!("Checking release for running tag: {}", running_tag); + + let db_rel = match UpdateBuilder::new() + .repo_owner(REPO_OWNER) + .repo_name(REPO_NAME) + .bin_name("") // seems required by builder but unused + .current_version("") // similar as above + .build()? + .get_release_version(running_tag) + { + Ok(gh_rel) => { + log::trace!("Got currently running release: {:?}", gh_rel); + DBRelease::try_from(gh_rel)? + } + Err(e) => { + log::trace!( + "Failed to get release for running tag: '{}': {}. Using current", + running_tag, + e + ); + DBRelease::current()? + } + }; + + let rel = match db.as_dao::().save_new(db_rel.clone()).await { + Err(e) => { + let r = db_rel.into(); + log::error!("Storing running Yagna release {} to DB: {}", r, e); + r + } + Ok(r) => { + log::info!("Stored currently running Yagna release {} to DB", r); + r + } + }; + Ok(rel) +} diff --git a/core/version/src/lib.rs b/core/version/src/lib.rs new file mode 100644 index 0000000000..8fa17aa8f9 --- /dev/null +++ b/core/version/src/lib.rs @@ -0,0 +1,11 @@ +#[macro_use] +extern crate diesel; +#[macro_use] +extern crate diesel_migrations; + +mod db; +mod github; +mod notifier; +mod service; + +pub use service::VersionService; diff --git a/core/version/src/notifier.rs b/core/version/src/notifier.rs new file mode 100644 index 0000000000..6e1df5a5cd --- /dev/null +++ b/core/version/src/notifier.rs @@ -0,0 +1,66 @@ +use std::time::Duration; + +use ya_persistence::executor::DbExecutor; + +use crate::db::dao::ReleaseDAO; +use crate::github; +use crate::github::check_running_release; +use crate::service::cli::ReleaseMessage; + +pub async fn on_start(db: &DbExecutor) -> anyhow::Result<()> { + check_running_release(&db).await?; + + if let Err(e) = github::check_latest_release(&db).await { + log::error!("Failed to check for new Yagna release: {}", e); + }; + + let worker_db = db.clone(); + tokio::task::spawn_local(async move { crate::notifier::worker(worker_db).await }); + let pinger_db = db.clone(); + tokio::task::spawn_local(async move { crate::notifier::pinger(pinger_db).await }); + + Ok(()) +} + +pub(crate) async fn worker(db: DbExecutor) { + // TODO: make interval configurable + let mut interval = tokio::time::interval(Duration::from_secs(3600 * 24)); + loop { + interval.tick().await; + if let Err(e) = github::check_latest_release(&db).await { + log::error!("Failed to check for new Yagna release: {}", e); + }; + } +} + +pub(crate) async fn pinger(db: DbExecutor) -> ! { + // TODO: make interval configurable + let mut interval = tokio::time::interval(Duration::from_secs(30 * 60)); + loop { + let release_dao = db.as_dao::(); + interval.tick().await; + match release_dao.pending_release().await { + Ok(Some(release)) => { + if !release.seen { + log::warn!("{}", ReleaseMessage::Available(&release.into())) + } + } + Ok(None) => log::trace!("Your Yagna is up to date"), + Err(e) => log::error!("Fetching new Yagna release from DB: {}", e), + } + } +} + +#[cfg(test)] +mod tests { + use chrono::NaiveDateTime; + + #[test] + fn test_default_release_ts() { + NaiveDateTime::parse_from_str( + &format!("{}T00:00:00Z", ya_compile_time_utils::build_date()), + "%Y-%m-%dT%H:%M:%S%Z", + ) + .unwrap(); + } +} diff --git a/core/version/src/service.rs b/core/version/src/service.rs new file mode 100644 index 0000000000..25ae561ee0 --- /dev/null +++ b/core/version/src/service.rs @@ -0,0 +1,29 @@ +use ya_persistence::executor::DbExecutor; +use ya_service_api_interfaces::{Provider, Service}; + +use crate::db::migrations; + +pub(crate) mod cli; +mod gsb; +mod rest; + +pub struct VersionService; + +impl Service for VersionService { + type Cli = cli::VersionCLI; +} + +impl VersionService { + pub async fn gsb>(ctx: &C) -> anyhow::Result<()> { + let db = ctx.component(); + db.apply_migration(migrations::run_with_output)?; + crate::notifier::on_start(&db).await?; + gsb::bind_gsb(&db); + + Ok(()) + } + + pub fn rest>(ctx: &C) -> actix_web::Scope { + rest::web_scope(ctx.component()) + } +} diff --git a/core/version/src/service/cli.rs b/core/version/src/service/cli.rs new file mode 100644 index 0000000000..bf18054868 --- /dev/null +++ b/core/version/src/service/cli.rs @@ -0,0 +1,94 @@ +use metrics::counter; +use structopt::{clap::AppSettings, StructOpt}; + +use ya_core_model::version; +use ya_service_api::{CliCtx, CommandOutput}; +use ya_service_bus::{typed as bus, RpcEndpoint}; + +const UPDATE_CMD: &'static str = "curl -sSf https://join.golem.network/as-provider | bash -"; + +#[derive(thiserror::Error, Debug, Clone)] +pub(crate) enum ReleaseMessage<'a> { + #[error("New Yagna {0} is available!\nUpdate via\n\t`{UPDATE_CMD}`")] + Available(&'a version::Release), + #[error("Your Yagna is up to date: {0}")] + UpToDate(&'a version::Release), + #[error("Release skipped: {0}")] + Skipped(&'a version::Release), + #[error("No pending release to skip")] + NotSkipped, +} + +/// Yagna version management. +#[derive(StructOpt, Debug)] +pub enum VersionCLI { + /// Show current Yagna version and updates if available. + Show, + /// Checks if there is new Yagna version available and shows it. + Check, + /// Stop logging warnings about latest Yagna release availability. + #[structopt(setting = AppSettings::Hidden)] + Skip, +} + +impl VersionCLI { + pub async fn run_command(self, ctx: &CliCtx) -> anyhow::Result { + match self { + VersionCLI::Show => show(version::Get::show_only(), ctx).await, + VersionCLI::Check => show(version::Get::with_check(), ctx).await, + VersionCLI::Skip => CommandOutput::object( + match bus::service(version::BUS_ID) + .send(version::Skip()) + .await?? + { + Some(r) => { + counter!("version.skip", 1); + ReleaseMessage::Skipped(&r).to_string() + } + None => ReleaseMessage::NotSkipped.to_string(), + }, + ), + } + } +} + +async fn show(msg: version::Get, ctx: &CliCtx) -> anyhow::Result { + let version_info = bus::service(version::BUS_ID).send(msg).await??; + if ctx.json_output { + return CommandOutput::object(version_info); + } + CommandOutput::object(match &version_info.pending { + Some(r) => ReleaseMessage::Available(r).to_string(), + None => ReleaseMessage::UpToDate(&version_info.current).to_string(), + }) +} + +#[cfg(test)] +mod test { + use super::*; + use chrono::NaiveDateTime; + use ya_core_model::version::Release; + + #[test] + fn test_release_available_to_string() { + let now = NaiveDateTime::parse_from_str("2015-10-13T15:43:00GMT+2", "%Y-%m-%dT%H:%M:%S%Z") + .unwrap(); + let r = Release { + version: "0.6.1".to_string(), + name: "some code name".to_string(), + seen: false, + release_ts: now, + insertion_ts: None, + update_ts: None, + }; + + assert_eq!( + ReleaseMessage::Available(&r).to_string(), + format!( + "New Yagna Version 0.6.1 'some code name' released 2015-10-13 is available!\n\ + Update via\n\ + \t`curl -sSf https://join.golem.network/as-provider | bash -`" + ) + ); + } +} diff --git a/core/version/src/service/gsb.rs b/core/version/src/service/gsb.rs new file mode 100644 index 0000000000..a8e53e6ad0 --- /dev/null +++ b/core/version/src/service/gsb.rs @@ -0,0 +1,53 @@ +use metrics::counter; + +use ya_core_model::version; +use ya_persistence::executor::DbExecutor; +use ya_service_bus::{typed as bus, RpcMessage}; + +use crate::db::dao::ReleaseDAO; +use crate::service::cli::ReleaseMessage; + +pub type RpcMessageResult = Result<::Item, ::Error>; + +pub fn bind_gsb(db: &DbExecutor) { + bus::ServiceBinder::new(version::BUS_ID, db, ()) + .bind(skip_version_gsb) + .bind(get_version_gsb); + + // Initialize counters to 0 value. Otherwise they won't appear on metrics endpoint + // until first change to value will be made. + counter!("version.new", 0); + counter!("version.skip", 0); +} + +async fn skip_version_gsb( + db: DbExecutor, + _caller: String, + _msg: version::Skip, +) -> RpcMessageResult { + match db.as_dao::().skip_pending_release().await { + Ok(r) => Ok(r.map(|r| { + let r = r.into(); + log::info!("{}", ReleaseMessage::Skipped(&r)); + r + })), + Err(e) => Err(e.to_string().into()), + } +} + +async fn get_version_gsb( + db: DbExecutor, + _caller: String, + msg: version::Get, +) -> RpcMessageResult { + if msg.check { + crate::github::check_latest_release(&db) + .await + .map_err(|e| e.to_string())?; + } + + db.as_dao::() + .version() + .await + .map_err(|e| e.to_string().into()) +} diff --git a/core/version/src/service/rest.rs b/core/version/src/service/rest.rs new file mode 100644 index 0000000000..6f83028eeb --- /dev/null +++ b/core/version/src/service/rest.rs @@ -0,0 +1,22 @@ +use crate::db::dao::ReleaseDAO; + +use ya_client::model::ErrorMessage; +use ya_persistence::executor::DbExecutor; + +use actix_web::{web, HttpResponse, Responder}; + +pub const VERSION_API_PATH: &str = ""; + +pub fn web_scope(db: DbExecutor) -> actix_web::Scope { + actix_web::web::scope(VERSION_API_PATH) + .data(db) + .service(get_version) +} + +#[actix_web::get("/version")] +async fn get_version(db: web::Data) -> impl Responder { + match db.as_dao::().version().await { + Ok(v) => HttpResponse::Ok().json(v), + Err(e) => HttpResponse::InternalServerError().json(ErrorMessage::new(e.to_string())), + } +} diff --git a/golem_cli/Cargo.toml b/golem_cli/Cargo.toml index 9c98646b61..3429ff8e88 100644 --- a/golem_cli/Cargo.toml +++ b/golem_cli/Cargo.toml @@ -1,38 +1,39 @@ [package] name = "golemsp" -description = "User friedly CLI for running provider" +description = "User friedly CLI for running Golem Provider" version = "0.1.0" authors = ["Golem Factory "] edition = "2018" [dependencies] -actix-rt="1.1" ya-compile-time-utils = "0.1" +ya-core-model = { version = "0.2", features=["payment", "version"] } +ya-utils-path = "0.1.0" +ya-utils-process = { version = "0.1.0", features = ["lock"] } + +actix-rt="1.1" +ansi_term="0.12.1" anyhow = "1.0" bigdecimal = { version = "0.1.0"} byte-unit = "4.0" chrono = { version = "0.4", features=["serde"] } +crossterm="0.18.0" +directories = "2.0.2" dotenv = "0.15" env_logger = "0.7" futures = "0.3" lazy_static = "1.4" log = "0.4" +names = "0.10.0" +prettytable-rs = "0.8.0" +promptly = "0.3.0" +rustyline="6.3.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" strip-ansi-escapes = "0.1" structopt = "0.3" tokio = { version = "0.2", features = ["process", "rt-core", "signal", "time", "io-util", "io-std"] } url = "2.1" -directories = "2.0.2" -promptly = "0.3.0" -names = "0.10.0" -crossterm="0.18.0" -rustyline="6.3.0" -prettytable-rs = "0.8.0" -ansi_term="0.12.1" -ya-core-model = { version = "0.2.1", path="../core/model", features=["payment"] } -ya-utils-path = "0.1.0" -ya-utils-process = { version = "0.1.0", features = ["lock"] } [target.'cfg(target_family = "unix")'.dependencies] libc="0.2.73" diff --git a/golem_cli/src/command/yagna.rs b/golem_cli/src/command/yagna.rs index 7ff0576ad5..cc8366a0b9 100644 --- a/golem_cli/src/command/yagna.rs +++ b/golem_cli/src/command/yagna.rs @@ -11,6 +11,7 @@ use std::process::Stdio; use tokio::process::{Child, Command}; use ya_core_model::payment::local::{InvoiceStats, InvoiceStatusNotes, StatusNotes, StatusResult}; +use ya_core_model::version::VersionInfo; pub static DEFAULT_DRIVER: &'static str = "zksync"; pub static DEFAULT_NETWORK: &'static str = "mainnet"; @@ -163,6 +164,7 @@ impl YagnaCommand { .output() .await?; if output.status.success() { + log::trace!("{}", String::from_utf8_lossy(&output.stdout)); Ok(serde_json::from_slice(&output.stdout)?) } else { Err(anyhow::anyhow!( @@ -179,6 +181,11 @@ impl YagnaCommand { output.map_err(anyhow::Error::msg) } + pub async fn version(mut self) -> anyhow::Result { + self.cmd.args(&["--json", "version", "show"]); + self.run().await + } + pub async fn payment_status( mut self, address: Option<&str>, diff --git a/golem_cli/src/status.rs b/golem_cli/src/status.rs index 51cbe6c716..fab4c3b42f 100644 --- a/golem_cli/src/status.rs +++ b/golem_cli/src/status.rs @@ -105,14 +105,22 @@ pub async fn run(args: StatusCommand) -> Result { Style::new().fg(Colour::Red).paint("is not running") ]); } - table.add_row(row!["version", ya_compile_time_utils::semver_str()]); - table.add_row(row!["commit", ya_compile_time_utils::git_rev()]); - table.add_row(row!["date", ya_compile_time_utils::build_date()]); + table.add_row(row!["Version", ya_compile_time_utils::semver_str()]); + table.add_row(row!["Commit", ya_compile_time_utils::git_rev()]); + table.add_row(row!["Date", ya_compile_time_utils::build_date()]); table.add_row(row![ - "build", + "Build", ya_compile_time_utils::build_number_str().unwrap_or("-") ]); + if let Some(pending) = cmd.yagna()?.version().await?.pending { + let ver = format!("{} released!", pending.version); + table.add_row(row![ + "New Version", + Style::new().fg(Colour::Fixed(220)).paint(ver) + ]); + } + table.add_empty_row(); table.add_row(row!["Node Name", &config.node_name.unwrap_or_default()]); table.add_row(row!["Subnet", &config.subnet.unwrap_or_default()]); diff --git a/utils/compile-time-utils/src/lib.rs b/utils/compile-time-utils/src/lib.rs index 93196455f1..ac1f6de247 100644 --- a/utils/compile-time-utils/src/lib.rs +++ b/utils/compile-time-utils/src/lib.rs @@ -31,7 +31,11 @@ pub fn build_number() -> Option { /// convert tag to a semantic version pub fn semver_str() -> &'static str { - let mut version = git_tag(); + tag2semver(git_tag()) +} + +pub fn tag2semver(tag: &str) -> &str { + let mut version = tag; for prefix in ["pre-rel-", "v"].iter() { if version.starts_with(prefix) { version = &version[prefix.len()..];