OpenLTXFile returns a reader for an LTX file. Returns os.ErrNotExist if no matching file is found.
(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, offset, size int64)
| 192 | // OpenLTXFile returns a reader for an LTX file. |
| 193 | // Returns os.ErrNotExist if no matching file is found. |
| 194 | func (c *ReplicaClient) OpenLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, offset, size int64) (io.ReadCloser, error) { |
| 195 | if err := c.Init(ctx); err != nil { |
| 196 | return nil, err |
| 197 | } |
| 198 | |
| 199 | // Build the key from the file info |
| 200 | filename := ltx.FormatFilename(minTXID, maxTXID) |
| 201 | key := c.ltxPath(level, filename) |
| 202 | |
| 203 | request := &oss.GetObjectRequest{ |
| 204 | Bucket: oss.Ptr(c.Bucket), |
| 205 | Key: oss.Ptr(key), |
| 206 | } |
| 207 | |
| 208 | // Set range header if offset is specified |
| 209 | if size > 0 { |
| 210 | request.RangeBehavior = oss.Ptr("standard") |
| 211 | request.Range = oss.Ptr(fmt.Sprintf("bytes=%d-%d", offset, offset+size-1)) |
| 212 | } else if offset > 0 { |
| 213 | request.RangeBehavior = oss.Ptr("standard") |
| 214 | request.Range = oss.Ptr(fmt.Sprintf("bytes=%d-", offset)) |
| 215 | } |
| 216 | |
| 217 | result, err := c.client.GetObject(ctx, request) |
| 218 | if err != nil { |
| 219 | if isNotExists(err) { |
| 220 | return nil, os.ErrNotExist |
| 221 | } |
| 222 | return nil, fmt.Errorf("oss: get object %s: %w", key, err) |
| 223 | } |
| 224 | |
| 225 | internal.OperationTotalCounterVec.WithLabelValues(ReplicaClientType, "GET").Inc() |
| 226 | |
| 227 | return result.Body, nil |
| 228 | } |
| 229 | |
| 230 | // WriteLTXFile writes an LTX file to the replica. |
| 231 | // Extracts timestamp from LTX header and stores it in OSS metadata to preserve original creation time. |
nothing calls this directly
no test coverage detected