fetch, create fetch mod and AdapterClient
Creates a fetch mod for fetching remote rss content. This implementation is barebones and not great since it doesn't pass any compression or timestamp information.
This commit is contained in:
parent
1c3f4cc854
commit
5d7e96eb31
4 changed files with 288 additions and 1 deletions
|
|
@ -3,12 +3,15 @@ use std::error::Error;
|
|||
type Result<T> = std::result::Result<T, Box<dyn Error>>;
|
||||
|
||||
pub mod db;
|
||||
pub mod fetch;
|
||||
pub mod score;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test_utils;
|
||||
|
||||
pub struct AdapterPool(sqlx::SqlitePool);
|
||||
pub struct AdapterClient(reqwest::Client);
|
||||
|
||||
pub struct AdapterBuilder {
|
||||
database_url: String,
|
||||
}
|
||||
|
|
@ -29,15 +32,18 @@ impl AdapterBuilder {
|
|||
let db = sqlx::sqlite::SqlitePoolOptions::new()
|
||||
.connect(&self.database_url).await?;
|
||||
sqlx::migrate!().run(&db).await?;
|
||||
let client = reqwest::Client::new();
|
||||
|
||||
Ok(Adapter { db: AdapterPool(db) })
|
||||
Ok(Adapter { db: AdapterPool(db), client: AdapterClient(client) })
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Adapter {
|
||||
db: AdapterPool,
|
||||
client: AdapterClient,
|
||||
}
|
||||
|
||||
impl Adapter {
|
||||
pub fn get_pool(&self) -> &AdapterPool { &self.db }
|
||||
pub fn get_client(&self) -> &AdapterClient { &self.client }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue