ff_backend_sqlite/queries/
waitpoint.rs1pub const SELECT_ACTIVE_HMAC_SQL: &str = "SELECT kid, secret FROM ff_waitpoint_hmac \
13 WHERE active = 1 \
14 ORDER BY rotated_at_ms DESC LIMIT 1";
15
16pub const SELECT_HMAC_SECRET_BY_KID_SQL: &str =
17 "SELECT secret FROM ff_waitpoint_hmac WHERE kid = ?1";
18
19pub const DEACTIVATE_ALL_HMAC_SQL: &str =
20 "UPDATE ff_waitpoint_hmac SET active = 0 WHERE active = 1";
21
22pub const INSERT_HMAC_ROW_SQL: &str = "INSERT INTO ff_waitpoint_hmac \
23 (kid, secret, rotated_at_ms, active) \
24 VALUES (?1, ?2, ?3, 1)";
25
26pub const SELECT_ACTIVE_KID_SQL: &str = "SELECT kid FROM ff_waitpoint_hmac \
27 WHERE active = 1 \
28 ORDER BY rotated_at_ms DESC LIMIT 1";
29
30pub const UPSERT_WAITPOINT_PENDING_ACTIVE_SQL: &str = "INSERT INTO ff_waitpoint_pending \
38 (partition_key, waitpoint_id, execution_id, token_kid, token, \
39 created_at_ms, expires_at_ms, waitpoint_key, \
40 state, required_signal_names, activated_at_ms) \
41 VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, 'active', ?9, ?6) \
42 ON CONFLICT (partition_key, waitpoint_id) DO UPDATE SET \
43 token_kid = excluded.token_kid, token = excluded.token, \
44 waitpoint_key = excluded.waitpoint_key, \
45 state = excluded.state, \
46 required_signal_names = excluded.required_signal_names, \
47 activated_at_ms = excluded.activated_at_ms";
48
49pub const INSERT_WAITPOINT_PENDING_SQL: &str = "INSERT INTO ff_waitpoint_pending \
54 (partition_key, waitpoint_id, execution_id, token_kid, token, \
55 created_at_ms, expires_at_ms, waitpoint_key, state, required_signal_names) \
56 VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, 'pending', '[]')";
57
58pub const SELECT_WAITPOINT_KEY_BY_ID_SQL: &str =
59 "SELECT waitpoint_key FROM ff_waitpoint_pending \
60 WHERE partition_key = ?1 AND waitpoint_id = ?2";
61
62pub const SELECT_WAITPOINT_FOR_DELIVER_SQL: &str =
65 "SELECT token_kid, token, waitpoint_key, execution_id \
66 FROM ff_waitpoint_pending \
67 WHERE partition_key = ?1 AND waitpoint_id = ?2";
68
69pub const DELETE_WAITPOINTS_BY_EXEC_SQL: &str =
71 "DELETE FROM ff_waitpoint_pending \
72 WHERE partition_key = ?1 AND execution_id = ?2";
73
74pub const SELECT_EXEC_EXISTS_SQL: &str =
80 "SELECT 1 FROM ff_exec_core WHERE partition_key = ?1 AND execution_id = ?2";
81
82pub const SELECT_PENDING_WAITPOINTS_PAGE_SQL: &str =
93 "SELECT waitpoint_id, waitpoint_key, state, required_signal_names, \
94 created_at_ms, activated_at_ms, expires_at_ms, token_kid, token \
95 FROM ff_waitpoint_pending \
96 WHERE partition_key = ?1 \
97 AND execution_id = ?2 \
98 AND state IN ('pending', 'active') \
99 AND (?3 IS NULL OR waitpoint_id > ?3) \
100 ORDER BY waitpoint_id \
101 LIMIT ?4";