|
9 | 9 | * page the list endpoints, optionally n pages at a time |
10 | 10 | * workos-sync-mysql listen tail the Events API |
11 | 11 | * workos-sync-mysql tick one poll, then exit (for cron) |
12 | | - * workos-sync-mysql reconcile [--repair] detect (and optionally fix) drift |
| 12 | + * workos-sync-mysql reconcile [--repair] [--exclude-streams <a,b>] detect (and optionally fix) drift |
13 | 13 | * workos-sync-mysql refresh re-list to refresh partial event fields |
14 | 14 | * workos-sync-mysql status cursor age and per-stream freshness |
15 | 15 | * workos-sync-mysql redact --user <id> erase one subject |
@@ -244,6 +244,27 @@ export function parseMaxPages(value: string | boolean | undefined): number | und |
244 | 244 | return n |
245 | 245 | } |
246 | 246 |
|
| 247 | +/** |
| 248 | + * `--exclude-streams <a,b>` names streams `reconcile` leaves out, for one |
| 249 | + * whose listing has to run somewhere without a time limit. A bare flag is |
| 250 | + * refused here: excluding nothing by accident is the mistake the flag exists |
| 251 | + * to prevent. The names themselves are checked by the engine. |
| 252 | + */ |
| 253 | +export function parseExcludeStreams(value: string | boolean | undefined): string[] | undefined { |
| 254 | + if (value === undefined || value === false) return undefined |
| 255 | + const names = |
| 256 | + typeof value === 'string' |
| 257 | + ? value |
| 258 | + .split(',') |
| 259 | + .map((s) => s.trim()) |
| 260 | + .filter(Boolean) |
| 261 | + : [] |
| 262 | + if (names.length === 0) { |
| 263 | + throw new Error(`invalid --exclude-streams "${String(value)}": expected a comma-separated list of stream names`) |
| 264 | + } |
| 265 | + return names |
| 266 | +} |
| 267 | + |
247 | 268 | function configFromEnv( |
248 | 269 | flags: Record<string, string | boolean>, |
249 | 270 | destination: MysqlDestination, |
@@ -289,12 +310,16 @@ Commands |
289 | 310 | with a port, serve GET /healthz and /metrics on it |
290 | 311 | tick One poll of the Events API, then exit (for a cron job); |
291 | 312 | exits 3 if a listener holds the lease |
292 | | - reconcile [--repair] [--resume] [--max-pages <n>] |
| 313 | + reconcile [--repair] [--resume] [--max-pages <n>] [--exclude-streams <a,b>] |
293 | 314 | Compare the mirror against the API; --repair fixes drift. |
294 | 315 | --max-pages stops starting streams once n pages have been |
295 | 316 | fetched (a stream that starts runs to its last page, since |
296 | | - a diff needs the whole listing); run again with --resume |
297 | | - until every stream reports complete |
| 317 | + a diff needs the whole listing, unless it alone needs more |
| 318 | + than n: it is then abandoned and reported oversized until |
| 319 | + a run with a larger budget or none); run again with |
| 320 | + --resume until every stream reports complete. |
| 321 | + --exclude-streams leaves streams out, for one that has to |
| 322 | + run somewhere without a time limit |
298 | 323 | refresh [--resume] [--max-pages <n>] |
299 | 324 | Re-list top-level streams, replacing each row; |
300 | 325 | --max-pages and --resume slice it like backfill, with |
@@ -459,6 +484,7 @@ async function runCommand(command: string, flags: Record<string, string | boolea |
459 | 484 | repair: Boolean(flags['repair']), |
460 | 485 | resume: Boolean(flags['resume']), |
461 | 486 | maxPages: parseMaxPages(flags['max-pages']), |
| 487 | + excludeStreams: parseExcludeStreams(flags['exclude-streams']), |
462 | 488 | }) |
463 | 489 | process.stdout.write(JSON.stringify(r, null, 2) + '\n') |
464 | 490 | // A non-zero exit makes this usable as a scheduled check. |
|
0 commit comments