feat(jobs): repo-level embed triggers (pages/refs/source_docs)
create/update on embeddable repos enqueue embed.text with a singleton key that coalesces rapid edits. No-op when the queue is not running (server tests construct createApp without booting pg-boss). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
18
lib/jobs/triggers.js
Normal file
18
lib/jobs/triggers.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import * as queue from './queue.js';
|
||||
import { log } from '../log.js';
|
||||
|
||||
// Fire-and-forget enqueue of an embed.text job after a repo write.
|
||||
// Never blocks the write: if the queue is not running (server tests),
|
||||
// or pg-boss errors transiently, we log + move on. Pending rows get
|
||||
// picked up by a future re-embed cron in Plan 4+.
|
||||
export async function triggerEmbed(entity_type, entity_id) {
|
||||
if (!queue.instance()) return; // not started — no-op
|
||||
try {
|
||||
await queue.enqueue('embed.text',
|
||||
{ entity_type, entity_id },
|
||||
{ singletonKey: `${entity_type}:${entity_id}` }
|
||||
);
|
||||
} catch (e) {
|
||||
log.warn({ err: e, entity_type, entity_id }, 'triggerEmbed failed');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user