apalis-sqlite 1.0.0-rc.7

Background task processing for rust using apalis and sqlite
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use sqlx::{Executor, Sqlite};

/// Lock a task, given a worker
pub async fn lock_task<E: for<'a> Executor<'a, Database = Sqlite>>(
    pool: E,
    task_id: &str,
    worker_id: &str,
) -> Result<(), sqlx::Error> {
    let res = sqlx::query_file!("queries/task/lock.sql", task_id, worker_id)
        .execute(pool)
        .await?;

    if res.rows_affected() == 0 {
        return Err(sqlx::Error::RowNotFound);
    }
    Ok(())
}