MCPcopy
hub / github.com/benbjohnson/litestream / createTestLTXFileWithTimestamp

Function createTestLTXFileWithTimestamp

compactor_test.go:603–636  ·  view source on GitHub ↗

createTestLTXFileWithTimestamp creates a minimal LTX file with a specific timestamp.

(t testing.TB, client litestream.ReplicaClient, level int, minTXID, maxTXID ltx.TXID, ts time.Time)

Source from the content-addressed store, hash-verified

601
602// createTestLTXFileWithTimestamp creates a minimal LTX file with a specific timestamp.
603func createTestLTXFileWithTimestamp(t testing.TB, client litestream.ReplicaClient, level int, minTXID, maxTXID ltx.TXID, ts time.Time) {
604 t.Helper()
605
606 var buf bytes.Buffer
607 enc, err := ltx.NewEncoder(&buf)
608 if err != nil {
609 t.Fatal(err)
610 }
611
612 if err := enc.EncodeHeader(ltx.Header{
613 Version: ltx.Version,
614 Flags: ltx.HeaderFlagNoChecksum,
615 PageSize: 4096,
616 Commit: 1,
617 MinTXID: minTXID,
618 MaxTXID: maxTXID,
619 Timestamp: ts.UnixMilli(),
620 }); err != nil {
621 t.Fatal(err)
622 }
623
624 // Write a dummy page
625 if err := enc.EncodePage(ltx.PageHeader{Pgno: 1}, make([]byte, 4096)); err != nil {
626 t.Fatal(err)
627 }
628
629 if err := enc.Close(); err != nil {
630 t.Fatal(err)
631 }
632
633 if _, err := client.WriteLTXFile(context.Background(), level, minTXID, maxTXID, io.NopCloser(&buf)); err != nil {
634 t.Fatal(err)
635 }
636}
637
638type earlyReturnCompactionClient struct {
639 litestream.ReplicaClient

Calls 2

WriteLTXFileMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected