Compare commits

...

2 commits

Author SHA1 Message Date
Diggory Blake c1d7ad4a2f
Bump version and fix clippy warning 2023-10-11 23:37:28 +01:00
Incomplete 5e4f160d91
Upgrade sqlx to 0.7.1 (#48) 2023-10-11 19:37:25 +01:00
5 changed files with 16 additions and 10 deletions

View file

@ -1,4 +1,7 @@
{
"rust-analyzer.checkOnSave.allFeatures": false,
"rust-analyzer.cargo.allFeatures": false
"rust-analyzer.cargo.allFeatures": false,
"rust-analyzer.cargo.features": [
"runtime-tokio-native-tls"
]
}

View file

@ -1,6 +1,6 @@
[package]
name = "sqlxmq"
version = "0.4.1"
version = "0.5.0"
authors = ["Diggory Blake <diggsey@googlemail.com>"]
edition = "2018"
license = "MIT OR Apache-2.0"
@ -15,7 +15,7 @@ members = ["sqlxmq_macros", "sqlxmq_stress"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sqlx = { version = "0.6.0", features = ["postgres", "chrono", "uuid"] }
sqlx = { version = "0.7.1", features = ["postgres", "chrono", "uuid"] }
tokio = { version = "1.8.3", features = ["full"] }
dotenv = "0.15.0"
chrono = "0.4.19"
@ -23,7 +23,7 @@ uuid = { version = "1.1.2", features = ["v4"] }
log = "0.4.14"
serde_json = "1.0.64"
serde = "1.0.124"
sqlxmq_macros = { version = "0.4.1", path = "sqlxmq_macros" }
sqlxmq_macros = { version = "0.5.0", path = "sqlxmq_macros" }
anymap2 = "0.13.0"
[features]

View file

@ -1,6 +1,6 @@
[package]
name = "sqlxmq_macros"
version = "0.4.1"
version = "0.5.0"
authors = ["Diggory Blake <diggsey@googlemail.com>"]
edition = "2018"
license = "MIT OR Apache-2.0"

View file

@ -15,10 +15,13 @@ use crate::hidden::{BuildFn, RunFn};
use crate::utils::Opaque;
use crate::{JobBuilder, JobRunnerOptions};
type BoxedError = Box<dyn Error + Send + 'static>;
/// Stores a mapping from job name to job. Can be used to construct
/// a job runner.
pub struct JobRegistry {
error_handler: Arc<dyn Fn(&str, Box<dyn Error + Send + 'static>) + Send + Sync>,
#[allow(clippy::type_complexity)]
error_handler: Arc<dyn Fn(&str, BoxedError) + Send + Sync>,
job_map: HashMap<&'static str, &'static NamedJob>,
context: Map<dyn CloneAnySendSync + Send + Sync>,
}
@ -53,7 +56,7 @@ impl JobRegistry {
/// Set a function to be called whenever a job returns an error.
pub fn set_error_handler(
&mut self,
error_handler: impl Fn(&str, Box<dyn Error + Send + 'static>) + Send + Sync + 'static,
error_handler: impl Fn(&str, BoxedError) + Send + Sync + 'static,
) -> &mut Self {
self.error_handler = Arc::new(error_handler);
self
@ -83,7 +86,7 @@ impl JobRegistry {
}
/// The default error handler implementation, which simply logs the error.
pub fn default_error_handler(name: &str, error: Box<dyn Error + Send + 'static>) {
pub fn default_error_handler(name: &str, error: BoxedError) {
log::error!("Job `{}` failed: {}", name, error);
}

View file

@ -142,7 +142,7 @@ impl CurrentJob {
&mut self,
mut tx: sqlx::Transaction<'_, Postgres>,
) -> Result<(), sqlx::Error> {
self.delete(&mut tx).await?;
self.delete(&mut *tx).await?;
tx.commit().await?;
self.stop_keep_alive().await;
Ok(())
@ -161,7 +161,7 @@ impl CurrentJob {
mut tx: sqlx::Transaction<'_, Postgres>,
checkpoint: &Checkpoint<'_>,
) -> Result<(), sqlx::Error> {
checkpoint.execute(self.id, &mut tx).await?;
checkpoint.execute(self.id, &mut *tx).await?;
tx.commit().await?;
Ok(())
}