Coverage / crates/flow-core/src/api.rs 100.0%
48 of 48 lines run, 7 of 14 functions · run #185 on main · run missed
| 1 | //! The runner API between OxygenHub and `flow runner` (docs/m0.md §5). | |
| 2 | //! Both sides use these types, so they cannot drift. | |
| 3 | | |
| 4 | use crate; | |
| 5 | use crateReceipt; | |
| 6 | use ; | |
| 7 | ||
| 8 | /// `POST /api/v1/flow/claim`. | |
| 9 | | |
| 10 | | |
| 11 | | |
| 12 | | |
| 13 | | |
| 14 | | |
| 15 | | |
| 16 | | |
| 17 | | |
| 18 | | |
| 19 | | |
| 20 | | |
| 21 | | |
| 22 | | |
| 23 | | |
| 24 | | |
| 25 | | |
| 26 | | |
| 27 | | |
| 28 | | |
| 29 | | |
| 30 | | |
| 31 | | |
| 32 | | |
| 33 | | |
| 34 | | |
| 35 | | |
| 36 | | |
| 37 | | |
| 38 | | |
| 39 | | |
| 40 | | |
| 41 | | |
| 42 | | |
| 43 | | |
| 44 | | |
| 45 | | |
| 46 | | |
| 47 | | |
| 48 | | |
| 49 | | |
| 50 | | |
| 51 | | |
| 52 | | |
| 53 | | |
| 54 | | |
| 55 | | |
| 56 | | |
| 57 | | |
| 58 | | |
| 59 | | |
| 60 | | |
| 61 | | |
| 62 | | |
| 63 | | |
| 64 | | |
| 65 | | |
| 66 | ||
| 67 | /// A name safe as one path segment: kept readable, with a short hash so | |
| 68 | /// two names that clean up alike stay apart. The build cache's pool is laid | |
| 69 | /// out by these (oxygenflow#28). | |
| 70 | 186× | |
| 71 | 987× | |
| 72 | 186× | |
| 73 | 186× | |
| 74 | ||
| 75 | /// Where a repository's job keeps its build caches, as runners report | |
| 76 | /// them in [`ClaimRequest::caches`] (oxygenflow#51): `repo/job`, each part | |
| 77 | /// a [`segment`]. | |
| 78 | 3× | |
| 79 | 3× | |
| 80 | 3× | |
| 81 | ||
| 82 | /// A runner's place in the image swarm: the address peers reach it on, | |
| 83 | /// the site it is in (peers are only ever in the same site), and the | |
| 84 | /// BLAKE3 of its TLS certificate, which peers check it by. | |
| 85 | | |
| 86 | | |
| 87 | | |
| 88 | | |
| 89 | | |
| 90 | | |
| 91 | | |
| 92 | | |
| 93 | ||
| 94 | /// `POST /flow/swarm/announce`: a runner starting, continuing or ending a | |
| 95 | /// fetch of `image`. | |
| 96 | | |
| 97 | | |
| 98 | | |
| 99 | | |
| 100 | | |
| 101 | | |
| 102 | ||
| 103 | /// The hub's answer to an announce: the peers to ask, and the ticket that | |
| 104 | /// admits this runner to them. | |
| 105 | | |
| 106 | | |
| 107 | | |
| 108 | | |
| 109 | | |
| 110 | | |
| 111 | | |
| 112 | ||
| 113 | /// A peer in the swarm for one image. | |
| 114 | | |
| 115 | | |
| 116 | | |
| 117 | | |
| 118 | | |
| 119 | | |
| 120 | | |
| 121 | | |
| 122 | | |
| 123 | | |
| 124 | | |
| 125 | ||
| 126 | /// A runner's own measurements, sent with every claim (spec §11.1): cheap | |
| 127 | /// ones taken each time, the speed from a short benchmark run at start and | |
| 128 | /// again while idle. Whole numbers, so a claim compares exactly. | |
| 129 | | |
| 130 | | |
| 131 | | |
| 132 | | |
| 133 | | |
| 134 | | |
| 135 | | |
| 136 | | |
| 137 | | |
| 138 | | |
| 139 | | |
| 140 | | |
| 141 | | |
| 142 | | |
| 143 | | |
| 144 | | |
| 145 | | |
| 146 | | |
| 147 | | |
| 148 | | |
| 149 | ||
| 150 | | |
| 151 | | |
| 152 | | |
| 153 | 5× | |
| 154 | 5× | |
| 155 | 5× | |
| 156 | 4× | |
| 157 | 3× | |
| 158 | 2× | |
| 159 | 1× | |
| 160 | | |
| 161 | 5× | |
| 162 | | |
| 163 | ||
| 164 | /// A runner's description: shown on the hub's Runners page, and what | |
| 165 | /// scheduling by label and architecture will match. | |
| 166 | | |
| 167 | | |
| 168 | | |
| 169 | | |
| 170 | | |
| 171 | | |
| 172 | | |
| 173 | | |
| 174 | | |
| 175 | | |
| 176 | | |
| 177 | | |
| 178 | | |
| 179 | | |
| 180 | | |
| 181 | | |
| 182 | | |
| 183 | ||
| 184 | | |
| 185 | | |
| 186 | 1× | |
| 187 | 1× | |
| 188 | 1× | |
| 189 | 1× | |
| 190 | 1× | |
| 191 | 1× | |
| 192 | 1× | |
| 193 | 1× | |
| 194 | 1× | |
| 195 | 1× | |
| 196 | 1× | |
| 197 | | |
| 198 | ||
| 199 | /// `POST /api/v1/flow/runners/register`: exchange a one-time registration | |
| 200 | /// token from the hub for a runner credential, binding the runner's | |
| 201 | /// signing identity to it. | |
| 202 | | |
| 203 | | |
| 204 | | |
| 205 | | |
| 206 | | |
| 207 | | |
| 208 | | |
| 209 | | |
| 210 | | |
| 211 | ||
| 212 | | |
| 213 | | |
| 214 | | |
| 215 | | |
| 216 | | |
| 217 | | |
| 218 | | |
| 219 | ||
| 220 | /// A pinned subrepo to put in the workspace: `repo`'s state `heads`, at `path`. | |
| 221 | | |
| 222 | | |
| 223 | | |
| 224 | | |
| 225 | | |
| 226 | | |
| 227 | | |
| 228 | | |
| 229 | ||
| 230 | /// A secret for a job, as the hub supplies it (spec §9): written by the | |
| 231 | /// runner at `path` in the sandbox, 0400, on an in-memory mount; never in | |
| 232 | /// the environment, the receipt or an artifact. | |
| 233 | | |
| 234 | | |
| 235 | | |
| 236 | | |
| 237 | | |
| 238 | | |
| 239 | ||
| 240 | /// A claimed job: everything the runner needs, nothing more. | |
| 241 | | |
| 242 | | |
| 243 | | |
| 244 | | |
| 245 | | |
| 246 | | |
| 247 | | |
| 248 | | |
| 249 | | |
| 250 | | |
| 251 | | |
| 252 | | |
| 253 | | |
| 254 | | |
| 255 | | |
| 256 | | |
| 257 | | |
| 258 | | |
| 259 | | |
| 260 | | |
| 261 | | |
| 262 | | |
| 263 | | |
| 264 | | |
| 265 | | |
| 266 | | |
| 267 | | |
| 268 | | |
| 269 | | |
| 270 | | |
| 271 | | |
| 272 | | |
| 273 | | |
| 274 | | |
| 275 | | |
| 276 | | |
| 277 | | |
| 278 | | |
| 279 | | |
| 280 | | |
| 281 | | |
| 282 | | |
| 283 | | |
| 284 | | |
| 285 | | |
| 286 | | |
| 287 | | |
| 288 | | |
| 289 | | |
| 290 | | |
| 291 | | |
| 292 | | |
| 293 | | |
| 294 | | |
| 295 | | |
| 296 | | |
| 297 | | |
| 298 | | |
| 299 | | |
| 300 | ||
| 301 | /// An artifact a job takes (oxygenflow#58), as the hub hands it over. | |
| 302 | | |
| 303 | | |
| 304 | | |
| 305 | | |
| 306 | | |
| 307 | | |
| 308 | | |
| 309 | | |
| 310 | | |
| 311 | | |
| 312 | ||
| 313 | | |
| 314 | | |
| 315 | | |
| 316 | | |
| 317 | | |
| 318 | 2× | |
| 319 | 2× | |
| 320 | 2× | |
| 321 | 2× | |
| 322 | 2× | |
| 323 | | |
| 324 | 2× | |
| 325 | 1× | |
| 326 | 1× | |
| 327 | 2× | |
| 328 | 1× | |
| 329 | 1× | |
| 330 | 2× | |
| 331 | 1× | |
| 332 | 1× | |
| 333 | 2× | |
| 334 | 7× | |
| 335 | 1× | |
| 336 | 1× | |
| 337 | | |
| 338 | 2× | |
| 339 | 2× | |
| 340 | | |
| 341 | ||
| 342 | /// One line of output (docs/m0.md §2). | |
| 343 | | |
| 344 | | |
| 345 | | |
| 346 | | |
| 347 | | |
| 348 | | |
| 349 | | |
| 350 | | |
| 351 | ||
| 352 | /// `POST /api/v1/flow/jobs/{id}/decline` (spec §11.5): the runner will | |
| 353 | /// not run a job it was handed, and says why. The hub queues the job | |
| 354 | /// again and offers it to this runner no more until its profile changes. | |
| 355 | | |
| 356 | | |
| 357 | | |
| 358 | | |
| 359 | ||
| 360 | /// `GET /api/v1/flow/runner/update` (docs/jetstream.md §8.2, oxygenhub#322): | |
| 361 | /// the update policy that applies to the asking runner, and the build it | |
| 362 | /// should run when that is not the one it runs. | |
| 363 | | |
| 364 | | |
| 365 | | |
| 366 | | |
| 367 | | |
| 368 | | |
| 369 | | |
| 370 | | |
| 371 | | |
| 372 | | |
| 373 | | |
| 374 | ||
| 375 | /// A runner's update policy once every level is applied (nearest wins). | |
| 376 | | |
| 377 | | |
| 378 | | |
| 379 | | |
| 380 | | |
| 381 | | |
| 382 | | |
| 383 | | |
| 384 | | |
| 385 | | |
| 386 | | |
| 387 | | |
| 388 | | |
| 389 | | |
| 390 | | |
| 391 | | |
| 392 | | |
| 393 | ||
| 394 | /// A build to install: a release asset of the site's runner releases. | |
| 395 | | |
| 396 | | |
| 397 | | |
| 398 | | |
| 399 | | |
| 400 | | |
| 401 | | |
| 402 | | |
| 403 | | |
| 404 | | |
| 405 | | |
| 406 | | |
| 407 | | |
| 408 | | |
| 409 | | |
| 410 | ||
| 411 | /// `POST /api/v1/flow/runner/update`: what the runner did about its update, | |
| 412 | /// shown on its page. | |
| 413 | | |
| 414 | | |
| 415 | | |
| 416 | | |
| 417 | ||
| 418 | /// `POST /api/v1/flow/jobs/{id}/log`. | |
| 419 | | |
| 420 | | |
| 421 | | |
| 422 | | |
| 423 | ||
| 424 | /// `POST /api/v1/flow/jobs/{id}/finish`. | |
| 425 | | |
| 426 | | |
| 427 | | |
| 428 | | |
| 429 | | |
| 430 | | |
| 431 | | |
| 432 | | |
| 433 | | |
| 434 | | |
| 435 | | |
| 436 | | |
| 437 | | |
| 438 | | |
| 439 | | |
| 440 | | |
| 441 | | |
| 442 | | |
| 443 | | |
| 444 | | |
| 445 | ||
| 446 | /// Longest text of one record the hub keeps; longer lines are cut. | |
| 447 | pub const MAX_RECORD_TEXT: usize = 16 * 1024; | |
| 448 | /// Most records the hub keeps per job; later ones are dropped with a note. | |
| 449 | pub const MAX_RECORDS: usize = 50_000; |