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

Method OpenLTXFile

vfs_write_test.go:55–74  ·  view source on GitHub ↗
(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, offset, size int64)

Source from the content-addressed store, hash-verified

53}
54
55func (c *writeTestReplicaClient) OpenLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, offset, size int64) (io.ReadCloser, error) {
56 c.mu.Lock()
57 defer c.mu.Unlock()
58
59 key := ltxKey(level, minTXID, maxTXID)
60 data, ok := c.ltxData[key]
61 if !ok {
62 return nil, io.EOF
63 }
64
65 if offset > 0 || size > 0 {
66 end := int64(len(data))
67 if size > 0 && offset+size < end {
68 end = offset + size
69 }
70 data = data[offset:end]
71 }
72
73 return io.NopCloser(bytes.NewReader(data)), nil
74}
75
76func (c *writeTestReplicaClient) WriteLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, r io.Reader) (*ltx.FileInfo, error) {
77 data, err := io.ReadAll(r)

Callers

nothing calls this directly

Calls 3

ltxKeyFunction · 0.85
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected