fix(go): batch durable spool replay
This commit is contained in:
@@ -118,6 +118,26 @@ func TestDurableSinkReplayLoopTickUsesUncancelledContext(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDurableSinkReplayLoopTickRespectsBatchSize(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
env := durableTestEnvelope()
|
||||
for index := 0; index < 5; index++ {
|
||||
writeDurableRecord(t, filepath.Join(dir, "000"+string(rune('1'+index))+"-raw.json"), durableRecord{Kind: "raw", Envelope: env})
|
||||
}
|
||||
delegate := &contextCheckingReplaySink{}
|
||||
sink := NewDurableSink(delegate, DurableConfig{Directory: dir, ReplayBatchSize: 2})
|
||||
|
||||
if err := sink.replayOnceFromLoop(context.Background()); err != nil {
|
||||
t.Fatalf("replayOnceFromLoop() error = %v", err)
|
||||
}
|
||||
if delegate.rawCalls != 2 {
|
||||
t.Fatalf("raw calls = %d, want 2", delegate.rawCalls)
|
||||
}
|
||||
if files := spoolFiles(t, dir); len(files) != 3 {
|
||||
t.Fatalf("spool files after replay = %d, want 3: %#v", len(files), files)
|
||||
}
|
||||
}
|
||||
|
||||
func durableTestEnvelope() envelope.FrameEnvelope {
|
||||
return envelope.FrameEnvelope{
|
||||
Protocol: envelope.ProtocolJT808,
|
||||
|
||||
Reference in New Issue
Block a user