-
Notifications
You must be signed in to change notification settings - Fork 16
feat(ensrainbow): implement background database bootstrapping and new readiness endpoint #1968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8dcebcb
3c23870
5ec830f
243667f
1f9d822
d3f9c0d
74cf754
89ac55f
a438a6a
ac844ce
2b498f9
cac82ed
83a4453
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||
| --- | ||||||
| "ensrainbow": minor | ||||||
| "@ensnode/ensrainbow-sdk": minor | ||||||
| "ensindexer": patch | ||||||
| --- | ||||||
|
|
||||||
| ENSRainbow now starts its HTTP server immediately and downloads/validates its database in the background, instead of blocking container startup behind a netcat placeholder. | ||||||
|
|
||||||
| - **New `GET /ready` endpoint**: returns `200 { status: "ok" }` once the database is attached, or `503 Service Unavailable` while ENSRainbow is still bootstrapping. `/health` is now a pure liveness probe that succeeds as soon as the HTTP server is listening. | ||||||
| - **503 responses for API routes during bootstrap**: `/v1/heal`, `/v1/labels/count`, and `/v1/config` return a structured `ServiceUnavailableError` (`errorCode: 503`) until the database is ready. | ||||||
| - **New Docker entrypoint**: the container now runs `pnpm --filter ensrainbow run entrypoint` (implemented in Node via `tsx src/cli.ts entrypoint`), which replaces `scripts/entrypoint.sh` and the `netcat` workaround. | ||||||
|
||||||
| - **New Docker entrypoint**: the container now runs `pnpm --filter ensrainbow run entrypoint` (implemented in Node via `tsx src/cli.ts entrypoint`), which replaces `scripts/entrypoint.sh` and the `netcat` workaround. | |
| - **New Docker entrypoint**: the container now runs `pnpm run entrypoint` (implemented in Node via `tsx src/cli.ts entrypoint`), which replaces `scripts/entrypoint.sh` and the `netcat` workaround. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ export class PublicConfigBuilder { | |
| * the ENSIndexer Public Config. | ||
| */ | ||
| private ensRainbowClient: EnsRainbow.ApiClient; | ||
| private waitForEnsRainbowReady: () => Promise<void>; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Document the new Neighboring fields ( 📝 Proposed doc addition private ensRainbowClient: EnsRainbow.ApiClient;
+ /**
+ * Readiness hook awaited once before the first ENSRainbow `config()` call.
+ * Defaults to a no-op so tests and other callers can opt out.
+ */
private waitForEnsRainbowReady: () => Promise<void>;
@@
/**
* `@param` ensRainbowClient ENSRainbow Client instance used to fetch ENSRainbow Public Config
+ * `@param` waitForEnsRainbowReady Optional readiness hook awaited before the first
+ * `ensRainbowClient.config()` call on the initial `getPublicConfig()` invocation.
*/
constructor(
ensRainbowClient: EnsRainbow.ApiClient,
waitForEnsRainbowReady: () => Promise<void> = async () => {},
) {As per coding guidelines: "Maintain comment consistency within a file: if most types, schemas, or declarations lack comments, do not add a comment to a single one" — the inverse applies here since the other fields in this class are documented. Also applies to: 31-40 🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * Immutable ENSIndexer Public Config | ||
|
|
@@ -30,8 +31,12 @@ export class PublicConfigBuilder { | |
| /** | ||
| * @param ensRainbowClient ENSRainbow Client instance used to fetch ENSRainbow Public Config | ||
| */ | ||
| constructor(ensRainbowClient: EnsRainbow.ApiClient) { | ||
| constructor( | ||
| ensRainbowClient: EnsRainbow.ApiClient, | ||
| waitForEnsRainbowReady: () => Promise<void> = async () => {}, | ||
| ) { | ||
| this.ensRainbowClient = ensRainbowClient; | ||
| this.waitForEnsRainbowReady = waitForEnsRainbowReady; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -45,6 +50,8 @@ export class PublicConfigBuilder { | |
| */ | ||
| async getPublicConfig(): Promise<EnsIndexerPublicConfig> { | ||
| if (typeof this.immutablePublicConfig === "undefined") { | ||
| await this.waitForEnsRainbowReady(); | ||
|
|
||
| const [versionInfo, ensRainbowPublicConfig] = await Promise.all([ | ||
| this.getEnsIndexerVersionInfo(), | ||
| this.ensRainbowClient.config(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| import { ensRainbowClient } from "@/lib/ensrainbow/singleton"; | ||
| import { ensRainbowClient, waitForEnsRainbowToBeReady } from "@/lib/ensrainbow/singleton"; | ||
| import { PublicConfigBuilder } from "@/lib/public-config-builder/public-config-builder"; | ||
|
|
||
| export const publicConfigBuilder = new PublicConfigBuilder(ensRainbowClient); | ||
| export const publicConfigBuilder = new PublicConfigBuilder( | ||
| ensRainbowClient, | ||
| waitForEnsRainbowToBeReady, | ||
| ); |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changeset says the container runs
pnpm --filter ensrainbow run entrypoint, but the Dockerfile now setsWORKDIR /app/apps/ensrainbowand runspnpm run entrypoint. Consider updating this line to match the actual container invocation (or vice versa) so the migration note is unambiguous.