Skip to main content

stormchaser_engine/db/
events.rs

1use sqlx::{Executor, Postgres};
2use stormchaser_model::{EventId, RunId, StepInstanceId};
3
4#[allow(clippy::too_many_arguments)]
5/// Insert event correlation.
6pub async fn insert_event_correlation<'a, E>(
7    executor: E,
8    id: EventId,
9    step_instance_id: StepInstanceId,
10    run_id: RunId,
11    correlation_key: &str,
12    correlation_value: &str,
13) -> Result<sqlx::postgres::PgQueryResult, sqlx::Error>
14where
15    E: Executor<'a, Database = Postgres>,
16{
17    sqlx::query(
18        "INSERT INTO event_correlations (id, step_instance_id, run_id, correlation_key, correlation_value) VALUES ($1, $2, $3, $4, $5)"
19    )
20    .bind(id)
21    .bind(step_instance_id)
22    .bind(run_id)
23    .bind(correlation_key)
24    .bind(correlation_value)
25    .execute(executor)
26    .await
27}