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>
19 lines
687 B
JavaScript
19 lines
687 B
JavaScript
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');
|
|
}
|
|
}
|