feat(go): persist realtime snapshots to mysql

This commit is contained in:
lingniu
2026-07-02 16:06:29 +08:00
parent f4335641db
commit dac6718ee4
4 changed files with 265 additions and 7 deletions

View File

@@ -42,6 +42,20 @@ func TestProcessRealtimeMessageUsesUncancelledContextForUpdateAndCommit(t *testi
}
}
func TestCompositeRealtimeUpdaterUpdatesBothStores(t *testing.T) {
env := envelope.FrameEnvelope{Protocol: envelope.ProtocolGB32960, VIN: "VIN001"}
redisUpdater := &contextCheckingRealtimeUpdater{}
snapshotUpdater := &contextCheckingRealtimeUpdater{}
updater := compositeRealtimeUpdater{primary: redisUpdater, secondary: snapshotUpdater}
if err := updater.Update(context.Background(), env); err != nil {
t.Fatalf("Update() error = %v", err)
}
if redisUpdater.count != 1 || snapshotUpdater.count != 1 {
t.Fatalf("updates primary=%d secondary=%d", redisUpdater.count, snapshotUpdater.count)
}
}
type contextCheckingRealtimeUpdater struct {
ctxErr error
count int