Address the non-red-team documentation/cleanup items from review #1679: - Document the GIT_SYNC_BACKEND_TIMEOUT_MS watchdog (git http-backend) in .env.example and add it to the environment validation schema — it was used (getGitSyncBackendTimeoutMs, default 120000) but undocumented/unvalidated. - Remove the dead GIT_SYNC_DEBOUNCE_MS_DEFAULT / GIT_SYNC_POLL_INTERVAL_MS_DEFAULT exports (never imported; environment.service is the single source of defaults). - Redirect the dangling `plan §X.Y` comment references to issue #194 (the git-sync spec moved there when docs/git-sync-plan.md was deleted by this PR). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
/**
|
|
* Git-sync control-plane constants.
|
|
*
|
|
* Event/job names are REUSED from the shared event contract (event.contants.ts)
|
|
* so the listener subscribes to the exact names the rest of the server emits —
|
|
* never a string literal that could drift. The Redis lock-key prefix + TTLs back
|
|
* the single-writer leader lock (§9); the debounce default backs the per-space
|
|
* event coalescing (§10).
|
|
*/
|
|
import { EventName } from '../../common/events/event.contants';
|
|
|
|
/**
|
|
* The page lifecycle events the git-sync listener reacts to. A change
|
|
* to any of these in an enabled space schedules a debounced sync cycle.
|
|
* - PAGE_CREATED / PAGE_UPDATED / PAGE_MOVED — structural + content edits;
|
|
* - PAGE_SOFT_DELETED / PAGE_RESTORED — Trash transitions (deletes are soft);
|
|
* - PAGE_MOVED_TO_SPACE — cross-space move (cross-repo).
|
|
*
|
|
* NOTE: body edits arrive via PAGE_UPDATED (emitted from persistence.extension),
|
|
* NOT via EventName.PAGE_CONTENT_UPDATED — that name is a BullMQ queue-job name,
|
|
* not an EventEmitter2 event, so @OnEvent would never fire for it.
|
|
*/
|
|
export const GIT_SYNC_PAGE_EVENTS = [
|
|
EventName.PAGE_CREATED,
|
|
EventName.PAGE_UPDATED,
|
|
EventName.PAGE_MOVED,
|
|
EventName.PAGE_MOVED_TO_SPACE,
|
|
EventName.PAGE_SOFT_DELETED,
|
|
EventName.PAGE_RESTORED,
|
|
] as const;
|
|
|
|
/** Redis key prefix for the per-space leader lock. */
|
|
export const GIT_SYNC_LOCK_PREFIX = 'git-sync:lock:';
|
|
|
|
/**
|
|
* Leader-lock TTL (ms). Must exceed the maximum expected cycle duration so the
|
|
* lock is not lost mid-cycle; on a crash it expires on its own. The
|
|
* in-process mutex (orchestrator) prevents overlapping cycles on one instance,
|
|
* and the Redis lock prevents two instances racing the same space.
|
|
*/
|
|
export const GIT_SYNC_LOCK_TTL_MS = 5 * 60 * 1000;
|