extract stuff to common crate

This commit is contained in:
OMGeeky
2024-04-23 21:44:18 +02:00
parent 9124395412
commit d89ce798e7
3 changed files with 52 additions and 23 deletions

60
Cargo.lock generated
View File

@@ -479,6 +479,15 @@ version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5"
[[package]]
name = "crossbeam-channel"
version = "0.5.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-queue"
version = "0.3.11"
@@ -1926,9 +1935,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustix"
version = "0.38.32"
version = "0.38.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89"
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
dependencies = [
"bitflags 2.5.0",
"errno",
@@ -1969,9 +1978,9 @@ dependencies = [
[[package]]
name = "rustls-pki-types"
version = "1.4.1"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247"
checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54"
[[package]]
name = "rustls-webpki"
@@ -2300,9 +2309,9 @@ dependencies = [
[[package]]
name = "signal-hook-registry"
version = "1.4.1"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
dependencies = [
"libc",
]
@@ -2716,18 +2725,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.58"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.58"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66"
dependencies = [
"proc-macro2",
"quote",
@@ -2921,6 +2930,18 @@ dependencies = [
"tracing-core",
]
[[package]]
name = "tracing-appender"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf"
dependencies = [
"crossbeam-channel",
"thiserror",
"time",
"tracing-subscriber",
]
[[package]]
name = "tracing-attributes"
version = "0.1.27"
@@ -2979,11 +3000,25 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "twba-backup-config"
version = "0.1.3"
source = "git+https://github.com/OMGeeky/backup_config.git#88645945830d3076478827503fef43541a2f047e"
version = "0.1.5"
source = "git+https://github.com/OMGeeky/backup_config.git#c42b6fca97502bd3f590f78324cfc9437e5ce20d"
dependencies = [
"confique",
"serde",
"shellexpand",
"tracing",
]
[[package]]
name = "twba-common"
version = "0.1.0"
source = "git+https://github.com/OMGeeky/twba.common.git#a3499ea8bf573db344ec8269782ecd576f3291b5"
dependencies = [
"tracing",
"tracing-appender",
"tracing-subscriber",
"twba-backup-config",
"twba-local-db",
]
[[package]]
@@ -3003,6 +3038,7 @@ dependencies = [
"tracing",
"tracing-subscriber",
"twba-backup-config",
"twba-common",
"twba-local-db",
"twba-reqwest-backoff",
]

View File

@@ -9,6 +9,7 @@ edition = "2021"
twba-backup-config = { version = "0.1.1", git = "https://github.com/OMGeeky/backup_config.git" }
twba-local-db = { version = "0.2", git = "https://github.com/OMGeeky/twitch_backup.local_db.git" }
twba-reqwest-backoff = { version = "0.1", git = "https://github.com/OMGeeky/twba_reqwest_backoff.git" }
twba-common = { version = "0.1", git = "https://github.com/OMGeeky/twba.common.git" }
tracing-subscriber = "0.3"

View File

@@ -1,5 +1,6 @@
pub mod prelude;
use twba_backup_config::get_default_builder;
use prelude::*;
pub mod client;
mod errors;
@@ -7,12 +8,7 @@ pub mod twitch;
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::INFO)
.with_env_filter(
"sea_orm=warn,sea_orm_migration=warn,sqlx=warn,twba_downloader=trace,local_db=warn,twba_reqwest_backoff=warn",
)
.init();
let _guard = twba_common::init_tracing("twba_downloader");
info!("Hello, world!");
let x = run().await;
@@ -30,11 +26,7 @@ async fn main() -> Result<()> {
#[tracing::instrument]
async fn run() -> Result<()> {
let conf = Conf::builder()
.env()
.file("./settings.toml")
.file(shellexpand::tilde("~/twba/config.toml").to_string())
.file(std::env::var("TWBA_CONFIG").unwrap_or_else(|_| "~/twba/config.toml".to_string()))
let conf = get_default_builder()
.load()
.map_err(|e| {
error!("Failed to load config: {:?}", e);