dialtone_sqlx 0.1.0

Dialtone SQLx Back-End
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::db::persistent_queue::JobDbType;
use sqlx::{Executor, Postgres};

pub async fn notify(
    exec: impl Executor<'_, Database = Postgres>,
    job_type: &JobDbType,
) -> Result<Option<()>, sqlx::Error> {
    let result = sqlx::query("select pg_notify($1::text,null)")
        .bind(job_type)
        .fetch_optional(exec)
        .await?;
    match result {
        None => Ok(None),
        Some(_) => Ok(Some(())),
    }
}