| 29 | } |
| 30 | |
| 31 | export async function readNextPluginScan( |
| 32 | vtSeconds: number, |
| 33 | ): Promise<PluginScanQueueRow | null> { |
| 34 | const supabase = await createAdminClient(); |
| 35 | const { data, error } = await supabase |
| 36 | // biome-ignore lint/suspicious/noExplicitAny: pgmq_public is not in the generated types |
| 37 | .schema("pgmq_public" as any) |
| 38 | .rpc("read", { |
| 39 | queue_name: PLUGIN_SCAN_QUEUE, |
| 40 | sleep_seconds: vtSeconds, |
| 41 | n: 1, |
| 42 | }); |
| 43 | |
| 44 | if (error) { |
| 45 | throw new Error(`pgmq_public.read failed: ${error.message}`); |
| 46 | } |
| 47 | |
| 48 | const rows = (data ?? []) as PluginScanQueueRow[]; |
| 49 | return rows[0] ?? null; |
| 50 | } |
| 51 | |
| 52 | export async function archivePluginScan(messageId: number): Promise<void> { |
| 53 | const supabase = await createAdminClient(); |