extract redis into the infrastructure crate

This commit is contained in:
Denis-Cosmin NUTIU 2024-12-26 12:58:38 +02:00
parent 303d8d303e
commit eaca4769a0
8 changed files with 34 additions and 10 deletions

View file

@ -5,6 +5,7 @@
<sourceFolder url="file://$MODULE_DIR$/scrapper/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/post/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/infrastructure/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />

View file

@ -1,6 +1,7 @@
[workspace]
members = [
"post",
"infrastructure",
"scrapper",
]
resolver = "2"

20
infrastructure/Cargo.toml Normal file
View file

@ -0,0 +1,20 @@
[package]
name = "infrastructure"
version = "0.1.0"
edition = "2021"
[dependencies]
tokio = { version = "1", features = ["full"] }
# Note: This appears unused by the RustRover analyzer, but it works.
# If in the future it stops working for whatever reason because the dependency has
# the same name as the module, then we can try to rename it using `package`.
redis = { version = "0.27.6", features = ["tokio-comp"] }
md5 = "0.7.0"
serde = { version = "1.0.216", features = ["derive"] }
serde_json = "1.0.134"
log = "0.4.22"
[dev-dependencies]
rand = "0.8.5"
serial_test = "3.2.0"
post = {path = "../post"}

7
infrastructure/readme.md Normal file
View file

@ -0,0 +1,7 @@
# Infrastructure
Implements shared infrastructure components.
## RedisService
A service for interacting with Redis.

View file

@ -0,0 +1,3 @@
pub mod redis;
pub use redis::RedisService;

View file

@ -13,12 +13,5 @@ clokwerk = "0.4.0"
log = "0.4.22"
ctrlc = "3.4.5"
clap = { version = "4.5.23", features = ["derive"] }
redis = { version = "0.27.6", features = ["tokio-comp"] }
md5 = "0.7.0"
serde = { version = "1.0.216", features = ["derive"] }
serde_json = "1.0.134"
post = {path = "../post"}
[dev-dependencies]
rand = "0.8.5"
serial_test = "3.2.0"
infrastructure = { path = "../infrastructure"}

View file

@ -1,9 +1,9 @@
use crate::cli::CliArgs;
use crate::redis_service::RedisService;
use crate::scrapper::gfourmedia::G4Media;
use crate::scrapper::WebScrapperEngine;
use clap::Parser;
use clokwerk::{AsyncScheduler, Interval, TimeUnits};
use infrastructure::RedisService;
use log::{debug, error, info};
use post::NewsPost;
use std::sync::atomic::{AtomicBool, Ordering};
@ -13,7 +13,6 @@ use std::time::Duration;
use tokio::task::JoinHandle;
mod cli;
mod redis_service;
mod scrapper;
/// Runs the scheduler in a separated thread.