fix Error struct export for asynk
(#61)
* fix Error struct export for `asynk` * fix imports in tests * bump version
This commit is contained in:
parent
3f8b189f90
commit
2bf660c9ee
8 changed files with 38 additions and 21 deletions
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
## 0.7.1 (2022-08-04)
|
||||
|
||||
- Fix a conflict in exports of the `blocking` and the `asynk` features - [#61](https://github.com/ayrat555/fang/pull/61)
|
||||
|
||||
## 0.7.0 (2022-08-03)
|
||||
|
||||
### [#21](https://github.com/ayrat555/fang/pull/21)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "fang"
|
||||
version = "0.7.0"
|
||||
version = "0.7.1"
|
||||
authors = ["Ayrat Badykov <ayratin555@gmail.com>" , "Pepe Márquez <pepe.marquezromero@gmail.com>"]
|
||||
description = "Background job processing library for Rust"
|
||||
repository = "https://github.com/ayrat555/fang"
|
||||
|
@ -46,7 +46,6 @@ version = "0.8"
|
|||
features = ["with-serde_json-1" , "with-uuid-0_8" , "with-chrono-0_4"]
|
||||
optional = true
|
||||
|
||||
|
||||
[dependencies.postgres-types]
|
||||
version = "0.X.X"
|
||||
features = ["derive"]
|
||||
|
|
10
README.md
10
README.md
|
@ -18,14 +18,20 @@ Background task processing library for Rust. It uses Postgres DB as a task queue
|
|||
#### Blocking feature
|
||||
```toml
|
||||
[dependencies]
|
||||
fang = { version = "0.7" , features = ["blocking"]}
|
||||
fang = { version = "0.7" , features = ["blocking"], default-features = false }
|
||||
```
|
||||
|
||||
#### Asynk feature
|
||||
```toml
|
||||
[dependencies]
|
||||
fang = { version = "0.7" , features = ["asynk"]}
|
||||
fang = { version = "0.7" , features = ["asynk"], default-features = false }
|
||||
```
|
||||
|
||||
#### Both features
|
||||
```toml
|
||||
fang = { version = "0.7" }
|
||||
```
|
||||
|
||||
*Supports rustc 1.62+*
|
||||
|
||||
2. Create `fang_tasks` table in the Postgres database. The migration can be found in [the migrations directory](https://github.com/ayrat555/fang/blob/master/migrations/2021-06-05-112912_create_fang_tasks/up.sql).
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use crate::asynk::async_runnable::AsyncRunnable;
|
||||
use crate::asynk::async_runnable::Error as FangError;
|
||||
use crate::AsyncRunnable;
|
||||
use async_trait::async_trait;
|
||||
use bb8_postgres::bb8::Pool;
|
||||
use bb8_postgres::bb8::RunError;
|
||||
use bb8_postgres::tokio_postgres::row::Row;
|
||||
#[cfg(test)]
|
||||
use bb8_postgres::tokio_postgres::tls::NoTls;
|
||||
use bb8_postgres::tokio_postgres::tls::{MakeTlsConnect, TlsConnect};
|
||||
use bb8_postgres::tokio_postgres::Socket;
|
||||
use bb8_postgres::tokio_postgres::Transaction;
|
||||
|
@ -18,6 +16,9 @@ use thiserror::Error;
|
|||
use typed_builder::TypedBuilder;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[cfg(test)]
|
||||
use bb8_postgres::tokio_postgres::tls::NoTls;
|
||||
|
||||
const INSERT_TASK_QUERY: &str = include_str!("queries/insert_task.sql");
|
||||
const INSERT_PERIODIC_TASK_QUERY: &str = include_str!("queries/insert_periodic_task.sql");
|
||||
const SCHEDULE_NEXT_TASK_QUERY: &str = include_str!("queries/schedule_next_task.sql");
|
||||
|
@ -333,6 +334,7 @@ impl AsyncQueueable for AsyncQueueTest<'_> {
|
|||
Ok(task)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Tls> AsyncQueue<Tls>
|
||||
where
|
||||
Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static,
|
||||
|
@ -463,6 +465,7 @@ where
|
|||
let task = Self::row_to_task(row);
|
||||
Ok(task)
|
||||
}
|
||||
|
||||
async fn schedule_next_task_query(
|
||||
transaction: &mut Transaction<'_>,
|
||||
periodic_task: PeriodicTask,
|
||||
|
@ -477,6 +480,7 @@ where
|
|||
let periodic_task = Self::row_to_periodic_task(row);
|
||||
Ok(periodic_task)
|
||||
}
|
||||
|
||||
async fn insert_periodic_task_query(
|
||||
transaction: &mut Transaction<'_>,
|
||||
metadata: serde_json::Value,
|
||||
|
@ -516,6 +520,7 @@ where
|
|||
Ok(Some(periodic_tasks))
|
||||
}
|
||||
}
|
||||
|
||||
async fn execute_query(
|
||||
transaction: &mut Transaction<'_>,
|
||||
query: &str,
|
||||
|
@ -545,6 +550,7 @@ where
|
|||
None => Self::insert_task_query(transaction, metadata, task_type).await,
|
||||
}
|
||||
}
|
||||
|
||||
async fn find_task_by_metadata_query(
|
||||
transaction: &mut Transaction<'_>,
|
||||
metadata: &serde_json::Value,
|
||||
|
@ -558,6 +564,7 @@ where
|
|||
Err(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn row_to_periodic_task(row: Row) -> PeriodicTask {
|
||||
let id: Uuid = row.get("id");
|
||||
let metadata: serde_json::Value = row.get("metadata");
|
||||
|
@ -578,6 +585,7 @@ where
|
|||
.updated_at(updated_at)
|
||||
.build()
|
||||
}
|
||||
|
||||
fn row_to_task(row: Row) -> Task {
|
||||
let id: Uuid = row.get("id");
|
||||
let metadata: serde_json::Value = row.get("metadata");
|
||||
|
@ -768,8 +776,8 @@ mod async_queue_tests {
|
|||
use super::AsyncQueueable;
|
||||
use super::FangTaskState;
|
||||
use super::Task;
|
||||
use crate::asynk::AsyncError as Error;
|
||||
use crate::asynk::AsyncRunnable;
|
||||
use crate::asynk::Error;
|
||||
use async_trait::async_trait;
|
||||
use bb8_postgres::bb8::Pool;
|
||||
use bb8_postgres::tokio_postgres::NoTls;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::asynk::async_queue::AsyncQueueable;
|
||||
use crate::asynk::async_queue::PeriodicTask;
|
||||
use crate::asynk::AsyncError as Error;
|
||||
use crate::asynk::AsyncRunnable;
|
||||
use crate::asynk::Error;
|
||||
use async_recursion::async_recursion;
|
||||
use log::error;
|
||||
use std::time::Duration;
|
||||
|
@ -169,8 +169,8 @@ mod async_scheduler_tests {
|
|||
use crate::asynk::async_queue::AsyncQueueTest;
|
||||
use crate::asynk::async_queue::AsyncQueueable;
|
||||
use crate::asynk::async_queue::PeriodicTask;
|
||||
use crate::asynk::AsyncError as Error;
|
||||
use crate::asynk::AsyncRunnable;
|
||||
use crate::asynk::Error;
|
||||
use async_trait::async_trait;
|
||||
use bb8_postgres::bb8::Pool;
|
||||
use bb8_postgres::tokio_postgres::NoTls;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::asynk::async_queue::FangTaskState;
|
|||
use crate::asynk::async_queue::Task;
|
||||
use crate::asynk::async_queue::DEFAULT_TASK_TYPE;
|
||||
use crate::asynk::async_runnable::AsyncRunnable;
|
||||
use crate::asynk::Error;
|
||||
use crate::asynk::AsyncError as Error;
|
||||
use crate::{RetentionMode, SleepParams};
|
||||
use log::error;
|
||||
use std::time::Duration;
|
||||
|
@ -216,8 +216,8 @@ mod async_worker_tests {
|
|||
use crate::asynk::async_queue::AsyncQueueable;
|
||||
use crate::asynk::async_queue::FangTaskState;
|
||||
use crate::asynk::async_worker::Task;
|
||||
use crate::asynk::AsyncError as Error;
|
||||
use crate::asynk::AsyncRunnable;
|
||||
use crate::asynk::Error;
|
||||
use crate::RetentionMode;
|
||||
use async_trait::async_trait;
|
||||
use bb8_postgres::bb8::Pool;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::asynk::async_queue::AsyncQueueable;
|
||||
use crate::asynk::async_worker::AsyncWorker;
|
||||
use crate::asynk::Error;
|
||||
use crate::asynk::AsyncError as Error;
|
||||
use crate::{RetentionMode, SleepParams};
|
||||
use async_recursion::async_recursion;
|
||||
use log::error;
|
||||
|
|
|
@ -5,4 +5,4 @@ pub mod async_worker;
|
|||
pub mod async_worker_pool;
|
||||
|
||||
pub use async_runnable::AsyncRunnable;
|
||||
pub use async_runnable::Error;
|
||||
pub use async_runnable::Error as AsyncError;
|
||||
|
|
Loading…
Reference in a new issue