apalis-postgres 1.0.0-rc.9

Background task processing for rust using apalis and postgres
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use sqlx::{Error, Executor};

/// Lock multiple tasks, given a worker
pub async fn lock_tasks<E>(conn: &mut E, task_ids: &[String], worker_id: &str) -> Result<u64, Error>
where
    for<'e> &'e mut E: Executor<'e, Database = sqlx::Postgres>,
{
    let res = sqlx::query_file!("queries/task/lock_by_id.sql", task_ids, worker_id)
        .execute(&mut *conn)
        .await?;

    Ok(res.rows_affected())
}