pub async fn increment_token(txn: &mut Transaction<'_, Postgres>, token: &Token) -> Result<()> {
    trace!(task_id=?token.task_id,
        trigger_datetime=?token.trigger_datetime.to_rfc3339(),
        "incrementing token");

    sqlx::query(
        "INSERT INTO token(task_id, trigger_datetime, count, state)
            VALUES ($1, $2, 1, 'waiting')
            ON CONFLICT(task_id, trigger_datetime)
            DO UPDATE SET count = token.count + 1",
    )
    .bind(token.task_id)
    .bind(token.trigger_datetime)
    .execute(&mut *txn)
    .await?;

    Ok(())
}
/// Adds a token to a task node
/// Usually you need to update some other state at the same time so it takes in a begun transaction
/// so you can do the other update before committing (eg. update the trigger's last trigger time, or
/// update the state of the upstream task to be 'done')
/// After adding the token you have to send the token over to the process_tokens future to actually
/// check if the node has activated
Adds a token to a task node
Usually you need to update some other state at the same time so it takes in a begun transaction
so you can do the other update before committing
After adding the token you have to send the token over to the process_tokens future to actually
check if the node has activated
Adds a token to a task node Usually you need to update some other state at the same time so it takes in a begun transaction so you can do the other update before committing After adding the token you have to send the token over to the process_tokens future to actually check if the node has activated
pub async fn increment_token(txn: &mut Transaction<'_, Postgres>, token: &Token) -> Result<()> {
    trace!(task_id=?token.task_id,
        trigger_datetime=?token.trigger_datetime.to_rfc3339(),
        "incrementing token");
    sqlx::query(
        "INSERT INTO token(task_id, trigger_datetime, count, state)
            VALUES ($1, $2, 1, 'waiting')
            ON CONFLICT(task_id, trigger_datetime)
            DO UPDATE SET count = token.count + 1",
    )
    .bind(token.task_id)
    .bind(token.trigger_datetime)
    .execute(&mut *txn)
    .await?;
    Ok(())
}
pub async fn increment_token ( txn : & mut Transaction < ' _ , Postgres > , token : & Token ) -> Result < ( ) > { trace ! ( task_id token task_id trigger_datetime token trigger_datetime to_rfc3339 ( ) " " ) ; sqlx :: query ( " " , ) . bind ( token . task_id ) . bind ( token . trigger_datetime ) . execute ( & mut * txn ) . await ? ; Ok ( ( ) ) }
Adds a token to a task node
Usually you need to update some other state at the same time so it takes in a begun transaction
so you can do the other update before committing (eg.
Adds a token to a task node Usually you need to update some other state at the same time so it takes in a begun transaction so you can do the other update before committing ( eg .
txn
&mut Transaction<'_, Postgres>
token
&Token