From 3a39676c95bf591c2777bcd6546598433a1b4514 Mon Sep 17 00:00:00 2001 From: Zhang Zhuo Date: Mon, 8 Feb 2021 14:32:26 +0800 Subject: [PATCH] chore: add install_all_deps.sh; upgrade sqlx; change persist policy to MQ only (#72) --- Cargo.lock | 20 +++++++++------- Cargo.toml | 2 +- scripts/install_all_deps.sh | 48 +++++++++++++++++++++++++++++++++++++ src/config.rs | 2 +- 4 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 scripts/install_all_deps.sh diff --git a/Cargo.lock b/Cargo.lock index e5001f0c..e98ad7cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2149,8 +2149,9 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.4.2" -source = "git+https://github.com/launchbadge/sqlx.git#31abe22e348d6ac668c140de32612f0930c2abec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2739d54a2ae9fdd0f545cb4e4b5574efb95e2ec71b7f921678e246fb20dcaaf" dependencies = [ "sqlx-core", "sqlx-macros", @@ -2158,8 +2159,9 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.4.2" -source = "git+https://github.com/launchbadge/sqlx.git#31abe22e348d6ac668c140de32612f0930c2abec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1cad9cae4ca8947eba1a90e8ec7d3c59e7a768e2f120dc9013b669c34a90711" dependencies = [ "ahash 0.6.3", "atoi", @@ -2209,8 +2211,9 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.4.2" -source = "git+https://github.com/launchbadge/sqlx.git#31abe22e348d6ac668c140de32612f0930c2abec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01caee2b3935b4efe152f3262afbe51546ce3b1fc27ad61014e1b3cf5f55366e" dependencies = [ "dotenv", "either", @@ -2228,8 +2231,9 @@ dependencies = [ [[package]] name = "sqlx-rt" -version = "0.2.0" -source = "git+https://github.com/launchbadge/sqlx.git#31abe22e348d6ac668c140de32612f0930c2abec" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ce2e16b6774c671cc183e1d202386fdf9cde1e8468c1894a7f2a63eb671c4f4" dependencies = [ "once_cell", "tokio", diff --git a/Cargo.toml b/Cargo.toml index 4938d765..da89aa2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ crossbeam-channel = "0.5.0" rdkafka = { version = "0.25.0", features = ["cmake-build"] } nix = "0.19.1" anyhow = "1.0.38" -sqlx = { git = "https://github.com/launchbadge/sqlx.git", features=["runtime-tokio-rustls", "postgres", "chrono", "decimal", "json", "migrate" ] } +sqlx = { version = "0.5.1", features=["runtime-tokio-rustls", "postgres", "chrono", "decimal", "json", "migrate" ] } chrono = { version = "0.4.19", features = ["serde"] } rust_decimal = { version = "1.10.1", features = ["postgres", "bytes", "byteorder"] } rust_decimal_macros = "1.10.1" diff --git a/scripts/install_all_deps.sh b/scripts/install_all_deps.sh new file mode 100644 index 00000000..30efe7bb --- /dev/null +++ b/scripts/install_all_deps.sh @@ -0,0 +1,48 @@ +#!/bin/bash +set -xu + +function install_rust() { + echo 'install rust' + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +} + +function install_docker() { + echo 'install docker' + curl -fsSL https://get.docker.com | bash + sudo groupadd docker + sudo usermod -aG docker $USER + newgrp docker + sudo systemctl start docker + sudo systemctl enable docker +} + +function install_docker_compose() { + echo 'install docker compose' + sudo curl -L "https://github.com/docker/compose/releases/download/1.28.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose +} + +function install_node() { + echo 'install node' + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + nvm install 'lts/*' + nvm use 'lts/*' + npm install --global yarn +} + +function install_sys_deps() { + echo 'install system deps' + sudo apt install libpq-dev cmake gcc g++ postgresql-client-12 +} + +function install_all() { + install_sys_deps + install_rust + install_docker + install_docker_compose + install_node +} + +install_all diff --git a/src/config.rs b/src/config.rs index 03f7c2b4..8205952c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -96,7 +96,7 @@ impl Default for Settings { debug: false, db_log: Default::default(), db_history: Default::default(), - history_persist_policy: PersistPolicy::Both, + history_persist_policy: PersistPolicy::ToMessage, assets: Vec::new(), markets: Vec::new(), consumer_group: "kline_data_fetcher".to_string(),