| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | | use super::{now_ms, Pool}; |
| 5 | | use sqlx::FromRow; |
| 6 | |
|
| 7 | | #[derive(Clone, Debug, Default, FromRow)] |
| 8 | | pub struct Runner { |
| 9 | | pub id: i64, |
| 10 | | pub name: String, |
| 11 | | pub token_hash: String, |
| 12 | | pub source: String, |
| 13 | | pub key: String, |
| 14 | | pub key_name: String, |
| 15 | | pub arch: String, |
| 16 | | pub os: String, |
| 17 | | pub version: String, |
| 18 | | pub labels: String, |
| 19 | | pub max_jobs: i64, |
| 20 | | pub memory_mib: Option<i64>, |
| 21 | | pub cpus: Option<i64>, |
| 22 | | pub state: String, |
| 23 | | pub created_ms: i64, |
| 24 | | pub created_by: String, |
| 25 | | pub last_seen_ms: Option<i64>, |
| 26 | | |
| 27 | | pub scope_owner: String, |
| 28 | | |
| 29 | | pub scope_repo_id: Option<i64>, |
| 30 | | |
| 31 | | pub admin_labels: String, |
| 32 | | |
| 33 | | pub timeout_minutes: Option<i64>, |
| 34 | | |
| 35 | | pub fetches_images: bool, |
| 36 | | |
| 37 | | |
| 38 | | pub free_disk_mib: Option<i64>, |
| 39 | | pub load_x100: Option<i64>, |
| 40 | | pub speed: Option<i64>, |
| 41 | | pub speed_class: Option<i64>, |
| 42 | | pub kernel: String, |
| 43 | | |
| 44 | | pub tiers: String, |
| 45 | | |
| 46 | | pub images: String, |
| 47 | | |
| 48 | | pub profile: String, |
| 49 | | } |
| 50 | |
|
| 51 | |
|
| 52 | | #[derive(Clone, Debug, Default, PartialEq, Eq)] |
| 53 | | pub struct Scope { |
| 54 | | |
| 55 | | pub owner: String, |
| 56 | | |
| 57 | | pub repo_id: Option<i64>, |
| 58 | | } |
| 59 | |
|
| 60 | | impl Scope { |
| 61 | 6× | pub fn is_site(&self) -> bool { |
| 62 | 6× | self.owner.is_empty() && self.repo_id.is_none() |
| 63 | 6× | } |
| 64 | | } |
| 65 | |
|
| 66 | |
|
| 67 | | pub const ONLINE_MS: i64 = 90_000; |
| 68 | |
|
| 69 | | impl Runner { |
| 70 | 111× | pub fn online(&self) -> bool { |
| 71 | 111× | self.last_seen_ms.is_some_and(|t| now_ms() - t < ONLINE_MS) |
| 72 | 111× | } |
| 73 | |
|
| 74 | | |
| 75 | | |
| 76 | 31× | pub fn connectivity(&self) -> &'static str { |
| 77 | 31× | if self.online() { |
| 78 | 29× | "online" |
| 79 | | } else { |
| 80 | 2× | "offline" |
| 81 | | } |
| 82 | 31× | } |
| 83 | |
|
| 84 | | |
| 85 | 32× | pub fn status(&self) -> &'static str { |
| 86 | 32× | match self.state.as_str() { |
| 87 | 32× | "disabled" => "disabled", |
| 88 | 32× | "draining" => "draining", |
| 89 | 32× | _ if self.online() => "online", |
| 90 | 0× | _ => "offline", |
| 91 | | } |
| 92 | 32× | } |
| 93 | |
|
| 94 | | |
| 95 | | |
| 96 | 55× | pub fn label_list(&self) -> Vec<&str> { |
| 97 | 55× | let mut out: Vec<&str> = self.labels.split(',').filter(|l| !l.is_empty()).collect(); |
| 98 | 55× | for l in self.admin_label_list() { |
| 99 | 10× | if !out.contains(&l) { |
| 100 | 10× | out.push(l); |
| 101 | 10× | } |
| 102 | | } |
| 103 | 55× | out |
| 104 | 55× | } |
| 105 | |
|
| 106 | 282× | pub fn admin_label_list(&self) -> Vec<&str> { |
| 107 | 289× | self.admin_labels.split(',').filter(|l| !l.is_empty()).collect() |
| 108 | 282× | } |
| 109 | |
|
| 110 | | |
| 111 | 216× | pub fn reported_label_list(&self) -> Vec<&str> { |
| 112 | 216× | self.labels.split(',').filter(|l| !l.is_empty()).collect() |
| 113 | 216× | } |
| 114 | |
|
| 115 | 282× | pub fn scope(&self) -> Scope { |
| 116 | 282× | Scope { owner: self.scope_owner.clone(), repo_id: self.scope_repo_id } |
| 117 | 282× | } |
| 118 | | } |
| 119 | |
|
| 120 | 447× | pub async fn by_token(pool: &Pool, token_hash: &str) -> sqlx::Result<Option<Runner>> { |
| 121 | 447× | sqlx::query_as("SELECT * FROM flow_runners WHERE token_hash = $1").bind(token_hash).fetch_optional(pool).await |
| 122 | 447× | } |
| 123 | |
|
| 124 | 26× | pub async fn get(pool: &Pool, id: i64) -> sqlx::Result<Option<Runner>> { |
| 125 | 26× | sqlx::query_as("SELECT * FROM flow_runners WHERE id = $1").bind(id).fetch_optional(pool).await |
| 126 | 26× | } |
| 127 | |
|
| 128 | 402× | pub async fn list(pool: &Pool) -> sqlx::Result<Vec<Runner>> { |
| 129 | 402× | sqlx::query_as("SELECT * FROM flow_runners ORDER BY name, id").fetch_all(pool).await |
| 130 | 402× | } |
| 131 | |
|
| 132 | |
|
| 133 | 65× | pub async fn configured(pool: &Pool, token_hash: &str, name: &str) -> sqlx::Result<Runner> { |
| 134 | 65× | sqlx::query("INSERT INTO flow_runners (name, token_hash, source, created_ms) VALUES ($1, $2, 'config', $3) ON CONFLICT DO NOTHING") |
| 135 | 65× | .bind(name) |
| 136 | 65× | .bind(token_hash) |
| 137 | 65× | .bind(now_ms()) |
| 138 | 65× | .execute(pool) |
| 139 | 65× | .await?; |
| 140 | 65× | Ok(by_token(pool, token_hash).await?.expect("just made")) |
| 141 | 65× | } |
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | 1× | pub async fn set_limits(pool: &Pool, id: i64, admin_labels: &str, timeout_minutes: Option<i64>) -> sqlx::Result<()> { |
| 147 | 1× | sqlx::query("UPDATE flow_runners SET admin_labels = $1, timeout_minutes = $2 WHERE id = $3") |
| 148 | 1× | .bind(admin_labels) |
| 149 | 1× | .bind(timeout_minutes) |
| 150 | 1× | .bind(id) |
| 151 | 1× | .execute(pool) |
| 152 | 1× | .await?; |
| 153 | 1× | Ok(()) |
| 154 | 1× | } |
| 155 | |
|
| 156 | 350× | pub async fn seen(pool: &Pool, id: i64, name: Option<&str>, info: Option<&flow_core::api::RunnerInfo>) -> sqlx::Result<()> { |
| 157 | 350× | let now = now_ms(); |
| 158 | 350× | match info { |
| 159 | 24× | Some(i) => { |
| 160 | 24× | sqlx::query( |
| 161 | 24× | "UPDATE flow_runners SET arch = $1, os = $2, version = $3, labels = $4, max_jobs = $5, memory_mib = $6, cpus = $7, last_seen_ms = $8 WHERE id = $9", |
| 162 | 24× | ) |
| 163 | 24× | .bind(&i.arch) |
| 164 | 24× | .bind(&i.os) |
| 165 | 24× | .bind(&i.version) |
| 166 | 24× | .bind(i.labels.join(",")) |
| 167 | 24× | .bind(i.max_jobs as i64) |
| 168 | 24× | .bind(i.memory_mib.map(i64::from)) |
| 169 | 24× | .bind(i.cpus.map(i64::from)) |
| 170 | 24× | .bind(now) |
| 171 | 24× | .bind(id) |
| 172 | 24× | .execute(pool) |
| 173 | 24× | .await?; |
| 174 | | } |
| 175 | | None => { |
| 176 | 326× | sqlx::query("UPDATE flow_runners SET last_seen_ms = $1 WHERE id = $2").bind(now).bind(id).execute(pool).await?; |
| 177 | | } |
| 178 | | } |
| 179 | 350× | if let Some(n) = name { |
| 180 | 224× | sqlx::query("UPDATE flow_runners SET name = $1 WHERE id = $2 AND source = 'config'").bind(n).bind(id).execute(pool).await?; |
| 181 | 126× | } |
| 182 | 350× | Ok(()) |
| 183 | 350× | } |
| 184 | |
|
| 185 | |
|
| 186 | 13× | pub async fn set_facts(pool: &Pool, id: i64, f: &flow_core::api::Facts) -> sqlx::Result<()> { |
| 187 | 13× | sqlx::query("UPDATE flow_runners SET free_disk_mib = $1, load_x100 = $2, speed = $3, speed_class = $4, kernel = $5 WHERE id = $6") |
| 188 | 13× | .bind(f.free_disk_mib.map(|v| v.min(i64::MAX as u64) as i64)) |
| 189 | 13× | .bind(f.load_x100.map(i64::from)) |
| 190 | 13× | .bind(f.speed.map(i64::from)) |
| 191 | 13× | .bind(f.speed_class.map(i64::from)) |
| 192 | 13× | .bind(f.kernel.clone().unwrap_or_default()) |
| 193 | 13× | .bind(id) |
| 194 | 13× | .execute(pool) |
| 195 | 13× | .await?; |
| 196 | 13× | Ok(()) |
| 197 | 13× | } |
| 198 | |
|
| 199 | | impl Runner { |
| 200 | | |
| 201 | | |
| 202 | 16× | pub fn facts_line(&self) -> String { |
| 203 | 16× | let mut out = Vec::new(); |
| 204 | 16× | if let Some(s) = self.speed { |
| 205 | 1× | out.push(format!("speed {s} (class {})", self.speed_class.unwrap_or(0))); |
| 206 | 15× | } |
| 207 | 16× | if let Some(l) = self.load_x100 { |
| 208 | 1× | out.push(format!("load {:.2}", l as f64 / 100.0)); |
| 209 | 15× | } |
| 210 | 16× | if let Some(d) = self.free_disk_mib { |
| 211 | 1× | out.push(if d >= 1024 { format!("{} GiB free", d / 1024) } else { format!("{d} MiB free") }); |
| 212 | 15× | } |
| 213 | 16× | out.join(" · ") |
| 214 | 16× | } |
| 215 | | } |
| 216 | |
|
| 217 | |
|
| 218 | |
|
| 219 | |
|
| 220 | 226× | pub async fn set_offer( |
| 221 | 226× | pool: &Pool, |
| 222 | 226× | id: i64, |
| 223 | 226× | tiers: &[String], |
| 224 | 226× | images: Option<&[String]>, |
| 225 | 226× | fetches_images: bool, |
| 226 | 226× | profile: &str, |
| 227 | 226× | ) -> sqlx::Result<()> { |
| 228 | 226× | let images = images.map(|i| serde_json::to_string(i).unwrap_or_default()).unwrap_or_default(); |
| 229 | 226× | sqlx::query("UPDATE flow_runners SET tiers = $1, images = $2, fetches_images = $3, profile = $4 WHERE id = $5") |
| 230 | 226× | .bind(tiers.join(",")) |
| 231 | 226× | .bind(images) |
| 232 | 226× | .bind(fetches_images) |
| 233 | 226× | .bind(profile) |
| 234 | 226× | .bind(id) |
| 235 | 226× | .execute(pool) |
| 236 | 226× | .await?; |
| 237 | 226× | Ok(()) |
| 238 | 226× | } |
| 239 | |
|
| 240 | | impl Runner { |
| 241 | 42× | pub fn tier_list(&self) -> Vec<&str> { |
| 242 | 49× | self.tiers.split(',').filter(|t| !t.is_empty()).collect() |
| 243 | 42× | } |
| 244 | |
|
| 245 | | |
| 246 | 422× | pub fn image_list(&self) -> Option<Vec<String>> { |
| 247 | 422× | if self.images.is_empty() { |
| 248 | 348× | None |
| 249 | | } else { |
| 250 | 74× | serde_json::from_str(&self.images).ok() |
| 251 | | } |
| 252 | 422× | } |
| 253 | | } |
| 254 | |
|
| 255 | 4× | pub async fn set_state(pool: &Pool, id: i64, state: &str) -> sqlx::Result<()> { |
| 256 | 4× | sqlx::query("UPDATE flow_runners SET state = $1, state_ms = $2 WHERE id = $3") |
| 257 | 4× | .bind(state) |
| 258 | 4× | .bind(super::now_ms()) |
| 259 | 4× | .bind(id) |
| 260 | 4× | .execute(pool) |
| 261 | 4× | .await?; |
| 262 | 4× | Ok(()) |
| 263 | 4× | } |
| 264 | |
|
| 265 | |
|
| 266 | |
|
| 267 | 12× | pub async fn erroring(pool: &Pool, id: i64, n: u32) -> sqlx::Result<Option<String>> { |
| 268 | 12× | if n == 0 { |
| 269 | 0× | return Ok(None); |
| 270 | 12× | } |
| 271 | 12× | let last: Vec<(String, String)> = sqlx::query_as( |
| 272 | 12× | "SELECT j.status, j.error FROM flow_jobs j JOIN flow_runners r ON r.id = j.runner_id |
| 273 | 12× | WHERE j.runner_id = $1 AND j.finished_ms IS NOT NULL AND j.finished_ms >= r.state_ms |
| 274 | 12× | ORDER BY j.finished_ms DESC, j.id DESC LIMIT $2", |
| 275 | 12× | ) |
| 276 | 12× | .bind(id) |
| 277 | 12× | .bind(n as i64) |
| 278 | 12× | .fetch_all(pool) |
| 279 | 12× | .await?; |
| 280 | 17× | Ok((last.len() == n as usize && last.iter().all(|(s, _)| s == "error")).then(|| last[0].1.clone())) |
| 281 | 12× | } |
| 282 | |
|
| 283 | |
|
| 284 | 3× | pub async fn remove(pool: &Pool, id: i64) -> sqlx::Result<()> { |
| 285 | 3× | sqlx::query("DELETE FROM flow_runners WHERE id = $1").bind(id).execute(pool).await?; |
| 286 | 3× | Ok(()) |
| 287 | 3× | } |
| 288 | |
|
| 289 | |
|
| 290 | |
|
| 291 | 3× | pub async fn bind_key(pool: &Pool, id: i64, key: &str, name: &str) -> sqlx::Result<String> { |
| 292 | 3× | sqlx::query("UPDATE flow_runners SET key = $1, key_name = $2 WHERE id = $3 AND key = ''") |
| 293 | 3× | .bind(key) |
| 294 | 3× | .bind(name) |
| 295 | 3× | .bind(id) |
| 296 | 3× | .execute(pool) |
| 297 | 3× | .await?; |
| 298 | 3× | sqlx::query_scalar("SELECT key FROM flow_runners WHERE id = $1").bind(id).fetch_one(pool).await |
| 299 | 3× | } |
| 300 | |
|
| 301 | |
|
| 302 | 5× | pub async fn keys(pool: &Pool) -> sqlx::Result<Vec<String>> { |
| 303 | 5× | sqlx::query_scalar("SELECT key FROM flow_runners WHERE key != ''").fetch_all(pool).await |
| 304 | 5× | } |
| 305 | |
|
| 306 | |
|
| 307 | 10× | pub async fn add_registration(pool: &Pool, token_hash: &str, by: &str, scope: &Scope) -> sqlx::Result<()> { |
| 308 | 10× | let now = now_ms(); |
| 309 | 10× | sqlx::query( |
| 310 | 10× | "INSERT INTO flow_runner_registrations (token_hash, created_by, created_ms, expires_ms, scope_owner, scope_repo_id) VALUES ($1, $2, $3, $4, $5, $6)", |
| 311 | 10× | ) |
| 312 | 10× | .bind(token_hash) |
| 313 | 10× | .bind(by) |
| 314 | 10× | .bind(now) |
| 315 | 10× | .bind(now + 24 * 3_600_000) |
| 316 | 10× | .bind(&scope.owner) |
| 317 | 10× | .bind(scope.repo_id) |
| 318 | 10× | .execute(pool) |
| 319 | 10× | .await?; |
| 320 | 10× | Ok(()) |
| 321 | 10× | } |
| 322 | |
|
| 323 | |
|
| 324 | |
|
| 325 | 268× | pub async fn serving(pool: &Pool, owner: &str, repo_id: i64) -> sqlx::Result<Vec<Runner>> { |
| 326 | 268× | sqlx::query_as( |
| 327 | 268× | "SELECT * FROM flow_runners WHERE (scope_owner = '' AND scope_repo_id IS NULL) \ |
| 328 | 268× | OR (scope_owner = $1 AND scope_repo_id IS NULL) OR scope_repo_id = $2 ORDER BY name", |
| 329 | 268× | ) |
| 330 | 268× | .bind(owner) |
| 331 | 268× | .bind(repo_id) |
| 332 | 268× | .fetch_all(pool) |
| 333 | 268× | .await |
| 334 | 268× | } |
| 335 | |
|
| 336 | |
|
| 337 | |
|
| 338 | 20× | pub async fn serving_owner(pool: &Pool, owner: &str) -> sqlx::Result<Vec<Runner>> { |
| 339 | 20× | sqlx::query_as("SELECT * FROM flow_runners WHERE (scope_owner = '' AND scope_repo_id IS NULL) OR scope_owner = $1 ORDER BY name") |
| 340 | 20× | .bind(owner) |
| 341 | 20× | .fetch_all(pool) |
| 342 | 20× | .await |
| 343 | 20× | } |
| 344 | |
|
| 345 | |
|
| 346 | 0× | pub async fn set_scope(pool: &Pool, id: i64, scope: &Scope) -> sqlx::Result<()> { |
| 347 | 0× | sqlx::query("UPDATE flow_runners SET scope_owner = $1, scope_repo_id = $2 WHERE id = $3") |
| 348 | 0× | .bind(&scope.owner) |
| 349 | 0× | .bind(scope.repo_id) |
| 350 | 0× | .bind(id) |
| 351 | 0× | .execute(pool) |
| 352 | 0× | .await?; |
| 353 | 0× | Ok(()) |
| 354 | 0× | } |
| 355 | |
|
| 356 | |
|
| 357 | 12× | pub async fn pending_registrations(pool: &Pool) -> sqlx::Result<Vec<(String, i64, i64)>> { |
| 358 | 12× | sqlx::query_as("SELECT created_by, created_ms, expires_ms FROM flow_runner_registrations WHERE used_ms IS NULL AND expires_ms > $1 ORDER BY created_ms DESC") |
| 359 | 12× | .bind(now_ms()) |
| 360 | 12× | .fetch_all(pool) |
| 361 | 12× | .await |
| 362 | 12× | } |
| 363 | |
|
| 364 | |
|
| 365 | |
|
| 366 | | #[allow(clippy::too_many_arguments)] |
| 367 | 11× | pub async fn register( |
| 368 | 11× | pool: &Pool, |
| 369 | 11× | registration: &str, |
| 370 | 11× | name: &str, |
| 371 | 11× | token_hash: &str, |
| 372 | 11× | key: &str, |
| 373 | 11× | key_name: &str, |
| 374 | 11× | by_default: &str, |
| 375 | 11× | ) -> sqlx::Result<Option<Runner>> { |
| 376 | 11× | let mut tx = super::begin_write(pool).await?; |
| 377 | 11× | let now = now_ms(); |
| 378 | 11× | let found: Option<(String, String, Option<i64>)> = sqlx::query_as( |
| 379 | 11× | "SELECT created_by, scope_owner, scope_repo_id FROM flow_runner_registrations WHERE token_hash = $1 AND used_ms IS NULL AND expires_ms > $2", |
| 380 | 11× | ) |
| 381 | 11× | .bind(registration) |
| 382 | 11× | .bind(now) |
| 383 | 11× | .fetch_optional(&mut *tx) |
| 384 | 11× | .await?; |
| 385 | 11× | let Some((who, scope_owner, scope_repo_id)) = found else { return Ok(None) }; |
| 386 | 10× | let id: i64 = sqlx::query_scalar( |
| 387 | 10× | "INSERT INTO flow_runners (name, token_hash, source, key, key_name, created_ms, created_by, scope_owner, scope_repo_id) VALUES ($1, $2, 'registered', $3, $4, $5, $6, $7, $8) RETURNING id", |
| 388 | | ) |
| 389 | 10× | .bind(name) |
| 390 | 10× | .bind(token_hash) |
| 391 | 10× | .bind(key) |
| 392 | 10× | .bind(key_name) |
| 393 | 10× | .bind(now) |
| 394 | 10× | .bind(if who.is_empty() { by_default } else { &who }) |
| 395 | 10× | .bind(scope_owner) |
| 396 | 10× | .bind(scope_repo_id) |
| 397 | 10× | .fetch_one(&mut *tx) |
| 398 | 10× | .await?; |
| 399 | 10× | sqlx::query("UPDATE flow_runner_registrations SET used_ms = $1, runner_id = $2 WHERE token_hash = $3") |
| 400 | 10× | .bind(now) |
| 401 | 10× | .bind(id) |
| 402 | 10× | .bind(registration) |
| 403 | 10× | .execute(&mut *tx) |
| 404 | 10× | .await?; |
| 405 | 10× | tx.commit().await?; |
| 406 | 10× | get(pool, id).await |
| 407 | 11× | } |
| 408 | |
|
| 409 | |
|
| 410 | | #[derive(Clone, Debug, FromRow)] |
| 411 | | pub struct RunnerJob { |
| 412 | | pub owner: String, |
| 413 | | pub repo: String, |
| 414 | | pub run_number: i64, |
| 415 | | pub job: String, |
| 416 | | pub status: String, |
| 417 | | pub started_ms: Option<i64>, |
| 418 | | pub finished_ms: Option<i64>, |
| 419 | | pub receipt_attest: String, |
| 420 | | } |
| 421 | |
|
| 422 | |
|
| 423 | 4× | pub async fn history(pool: &Pool, id: i64, limit: i64, before: Option<i64>) -> sqlx::Result<Vec<RunnerJob>> { |
| 424 | 4× | sqlx::query_as( |
| 425 | 4× | "SELECT p.owner AS owner, p.name AS repo, r.number AS run_number, j.name AS job, j.status AS status, j.started_ms AS started_ms, \ |
| 426 | 4× | j.finished_ms AS finished_ms, j.receipt_attest AS receipt_attest \ |
| 427 | 4× | FROM flow_jobs j JOIN flow_runs r ON r.id = j.run_id JOIN repositories p ON p.id = r.repo_id \ |
| 428 | 4× | WHERE j.runner_id = $1 AND ($2 IS NULL OR j.started_ms < $3) ORDER BY j.started_ms DESC LIMIT $4", |
| 429 | 4× | ) |
| 430 | 4× | .bind(id) |
| 431 | 4× | .bind(before) |
| 432 | 4× | .bind(before) |
| 433 | 4× | .bind(limit) |
| 434 | 4× | .fetch_all(pool) |
| 435 | 4× | .await |
| 436 | 4× | } |
| 437 | |
|
| 438 | |
|
| 439 | 3× | pub async fn totals(pool: &Pool, id: i64) -> sqlx::Result<(i64, i64, i64)> { |
| 440 | 3× | sqlx::query_as( |
| 441 | 3× | "SELECT COUNT(*), COALESCE(SUM(CASE WHEN status = 'passed' THEN 1 ELSE 0 END), 0), CAST(COALESCE(SUM(finished_ms - started_ms), 0) AS BIGINT) \ |
| 442 | 3× | FROM flow_jobs WHERE runner_id = $1 AND finished_ms IS NOT NULL", |
| 443 | 3× | ) |
| 444 | 3× | .bind(id) |
| 445 | 3× | .fetch_one(pool) |
| 446 | 3× | .await |
| 447 | 3× | } |
| 448 | |
|
| 449 | |
|
| 450 | 245× | pub async fn running(pool: &Pool) -> sqlx::Result<Vec<(i64, i64)>> { |
| 451 | 245× | sqlx::query_as("SELECT runner_id, COUNT(*) FROM flow_jobs WHERE status = 'running' AND runner_id IS NOT NULL GROUP BY runner_id") |
| 452 | 245× | .fetch_all(pool) |
| 453 | 245× | .await |
| 454 | 245× | } |
| 455 | |
|
| 456 | 155× | pub async fn set_job_runner(pool: &Pool, job_id: i64, runner_id: i64) -> sqlx::Result<()> { |
| 457 | 155× | sqlx::query("UPDATE flow_jobs SET runner_id = $1 WHERE id = $2").bind(runner_id).bind(job_id).execute(pool).await?; |
| 458 | 155× | Ok(()) |
| 459 | 155× | } |