feat: 拉通 Workbench 纯 Kafka 实时链路

This commit is contained in:
root
2026-07-10 10:22:28 +02:00
parent d5230cb923
commit 8ad5976a07
59 changed files with 4700 additions and 498 deletions
+57 -3
View File
@@ -5,11 +5,11 @@ import { fileURLToPath } from "node:url";
import {
CLOUD_CORE_MIGRATIONS,
CLOUD_RUNTIME_DURABLE_MIGRATION_ID,
CLOUD_RUNTIME_DURABLE_ADAPTER_SCHEMA_VERSION,
CLOUD_TRANSACTIONAL_REALTIME_MIGRATION_ID as CLOUD_RUNTIME_DURABLE_MIGRATION_ID,
CLOUD_TRANSACTIONAL_REALTIME_SCHEMA_VERSION as CLOUD_RUNTIME_DURABLE_ADAPTER_SCHEMA_VERSION,
CLOUD_RUNTIME_DURABLE_MIGRATION_TABLE,
CLOUD_RUNTIME_DURABLE_MIGRATION_TABLE_COLUMNS,
CLOUD_RUNTIME_DURABLE_TABLE_COLUMNS
CLOUD_TRANSACTIONAL_REALTIME_REQUIRED_TABLE_COLUMNS as CLOUD_RUNTIME_DURABLE_TABLE_COLUMNS
} from "../../internal/db/schema.ts";
import {
PostgresCloudRuntimeStore,
@@ -267,6 +267,10 @@ async function verifyRuntimeReadiness(report, env, options) {
let runtime;
try {
runtime = await runtimeStore.readiness();
if (runtime.gates?.schema?.ready === true && runtime.gates?.migration?.ready === true) {
const transactionalReadiness = await runtimeStore.workbenchTransactionalRealtimeReadiness();
runtime = mergeTransactionalRealtimeReadiness(runtime, transactionalReadiness);
}
} finally {
if (!options.queryClient && typeof runtimeStore.pool?.end === "function") {
await runtimeStore.pool.end();
@@ -290,6 +294,56 @@ async function verifyRuntimeReadiness(report, env, options) {
}
}
function mergeTransactionalRealtimeReadiness(runtime, readiness = {}) {
const schemaReady = readiness.schema?.ready === true;
const migrationReady = readiness.migration?.ready === true;
const transactionalReady = readiness.ready === true && schemaReady && migrationReady;
const ready = runtime.ready === true && transactionalReady;
const blocker = ready
? null
: !schemaReady
? RUNTIME_DURABLE_ADAPTER_SCHEMA_BLOCKED
: !migrationReady
? RUNTIME_DURABLE_ADAPTER_MIGRATION_BLOCKED
: runtime.blocker;
return {
...runtime,
ready,
status: ready ? "ready" : "blocked",
blocker,
reason: ready
? "Postgres transactional Workbench realtime schema and migration are ready"
: !schemaReady
? "Postgres transactional Workbench realtime schema is incomplete"
: !migrationReady
? "Postgres transactional Workbench realtime migration is not recorded"
: runtime.reason,
liveRuntimeEvidence: runtime.liveRuntimeEvidence === true && ready,
connection: {
...runtime.connection,
queryResult: ready
? "transactional_realtime_readiness_ready"
: !schemaReady
? "schema_blocked"
: !migrationReady
? "migration_blocked"
: runtime.connection?.queryResult
},
schema: readiness.schema,
migration: readiness.migration,
gates: {
...runtime.gates,
schema: schemaReady ? readyGate() : blockedGate(RUNTIME_DURABLE_ADAPTER_SCHEMA_BLOCKED),
migration: !schemaReady
? notCheckedGate()
: migrationReady
? readyGate()
: blockedGate(RUNTIME_DURABLE_ADAPTER_MIGRATION_BLOCKED),
durability: transactionalReady ? runtime.gates?.durability ?? notCheckedGate() : notCheckedGate()
}
};
}
async function applyMigration(report, sql, env, options) {
report.actions.liveDbWriteAttempted = true;
let client;