Message loader gated on database ready
Skill kjuhwa/skills-hub/skills/backend/message-loader-gated-on-database-ready
Self-correcting knowledge corpus for Claude Code — 9 stable shape clusters, bias-correction pipeline baked into contribution flow. 47 papers, 45 techniques, 1.1k skills.
npx -y skills add kjuhwa/skills-hub --skill message-loader-gated-on-database-readyAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Gate i18n/seed loading on database readiness + per-tenant distributed lock so the first instance wins initialization in a multi-replica rollout.
SKILL.md
2.0 KB, 364 tokens by cl100k_base, as published. Nobody here has run it
Message/Seed Loader with Readiness Gate + Per-Tenant Lock
Shape
Three layered gates before a loader runs:
- Service dependency gate — wait for upstream services (e.g.,
account) to register in discovery. In Lucida this is@WaitForServices("account"). - Database readiness gate — poll until expected tenant databases exist (
MIN_DATABASE_COUNT). Retry loop: N attempts × delay (e.g., 100 × 10 s). - Per-tenant distributed lock — acquire
meta:init:<tenantId>via the Mongo lock pattern before seeding. Other replicas exit early when they find data already present.
Steps
- Define a startup runner (
ApplicationRunner/ event listener) that calls the loader per tenant. - Before work: check a cheap "already seeded" marker (e.g., collection count > 0). Skip if present.
- Wrap the seed block in the distributed lock; double-check the marker inside the lock (read-after-lock).
- On timeout at any gate, log with the specific stage (
stage=waitDb|stage=acquireLock|stage=seed) so operators know whether to extend the timeout or investigate. - Emit a Kafka "loaded" event (e.g.,
MessageLoadedTopicAvro) so downstream services can flip from fallback to real data.
Counter / Caveats
- Don't gate on upstream service health alone — the account service being
UPdoes not mean its Kafka org-created events have been consumed locally. - Retry count × delay should exceed the slowest legitimate cold start (cold MongoDB + first-pod schema init).
- Do not use this pattern for fast-changing config; it is for one-shot bootstrap only.
What ships with it: 1 file
690 B alongside SKILL.md
- content.md690 B