Skip to content

Commit

Permalink
chore: adjusted SegmentWriter to the reader conversion (#13342)
Browse files Browse the repository at this point in the history
Signed-off-by: Vladyslav Diachenko <[email protected]>
Co-authored-by: George Robinson <[email protected]>
Co-authored-by: Ben Clive <[email protected]>
  • Loading branch information
3 people authored Jul 3, 2024
1 parent 7f35179 commit 33bd390
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/storage/chunk/client/object_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ func (o *client) Stop() {
}

func (o *client) PutWal(ctx context.Context, segment *wal.SegmentWriter) error {
buffer := bytes.NewBuffer(nil)
_, err := segment.WriteTo(buffer)
reader, err := segment.ToReader()
if err != nil {
return err
}
return o.store.PutObject(ctx, "wal-segment-"+time.Now().UTC().Format(time.RFC3339Nano), bytes.NewReader(buffer.Bytes()))
defer func(reader io.ReadSeekCloser) {
_ = reader.Close()
}(reader)
return o.store.PutObject(ctx, "wal-segment-"+time.Now().UTC().Format(time.RFC3339Nano), reader)
}

// PutChunks stores the provided chunks in the configured backend. If multiple errors are
Expand Down

0 comments on commit 33bd390

Please sign in to comment.