Compare commits

..

No commits in common. "a97e0b51b8a12ed3bda058219595009357c5358a" and "964b06b37069c7e72d903da47678575e5df1788f" have entirely different histories.

10 changed files with 25 additions and 160 deletions

View File

@ -1,14 +0,0 @@
-- CreateTable: Debezium Heartbeat
-- 用于 CDC replication slot 的 WAL 位置推进
-- 由 Debezium heartbeat.action.query 自动更新
-- 防止因业务表长期无写入导致 WAL 堆积
CREATE TABLE "debezium_heartbeat" (
"id" INTEGER NOT NULL DEFAULT 1,
"ts" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "debezium_heartbeat_pkey" PRIMARY KEY ("id")
);
-- 插入初始记录
INSERT INTO "debezium_heartbeat" ("id", "ts") VALUES (1, NOW());

View File

@ -377,16 +377,3 @@ model ContractSigningTask {
@@index([status, expiresAt])
@@map("contract_signing_tasks")
}
// ============================================
// Debezium 心跳表
// 用于 CDC replication slot 的 WAL 位置推进
// 由 Debezium heartbeat.action.query 自动更新
// 防止因业务表长期无写入导致 WAL 堆积
// ============================================
model DebeziumHeartbeat {
id Int @id @default(1)
ts DateTime @default(now()) @updatedAt @map("ts")
@@map("debezium_heartbeat")
}

View File

@ -1,14 +0,0 @@
-- CreateTable: Debezium Heartbeat
-- 用于 CDC replication slot 的 WAL 位置推进
-- 由 Debezium heartbeat.action.query 自动更新
-- 防止因业务表长期无写入导致 WAL 堆积
CREATE TABLE "debezium_heartbeat" (
"id" INTEGER NOT NULL DEFAULT 1,
"ts" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "debezium_heartbeat_pkey" PRIMARY KEY ("id")
);
-- 插入初始记录
INSERT INTO "debezium_heartbeat" ("id", "ts") VALUES (1, NOW());

View File

@ -199,16 +199,3 @@ model ReferralEvent {
@@index([userId], name: "idx_event_user")
@@index([occurredAt], name: "idx_event_occurred")
}
// ============================================
// Debezium 心跳表
// 用于 CDC replication slot 的 WAL 位置推进
// 由 Debezium heartbeat.action.query 自动更新
// 防止因业务表长期无写入导致 WAL 堆积
// ============================================
model DebeziumHeartbeat {
id Int @id @default(1)
ts DateTime @default(now()) @updatedAt @map("ts")
@@map("debezium_heartbeat")
}

View File

@ -2,40 +2,26 @@
"name": "planting-postgres-connector",
"config": {
"connector.class": "io.debezium.connector.postgresql.PostgresConnector",
"tasks.max": "1",
"database.hostname": "postgres",
"database.port": "5432",
"database.user": "${POSTGRES_USER:-rwa_user}",
"database.password": "${POSTGRES_PASSWORD:-rwa_secure_password}",
"database.user": "debezium",
"database.password": "debezium_password",
"database.dbname": "rwa_planting",
"database.server.name": "planting",
"topic.prefix": "cdc.planting",
"table.include.list": "public.planting_orders,public.planting_positions,public.contract_signing_tasks,public.fund_allocations,public.debezium_heartbeat",
"plugin.name": "pgoutput",
"publication.name": "debezium_planting_publication",
"publication.autocreate.mode": "filtered",
"slot.name": "debezium_planting_slot",
"publication.name": "planting_cdc_publication",
"slot.name": "planting_cdc_slot",
"table.include.list": "public.planting_orders,public.planting_positions,public.contract_signing_tasks,public.fund_allocations",
"transforms": "unwrap",
"transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
"transforms.unwrap.add.fields": "op,table,source.ts_ms",
"transforms.unwrap.delete.handling.mode": "rewrite",
"key.converter": "org.apache.kafka.connect.json.JsonConverter",
"key.converter.schemas.enable": "false",
"value.converter": "org.apache.kafka.connect.json.JsonConverter",
"value.converter.schemas.enable": "false",
"transforms": "unwrap",
"transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
"transforms.unwrap.drop.tombstones": "true",
"transforms.unwrap.delete.handling.mode": "rewrite",
"transforms.unwrap.add.fields": "op,table,source.ts_ms",
"heartbeat.interval.ms": "60000",
"heartbeat.action.query": "UPDATE debezium_heartbeat SET ts = NOW() WHERE id = 1",
"snapshot.mode": "initial",
"decimal.handling.mode": "string",
"time.precision.mode": "connect"
}

View File

@ -12,7 +12,7 @@
"topic.prefix": "cdc.referral",
"table.include.list": "public.referral_relationships,public.debezium_heartbeat",
"table.include.list": "public.referral_relationships",
"plugin.name": "pgoutput",
"publication.name": "debezium_referral_publication",
@ -31,8 +31,7 @@
"transforms.unwrap.delete.handling.mode": "rewrite",
"transforms.unwrap.add.fields": "op,table,source.ts_ms",
"heartbeat.interval.ms": "60000",
"heartbeat.action.query": "UPDATE debezium_heartbeat SET ts = NOW() WHERE id = 1",
"heartbeat.interval.ms": "10000",
"snapshot.mode": "initial",

View File

@ -2,40 +2,26 @@
"name": "wallet-postgres-connector",
"config": {
"connector.class": "io.debezium.connector.postgresql.PostgresConnector",
"tasks.max": "1",
"database.hostname": "postgres",
"database.port": "5432",
"database.user": "${POSTGRES_USER:-rwa_user}",
"database.password": "${POSTGRES_PASSWORD:-rwa_secure_password}",
"database.user": "debezium",
"database.password": "debezium_password",
"database.dbname": "rwa_wallet",
"database.server.name": "wallet",
"topic.prefix": "cdc.wallet",
"table.include.list": "public.wallet_accounts,public.withdrawal_orders,public.fiat_withdrawal_orders,public.wallet_ledger_entries,public.debezium_heartbeat",
"plugin.name": "pgoutput",
"publication.name": "debezium_wallet_publication",
"publication.autocreate.mode": "filtered",
"slot.name": "debezium_wallet_slot",
"publication.name": "wallet_cdc_publication",
"slot.name": "wallet_cdc_slot",
"table.include.list": "public.wallet_accounts,public.withdrawal_orders,public.fiat_withdrawal_orders,public.wallet_ledger_entries",
"transforms": "unwrap",
"transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
"transforms.unwrap.add.fields": "op,table,source.ts_ms",
"transforms.unwrap.delete.handling.mode": "rewrite",
"key.converter": "org.apache.kafka.connect.json.JsonConverter",
"key.converter.schemas.enable": "false",
"value.converter": "org.apache.kafka.connect.json.JsonConverter",
"value.converter.schemas.enable": "false",
"transforms": "unwrap",
"transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
"transforms.unwrap.drop.tombstones": "true",
"transforms.unwrap.delete.handling.mode": "rewrite",
"transforms.unwrap.add.fields": "op,table,source.ts_ms",
"heartbeat.interval.ms": "60000",
"heartbeat.action.query": "UPDATE debezium_heartbeat SET ts = NOW() WHERE id = 1",
"snapshot.mode": "initial",
"decimal.handling.mode": "string",
"time.precision.mode": "connect"
}

View File

@ -1,14 +0,0 @@
-- CreateTable: Debezium Heartbeat
-- 用于 CDC replication slot 的 WAL 位置推进
-- 由 Debezium heartbeat.action.query 自动更新
-- 防止因业务表长期无写入导致 WAL 堆积
CREATE TABLE "debezium_heartbeat" (
"id" INTEGER NOT NULL DEFAULT 1,
"ts" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "debezium_heartbeat_pkey" PRIMARY KEY ("id")
);
-- 插入初始记录
INSERT INTO "debezium_heartbeat" ("id", "ts") VALUES (1, NOW());

View File

@ -498,16 +498,3 @@ model OutboxEvent {
@@index([topic])
@@map("outbox_events")
}
// ============================================
// Debezium 心跳表
// 用于 CDC replication slot 的 WAL 位置推进
// 由 Debezium heartbeat.action.query 自动更新
// 防止因业务表长期无写入导致 WAL 堆积
// ============================================
model DebeziumHeartbeat {
id Int @id @default(1)
ts DateTime @default(now()) @updatedAt @map("ts")
@@map("debezium_heartbeat")
}

View File

@ -83,38 +83,13 @@ class _KlineChartWidgetState extends State<KlineChartWidget> {
_candleWidth = idealWidth.clamp(_minCandleWidth, _maxCandleWidth);
_prevCandleWidth = _candleWidth;
// K 线
_scrollToCenter();
//
_scrollToEnd();
}
/// 使 K 线
///
///
/// - K 线
/// - K 线
void _scrollToCenter() {
if (widget.klines.isEmpty || _chartWidth == 0) return;
final totalWidth = widget.klines.length * _candleWidth;
if (totalWidth <= _chartWidth) {
// K 线
_scrollX = 0;
} else {
// K 线
// K 线 = (K线数量 - 0.5) * K线宽度
final lastKlineCenter = (widget.klines.length - 0.5) * _candleWidth;
// = K线中心 -
final targetScroll = lastKlineCenter - _chartWidth / 2;
//
final maxScroll = totalWidth - _chartWidth;
_scrollX = targetScroll.clamp(0.0, maxScroll);
}
}
///
void _scrollToEnd() {
if (widget.klines.isEmpty || _chartWidth == 0) return;
//
final totalWidth = widget.klines.length * _candleWidth;
final maxScroll = math.max(0.0, totalWidth - _chartWidth);
_scrollX = maxScroll;